Skip to content

Commit

Permalink
Merge pull request #80 from vkottler/dev/2.7.5
Browse files Browse the repository at this point in the history
2.7.5 - Add support for extra source directories
  • Loading branch information
vkottler committed Oct 26, 2023
2 parents a6a2143 + 8a354ec commit 48016dd
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- run: |
mk python-release owner=vkottler \
repo=yambs version=2.7.4
repo=yambs version=2.7.5
if: |
matrix.python-version == '3.11'
&& matrix.system == 'ubuntu-latest'
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!--
=====================================
generator=datazen
version=3.1.3
hash=e7ae68711a56d6cf890b6a6d9ecbac52
version=3.1.4
hash=b26d761fc77bb1ddee83a2faa6a6fa5f
=====================================
-->

# yambs ([2.7.4](https://pypi.org/project/yambs/))
# yambs ([2.7.5](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)
Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 2
minor: 7
patch: 4
patch: 5
entry: mbs
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "yambs"
version = "2.7.4"
version = "2.7.5"
description = "Yet another meta build-system."
readme = "README.md"
requires-python = ">=3.11"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# =====================================
# generator=datazen
# version=3.1.3
# version=3.1.4
# hash=f3af34a4b5815c617489419b194b30b5
# =====================================

Expand Down
2 changes: 1 addition & 1 deletion tasks/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# =====================================
# generator=datazen
# version=3.1.3
# version=3.1.4
# hash=9f62028523c3b5a953733ca89dcc3018
# =====================================
"""
Expand Down
1 change: 1 addition & 0 deletions tests/data/valid/scenarios/native/src/apps/test_app1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ int main(void) {

Example4::method1();
Example4::method2();
Example4::method3();

return 0;
}
1 change: 1 addition & 0 deletions tests/data/valid/scenarios/native/src/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ namespace Example4 {

void method1(void);
void method2(void);
void method3(void);

} // namespace Example4
10 changes: 10 additions & 0 deletions tests/data/valid/scenarios/native/src_extra/method3.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "test.h"

namespace Example4 {

void method3() {
method1();
method2();
}

} // namespace Example4
4 changes: 1 addition & 3 deletions tests/data/valid/scenarios/native/yambs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ cflag_groups:
opt: [-O2]

extra_dist: [extra]
extra_sources: [src_extra]

project:
name: yambs
github:
owner: &self vkottler

variants:
debug:
suffix: "-12"

# Toggle this to test regeneration.
# new_variant: {}

Expand Down
6 changes: 3 additions & 3 deletions yambs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.3
# hash=aaab3e6d3985b3eaea023dad3c4aea9b
# version=3.1.4
# hash=ec366500d47c9484008309e85a10fb06
# =====================================

"""
Expand All @@ -10,4 +10,4 @@

DESCRIPTION = "Yet another meta build-system."
PKG_NAME = "yambs"
VERSION = "2.7.4"
VERSION = "2.7.5"
2 changes: 1 addition & 1 deletion yambs/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# =====================================
# generator=datazen
# version=3.1.3
# version=3.1.4
# hash=baa87aaac0a761679ca051feeebbec02
# =====================================
"""
Expand Down
2 changes: 1 addition & 1 deletion yambs/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# =====================================
# generator=datazen
# version=3.1.3
# version=3.1.4
# hash=4b61ad6ad675ba2556b5e4af32b9d400
# =====================================

Expand Down
2 changes: 1 addition & 1 deletion yambs/commands/all.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# =====================================
# generator=datazen
# version=3.1.3
# version=3.1.4
# hash=a579de7276b0c8f219e976ab8cc6a008
# =====================================

Expand Down
5 changes: 5 additions & 0 deletions yambs/data/schemas/config_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ properties:
items:
type: string

extra_sources:
type: array
items:
type: string

project:
$ref: package://yambs/schemas/Project.yaml

Expand Down
2 changes: 1 addition & 1 deletion yambs/entry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# =====================================
# generator=datazen
# version=3.1.3
# version=3.1.4
# hash=8fa30f62c899316f16c8a16146b7ef7e
# =====================================

Expand Down
20 changes: 17 additions & 3 deletions yambs/environment/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# third-party
from vcorelib.io import ARBITER
from vcorelib.logging import LoggerMixin
from vcorelib.paths import Pathlike, normalize

# internal
from yambs.aggregation import collect_files, populate_sources, sources_headers
Expand All @@ -27,6 +28,13 @@ def resolve_build_dir(build_root: Path, variant: str, path: Path) -> Path:
return build_root.joinpath(variant, path.relative_to(BUILD_DIR_PATH))


def combine_if_not_absolute(root: Path, candidate: Pathlike) -> Path:
"""https://github.com/vkottler/ifgen/blob/master/ifgen/paths.py"""

candidate = normalize(candidate)
return candidate if candidate.is_absolute() else root.joinpath(candidate)


class NativeBuildEnvironment(LoggerMixin):
"""A class implementing a native-build environment."""

Expand Down Expand Up @@ -77,8 +85,11 @@ def write_third_party_line(

out = None

# Get the relative part of the path from the third-party root.
rel_part = path.relative_to(self.config.third_party_root)
try:
# Get the relative part of the path from the third-party root.
rel_part = path.relative_to(self.config.third_party_root)
except ValueError:
rel_part = Path("..", path.relative_to(self.config.root))

# Ignore applications.
if APP_ROOT not in str(rel_part):
Expand Down Expand Up @@ -234,7 +245,10 @@ def generate(self, sources_only: bool = False) -> None:
)

# Handle additional source directories (belonging to dependencies).
for path in self.dependency_manager.source_dirs:
for path in self.dependency_manager.source_dirs | {
combine_if_not_absolute(self.config.root, x)
for x in self.config.data.get("extra_sources", [])
}:
collect_files(path, files=self.sources)
populate_sources(
self.sources,
Expand Down

0 comments on commit 48016dd

Please sign in to comment.