From 0ea5515cad0c4e5e33c6ee4fe201e43397417b22 Mon Sep 17 00:00:00 2001 From: Tobias Reiher Date: Tue, 1 Aug 2023 13:41:55 +0200 Subject: [PATCH] Rename `src` directory to `generated` Ref. eng/recordflux/RecordFlux#1369 --- .gitignore | 2 +- MANIFEST.in | 14 +++++++------- Makefile | 46 +++++++++++++++++++++++----------------------- setup.py | 15 ++++++++------- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index 2409d9ad1..ef77ca735 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ .mypy_cache .venv* .vscode/configurationCache.log +/generated \.*.swp __pycache__ build @@ -19,6 +20,5 @@ dist gnatinspect.db htmlcov pyproject.toml -src why3session.xml.bak why3shapes.gz.bak diff --git a/MANIFEST.in b/MANIFEST.in index 479231083..d86f956f2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,11 +4,11 @@ exclude .git* defaults* Makefile MANIFEST.in graft bin graft ide graft rflx -include src/librflxlang.gpr -recursive-include src/src *.ad? *.c *.h -recursive-include src/gnatcoll-bindings/iconv *.ad? *.gpr *.c -recursive-include src/gnatcoll-bindings/gmp *.ad? *.gpr *.c -recursive-include src/adasat *.ad? *.gpr -recursive-include src/python py.typed *.py *.pyi -recursive-include src/langkit/langkit/support *.gpr *.ad? +include generated/librflxlang.gpr +recursive-include generated/src *.ad? *.c *.h +recursive-include generated/gnatcoll-bindings/iconv *.ad? *.gpr *.c +recursive-include generated/gnatcoll-bindings/gmp *.ad? *.gpr *.c +recursive-include generated/adasat *.ad? *.gpr +recursive-include generated/python py.typed *.py *.pyi +recursive-include generated/langkit/langkit/support *.gpr *.ad? global-exclude *.py[cod] diff --git a/Makefile b/Makefile index fa294d883..6d72f6ed5 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,9 @@ VERSION ?= $(shell python3 -c "import setuptools_scm; print(setuptools_scm.get_v SDIST ?= dist/RecordFlux-$(VERSION).tar.gz BUILD_DIR = build -SRC_DIR = src +GENERATED_DIR = generated MAKEFILE_DIR := $(dir $(abspath Makefile)) -BUILD_SRC_DIR := $(MAKEFILE_DIR)/$(BUILD_DIR)/$(SRC_DIR) +BUILD_GENERATED_DIR := $(MAKEFILE_DIR)/$(BUILD_DIR)/$(GENERATED_DIR) PYTHON_PACKAGES = bin doc/language_reference/conf.py doc/user_guide/conf.py examples/apps ide language rflx tests tools stubs setup.py DEVUTILS_HEAD = 7f4319741b23b926aca093467e097005d4a1f642 GNATCOLL_HEAD = 25459f07a2e96eb0f28dcfd5b03febcb72930987 @@ -132,17 +132,17 @@ check_doc: test: test_coverage test_unit_coverage test_language_coverage test_property test_tools test_ide test_optimized test_compilation test_binary_size test_specs test_installation test_apps -# A separate invocation of `coverage report` is needed to exclude `src` in the coverage report. +# A separate invocation of `coverage report` is needed to exclude `$(GENERATED_DIR)` in the coverage report. # Currently, pytest's CLI does not allow the specification of omitted directories # (cf. https://github.com/pytest-dev/pytest-cov/issues/373). test_coverage: timeout -k 60 7200 $(PYTEST) --cov=rflx --cov=tests/unit --cov=tests/integration --cov-branch --cov-fail-under=0 --cov-report= tests/unit tests/integration - coverage report --fail-under=100 --show-missing --skip-covered --omit="src/*" + coverage report --fail-under=100 --show-missing --skip-covered --omit="$(GENERATED_DIR)/*" test_unit_coverage: timeout -k 60 7200 $(PYTEST) --cov=rflx --cov=tests/unit --cov=tools --cov-branch --cov-fail-under=0 --cov-report= tests/unit tests/tools - coverage report --fail-under=94.68 --show-missing --skip-covered --omit="src/*" + coverage report --fail-under=94.68 --show-missing --skip-covered --omit="$(GENERATED_DIR)/*" test_language_coverage: timeout -k 60 7200 $(PYTEST) --cov=rflx_lang --cov-branch --cov-fail-under=73.8 --cov-report=term-missing:skip-covered tests/language @@ -296,37 +296,37 @@ build_pdf_doc_user_guide: dist: $(SDIST) -$(SDIST): $(SRC_DIR)/python/librflxlang pyproject.toml setup.py MANIFEST.in $(wildcard bin/*) $(wildcard rflx/*) +$(SDIST): $(GENERATED_DIR)/python/librflxlang pyproject.toml setup.py MANIFEST.in $(wildcard bin/*) $(wildcard rflx/*) python3 -m build --sdist -$(SRC_DIR)/python/librflxlang: export PYTHONPATH=$(MAKEFILE_DIR) -$(SRC_DIR)/python/librflxlang: $(wildcard language/*.py) - mkdir -p $(BUILD_SRC_DIR) - language/generate.py $(BUILD_SRC_DIR) $(VERSION) - cp -a $(MAKEFILE_DIR)/contrib/langkit $(BUILD_SRC_DIR)/ - cp -a $(MAKEFILE_DIR)/contrib/gnatcoll-bindings $(BUILD_SRC_DIR)/ - cp -a $(MAKEFILE_DIR)/contrib/adasat $(BUILD_SRC_DIR)/ - rm -rf $(SRC_DIR) - mv $(BUILD_SRC_DIR) $(SRC_DIR) +$(GENERATED_DIR)/python/librflxlang: export PYTHONPATH=$(MAKEFILE_DIR) +$(GENERATED_DIR)/python/librflxlang: $(wildcard language/*.py) + mkdir -p $(BUILD_GENERATED_DIR) + language/generate.py $(BUILD_GENERATED_DIR) $(VERSION) + cp -a $(MAKEFILE_DIR)/contrib/langkit $(BUILD_GENERATED_DIR)/ + cp -a $(MAKEFILE_DIR)/contrib/gnatcoll-bindings $(BUILD_GENERATED_DIR)/ + cp -a $(MAKEFILE_DIR)/contrib/adasat $(BUILD_GENERATED_DIR)/ + rm -rf $(GENERATED_DIR) + mv $(BUILD_GENERATED_DIR) $(GENERATED_DIR) .PHONY: parser -parser: $(SRC_DIR)/python/librflxlang/librflxlang.so +parser: $(GENERATED_DIR)/python/librflxlang/librflxlang.so -$(SRC_DIR)/python/librflxlang/librflxlang.so: export GPR_PROJECT_PATH := \ - $(GPR_PROJECT_PATH):src/langkit/langkit/support:src/gnatcoll-bindings/gmp:src/gnatcoll-bindings/iconv:src/adasat -$(SRC_DIR)/python/librflxlang/librflxlang.so: export GNATCOLL_ICONV_OPT := -v -$(SRC_DIR)/python/librflxlang/librflxlang.so: $(wildcard language/*.py) | $(SRC_DIR)/python/librflxlang - gprbuild -p -j0 -Psrc/librflxlang.gpr \ +$(GENERATED_DIR)/python/librflxlang/librflxlang.so: export GPR_PROJECT_PATH := \ + $(GPR_PROJECT_PATH):$(GENERATED_DIR)/langkit/langkit/support:$(GENERATED_DIR)/gnatcoll-bindings/gmp:$(GENERATED_DIR)/gnatcoll-bindings/iconv:$(GENERATED_DIR)/adasat +$(GENERATED_DIR)/python/librflxlang/librflxlang.so: export GNATCOLL_ICONV_OPT := -v +$(GENERATED_DIR)/python/librflxlang/librflxlang.so: $(wildcard language/*.py) | $(GENERATED_DIR)/python/librflxlang + gprbuild -p -j0 -P$(GENERATED_DIR)/librflxlang.gpr \ -XLIBRARY_TYPE=static-pic \ -XLIBRFLXLANG_LIBRARY_TYPE=relocatable \ -XLIBRFLXLANG_STANDALONE=encapsulated - cp $(SRC_DIR)/lib/relocatable/dev/librflxlang.so $@ + cp $(GENERATED_DIR)/lib/relocatable/dev/librflxlang.so $@ .PHONY: clean clean: - rm -rf $(BUILD_DIR)/[^_]* $(SRC_DIR) .coverage .coverage.* .hypothesis .mypy_cache .pytest_cache .ruff_cache + rm -rf $(BUILD_DIR)/[^_]* $(GENERATED_DIR) .coverage .coverage.* .hypothesis .mypy_cache .pytest_cache .ruff_cache $(MAKE) -C examples/apps/ping clean $(MAKE) -C examples/apps/dhcp_client clean $(MAKE) -C doc/language_reference clean diff --git a/setup.py b/setup.py index 719d4d242..cacf9d506 100644 --- a/setup.py +++ b/setup.py @@ -20,10 +20,10 @@ def run(self) -> None: env["GPR_PROJECT_PATH"] = "" env["GPR_PROJECT_PATH"] += ":".join( [ - "src/langkit/langkit/support", - "src/gnatcoll-bindings/gmp", - "src/gnatcoll-bindings/iconv", - "src/adasat", + "generated/langkit/langkit/support", + "generated/gnatcoll-bindings/gmp", + "generated/gnatcoll-bindings/iconv", + "generated/adasat", ] ) env["GNATCOLL_ICONV_OPT"] = "-v" @@ -32,7 +32,7 @@ def run(self) -> None: "gprbuild", "-p", "-j0", - "-Psrc/librflxlang.gpr", + "-Pgenerated/librflxlang.gpr", "-XLIBRARY_TYPE=static-pic", "-XLIBRFLXLANG_LIBRARY_TYPE=relocatable", "-XLIBRFLXLANG_STANDALONE=encapsulated", @@ -41,7 +41,8 @@ def run(self) -> None: check=True, ) shutil.copy( - "src/lib/relocatable/dev/librflxlang.so", "src/python/librflxlang/librflxlang.so" + "generated/lib/relocatable/dev/librflxlang.so", + "generated/python/librflxlang/librflxlang.so", ) super().run() @@ -80,7 +81,7 @@ def run(self) -> None: "Topic :: System :: Networking", ], packages=["rflx", "rflx_ide", "rflx_lang"], - package_dir={"rflx_ide": "ide", "rflx_lang": "src/python/librflxlang"}, + package_dir={"rflx_ide": "ide", "rflx_lang": "generated/python/librflxlang"}, package_data={"rflx_lang": ["librflxlang.so", "py.typed", "*.pyi"]}, include_package_data=True, cmdclass={"bdist_wheel": BuildParser},