Skip to content

Commit

Permalink
Merge pull request #76 from vkottler/dev/2.7.3
Browse files Browse the repository at this point in the history
2.7.3 - Fix a bug with including app sources
  • Loading branch information
vkottler authored Oct 2, 2023
2 parents 6870be4 + f0ccba1 commit 950b6bc
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 21 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.2
repo=yambs version=2.7.3
if: |
matrix.python-version == '3.11'
&& matrix.system == 'ubuntu-latest'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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: 2
patch: 3
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.2"
version = "2.7.3"
description = "Yet another meta build-system."
readme = "README.md"
requires-python = ">=3.11"
Expand Down
1 change: 1 addition & 0 deletions tests/data/valid/scenarios/native2/src/sample.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* internal */
#include "sample.h"

/* third-party */
Expand Down
24 changes: 24 additions & 0 deletions tests/data/valid/scenarios/native3/src/apps/test_app2.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* toolchain */
#include <iostream>

/* 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;
}
4 changes: 2 additions & 2 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=4cdba934d8d649c3f1f4df224a1185a7
# hash=6e76463c5c720d69c1c849b917df5a5f
# =====================================

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

DESCRIPTION = "Yet another meta build-system."
PKG_NAME = "yambs"
VERSION = "2.7.2"
VERSION = "2.7.3"
3 changes: 3 additions & 0 deletions yambs/dependency/handlers/yambs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
39 changes: 25 additions & 14 deletions yambs/environment/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 950b6bc

Please sign in to comment.