agorararmard | bc4749c | 2021-02-22 22:22:08 +0200 | [diff] [blame] | 1 | # Copyright 2020 SkyWater PDK Authors |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| 15 | # SPDX-License-Identifier: Apache-2.0 |
| 16 | |
| 17 | # The top directory where environment will be created. |
| 18 | TOP_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) |
| 19 | |
| 20 | # A pip `requirements.txt` file. |
| 21 | # https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format |
| 22 | REQUIREMENTS_FILE := requirements.txt |
| 23 | |
| 24 | # A conda `environment.yml` file. |
| 25 | # https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html |
| 26 | ENVIRONMENT_FILE := environment.yml |
| 27 | |
| 28 | $(TOP_DIR)/third_party/make-env/conda.mk: $(TOP_DIR)/.gitmodules |
| 29 | cd $(TOP_DIR); git submodule update --init third_party/make-env |
| 30 | |
| 31 | -include $(TOP_DIR)/third_party/make-env/conda.mk |
| 32 | |
| 33 | .DEFAULT_GOAL := all |
| 34 | |
| 35 | FULL_VERSION := $(shell git describe --long) |
| 36 | TAG_VERSION := $(firstword $(subst -, ,$(FULL_VERSION))) |
| 37 | |
| 38 | RST_SRC = $(shell find -name *.src.rst) |
| 39 | RST_OUT = $(RST_SRC:.src.rst=.rst) |
| 40 | |
| 41 | %.rst: %.src.rst $(TOP_DIR)/docs/*.rst Makefile | $(CONDA_ENV_PYTHON) |
| 42 | @rm -f $@ |
| 43 | $(IN_CONDA_ENV) rst_include include $< - \ |
| 44 | | sed \ |
| 45 | -e's@|TAG_VERSION|@$(TAG_VERSION)@g' \ |
| 46 | -e's@:ref:`Versioning Information`@`Versioning Information <docs/versioning.rst>`_@g' \ |
| 47 | -e's@:ref:`Known Issues`@`Known Issues <docs/known_issues.rst>`_@g' \ |
| 48 | -e's@.. warning::@*Warning*@g' \ |
| 49 | > $@ |
| 50 | |
Tim 'mithro' Ansell | 2e85e4d | 2021-05-18 06:11:02 -0700 | [diff] [blame] | 51 | update-rst: |
agorararmard | bc4749c | 2021-02-22 22:22:08 +0200 | [diff] [blame] | 52 | @echo Found $(RST_SRC) source files. |
Tim 'mithro' Ansell | 2e85e4d | 2021-05-18 06:11:02 -0700 | [diff] [blame] | 53 | @touch $(RST_SRC) |
| 54 | make $(RST_OUT) |
agorararmard | bc4749c | 2021-02-22 22:22:08 +0200 | [diff] [blame] | 55 | |
| 56 | |
| 57 | COPYRIGHT_HOLDER := SkyWater PDK Authors |
| 58 | FIND := find . -path ./env -prune -o -path ./.git -prune -o -path ./third_party -prune -o |
| 59 | ADDLICENSE := addlicense -f ./docs/license_header.txt |
| 60 | fix-licenses: |
| 61 | @# Makefiles |
| 62 | @$(FIND) -type f -name Makefile -exec $(ADDLICENSE) $(ADDLICENSE_EXTRA) -v \{\} \+ |
| 63 | @$(FIND) -type f -name \*.mk -exec $(ADDLICENSE) $(ADDLICENSE_EXTRA) -v \{\} \+ |
| 64 | @# Scripting files |
| 65 | @$(FIND) -type f -name \*.sh -exec $(ADDLICENSE) $(ADDLICENSE_EXTRA) -v \{\} \+ |
| 66 | @$(FIND) -type f -name \*.py -exec $(ADDLICENSE) $(ADDLICENSE_EXTRA) -v \{\} \+ |
| 67 | @# Configuration files |
| 68 | @$(FIND) -type f -name \*.yml -exec $(ADDLICENSE) $(ADDLICENSE_EXTRA) -v \{\} \+ |
| 69 | |
| 70 | .PHONY: fix-licenses |
| 71 | |
| 72 | check-licenses: |
| 73 | @make --no-print-directory ADDLICENSE_EXTRA=--check fix-licenses |
| 74 | |
| 75 | .PHONY: check-licenses |
| 76 | |
| 77 | lint-python: | $(CONDA_ENV_PYTHON) |
| 78 | @echo "Found python files:" |
| 79 | @$(FIND) -type f -name *.py -print | sed -e's/^/ /' |
| 80 | @echo |
| 81 | @$(IN_CONDA_ENV) $(FIND) -type f -name *.py -exec flake8 \{\} \+ || echo |
| 82 | @$(IN_CONDA_ENV) $(FIND) -type f -name *.py -exec flake8 --quiet --count --statistics \{\} \+ |
| 83 | |
| 84 | .PHONY: lint-python |
| 85 | |
| 86 | check: check-licenses lint-python |
| 87 | @true |
| 88 | |
| 89 | all: README.rst |
| 90 | @true |
| 91 | |
| 92 | |
| 93 | .PHONY: all |