From 94d443511ab7190ee07e5fa044682447c1a53f4f Mon Sep 17 00:00:00 2001 From: Vaughn Kottler Date: Mon, 2 Oct 2023 02:44:48 -0500 Subject: [PATCH 1/2] 2.7.3 - Fix a bug with including app sources --- .github/workflows/python-package.yml | 2 +- README.md | 4 +- local/variables/package.yaml | 2 +- pyproject.toml | 2 +- .../valid/scenarios/native2/src/sample.cc | 1 + .../scenarios/native3/src/apps/test_app2.cc | 24 ++++++++++++ yambs/__init__.py | 4 +- yambs/environment/native.py | 39 ++++++++++++------- 8 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 tests/data/valid/scenarios/native3/src/apps/test_app2.cc diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 946bc8a..9639698 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -76,7 +76,7 @@ jobs: - run: | mk python-release owner=vkottler \ - repo=yambs version=2.7.2 + repo=yambs version=2.7.3 if: | matrix.python-version == '3.11' && matrix.system == 'ubuntu-latest' diff --git a/README.md b/README.md index e4f9634..b99dc2d 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ===================================== generator=datazen version=3.1.3 - hash=69e88b1a9e3ab69f9b3eab445a7802b9 + hash=3bb38fe76c9bbcf114c399782c81f0f2 ===================================== --> -# yambs ([2.7.2](https://pypi.org/project/yambs/)) +# yambs ([2.7.3](https://pypi.org/project/yambs/)) [![python](https://img.shields.io/pypi/pyversions/yambs.svg)](https://pypi.org/project/yambs/) ![Build Status](https://github.com/vkottler/yambs/workflows/Python%20Package/badge.svg) diff --git a/local/variables/package.yaml b/local/variables/package.yaml index cf6fbd0..3789d15 100644 --- a/local/variables/package.yaml +++ b/local/variables/package.yaml @@ -1,5 +1,5 @@ --- major: 2 minor: 7 -patch: 2 +patch: 3 entry: mbs diff --git a/pyproject.toml b/pyproject.toml index 6c39654..9e9a154 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__" [project] name = "yambs" -version = "2.7.2" +version = "2.7.3" description = "Yet another meta build-system." readme = "README.md" requires-python = ">=3.11" diff --git a/tests/data/valid/scenarios/native2/src/sample.cc b/tests/data/valid/scenarios/native2/src/sample.cc index 916577b..a64d1b3 100644 --- a/tests/data/valid/scenarios/native2/src/sample.cc +++ b/tests/data/valid/scenarios/native2/src/sample.cc @@ -1,3 +1,4 @@ +/* internal */ #include "sample.h" /* third-party */ diff --git a/tests/data/valid/scenarios/native3/src/apps/test_app2.cc b/tests/data/valid/scenarios/native3/src/apps/test_app2.cc new file mode 100644 index 0000000..07ef038 --- /dev/null +++ b/tests/data/valid/scenarios/native3/src/apps/test_app2.cc @@ -0,0 +1,24 @@ +/* toolchain */ +#include + +/* internal */ +#include "sample2.h" + +int test1(int a, int b) { return a + b; } + +int main(void) { + std::cout << test1(1, 2) << std::endl; + + float a = 0.0f; + for (int i = 0; i < 1000; i++) { + a *= 2.0f; + a /= 2.0f; + std::cout << a << std::endl; + } + + Example5::method1(); + Example5::method2(); + Example5::method3(); + + return 0; +} diff --git a/yambs/__init__.py b/yambs/__init__.py index fe2f79e..43f770d 100644 --- a/yambs/__init__.py +++ b/yambs/__init__.py @@ -1,7 +1,7 @@ # ===================================== # generator=datazen # version=3.1.3 -# hash=4cdba934d8d649c3f1f4df224a1185a7 +# hash=6e76463c5c720d69c1c849b917df5a5f # ===================================== """ @@ -10,4 +10,4 @@ DESCRIPTION = "Yet another meta build-system." PKG_NAME = "yambs" -VERSION = "2.7.2" +VERSION = "2.7.3" diff --git a/yambs/environment/native.py b/yambs/environment/native.py index 8b7076b..2bab694 100644 --- a/yambs/environment/native.py +++ b/yambs/environment/native.py @@ -5,7 +5,7 @@ # built-in from os import linesep from pathlib import Path -from typing import Any, Dict, Set, TextIO +from typing import Any, Dict, Optional, Set, TextIO # third-party from vcorelib.io import ARBITER @@ -15,7 +15,7 @@ from yambs.aggregation import collect_files, populate_sources, sources_headers from yambs.config.native import Native from yambs.dependency.manager import DependencyManager -from yambs.generate.common import get_jinja, render_template +from yambs.generate.common import APP_ROOT, get_jinja, render_template from yambs.generate.ninja import write_continuation from yambs.generate.ninja.format import render_format from yambs.generate.variants import generate as generate_variants @@ -70,34 +70,45 @@ def write_compile_line(self, stream: TextIO, path: Path) -> Path: return out - def write_third_party_line(self, stream: TextIO, path: Path) -> Path: + def write_third_party_line( + self, stream: TextIO, path: Path + ) -> Optional[Path]: """Write a single source-compile line for a third-party source.""" - translator = get_translator(path) + out = None # Get the relative part of the path from the third-party root. rel_part = path.relative_to(self.config.third_party_root) - out = translator.translate(Path("$build_dir", "third-party", rel_part)) + # Ignore applications. + if APP_ROOT not in str(rel_part): + translator = get_translator(path) + out = translator.translate( + Path("$build_dir", "third-party", rel_part) + ) - stream.write( - f"build {out}: {translator.rule} $third_party_dir/{rel_part}" - ) - stream.write(linesep) + stream.write( + f"build {out}: {translator.rule} $third_party_dir/{rel_part}" + ) + stream.write(linesep) return out def write_source_rules(self, stream: TextIO) -> Set[Path]: """Write source rules.""" - # Add third-party sources. - return { + result = { self.write_compile_line(stream, path) for path in self.regular - } | { - self.write_third_party_line(stream, path) - for path in self.third_party } + # Add third-party sources. + for path in self.third_party: + path_result = self.write_third_party_line(stream, path) + if path_result is not None: + result.add(path_result) + + return result + def write_static_library_rule( self, stream: TextIO, outputs: Set[Path] ) -> Path: From f0ccba185673773a4f5b4665a986fb6e67aa59fe Mon Sep 17 00:00:00 2001 From: Vaughn Kottler Date: Mon, 2 Oct 2023 02:53:57 -0500 Subject: [PATCH 2/2] Add include path for source dependencies --- yambs/dependency/handlers/yambs/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yambs/dependency/handlers/yambs/__init__.py b/yambs/dependency/handlers/yambs/__init__.py index 35a6d1a..498c200 100644 --- a/yambs/dependency/handlers/yambs/__init__.py +++ b/yambs/dependency/handlers/yambs/__init__.py @@ -126,6 +126,9 @@ def yambs_handler(task: DependencyTask) -> DependencyState: if task.dep.as_source: task.source_dirs.add(src_include) + task.compile_flags.extend( + ["-iquote", str(rel(src_include, base=task.root.parent))] + ) # Check if loading the project configuration data is necessary. # Read the project's configuration data to find any nested dependencies.