aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-08-12 14:22:44 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-08-12 14:22:44 +0200
commit9739fe95e608845311f5cdc60d07d02af0b96b81 (patch)
treeae43b541abebe324d3ee36d10d9d1a023c7ce39f
parent81bd4410efa86722661c809d9522f8c2fcc858ec (diff)
downloadee-python-9739fe95e608845311f5cdc60d07d02af0b96b81.tar.gz
ee-python-9739fe95e608845311f5cdc60d07d02af0b96b81.tar.bz2
ee-python-9739fe95e608845311f5cdc60d07d02af0b96b81.tar.xz
ee-python-9739fe95e608845311f5cdc60d07d02af0b96b81.zip
ninja: Working detection of custom supplier Datalog files.
-rw-r--r--src/ee/tools/ninja.py15
-rw-r--r--src/ee/tools/templates/build.ninja.j24
2 files changed, 13 insertions, 6 deletions
diff --git a/src/ee/tools/ninja.py b/src/ee/tools/ninja.py
index 3df8796..c669ad1 100644
--- a/src/ee/tools/ninja.py
+++ b/src/ee/tools/ninja.py
@@ -13,8 +13,9 @@ from ee.project import Project, SupplierDescriptor
class NinjaSupplier(object):
- def __init__(self, project: Project, supplier: SupplierDescriptor):
+ def __init__(self, project: Project, souffle_ee_src: Path, supplier: SupplierDescriptor):
self.project = project
+ self.souffle_ee_src = souffle_ee_src
self.supplier = supplier
self.key = supplier.key
@@ -31,6 +32,13 @@ class NinjaSupplier(object):
# This needs to be configurable per supplier
return "$public_dir/{}/bom.csv".format(self.key)
+ @property
+ def souffle_script(self):
+ build_it = self.souffle_ee_src / (self.key + ".dl")
+ custom = self.project.public_dir / "custom" / (self.key + "-souffle.dl")
+
+ return custom if custom.is_file() else build_it
+
def ninja_path_filter(s: Union[Path, str, List[str]]) -> str:
if isinstance(s, Path):
@@ -75,10 +83,11 @@ def generate(project: Project):
e.filters["noext"] = noext_filter
return e
+ souffle_ee_src = Path(__file__).parent.parent / "souffle"
params = {
"ee": "{} -m ee".format(os.path.relpath(sys.executable, Path("."))),
"project": project,
- "souffle_ee_src": str(Path(__file__).parent.parent / "souffle"),
+ "souffle_ee_src": str(souffle_ee_src),
"is_file": lambda p: os.path.isfile(str(p)),
}
@@ -103,7 +112,7 @@ def generate(project: Project):
params["pcb"] = Path(project.cfg["kicad-project"]["pcb"])
gerber_zip = "prod/gerber.zip"
- params["suppliers"] = [NinjaSupplier(project, s) for s in project.suppliers]
+ params["suppliers"] = [NinjaSupplier(project, souffle_ee_src, s) for s in project.suppliers]
if gerber_zip is not None:
params["gerber_zip"] = gerber_zip
diff --git a/src/ee/tools/templates/build.ninja.j2 b/src/ee/tools/templates/build.ninja.j2
index 8ca5d3a..c68f505 100644
--- a/src/ee/tools/templates/build.ninja.j2
+++ b/src/ee/tools/templates/build.ninja.j2
@@ -148,9 +148,7 @@ build $public_dir/{{ s.key }}/parts.xml: part-apply-function $public_dir/{{ s.ke
build $public_dir/{{ s.key }}/souffle/facts.dl: part-apply-souffle-pre $public_dir/{{ s.key }}/downloaded.xml
work = $public_dir/{{ s.key }}/souffle
-{%- set main="$souffle_src/" + s.key + ".dl" %}
-{%- set alt="$public_dir/custom/" + s.key + "-souffle.dl" %}
-build $public_dir/{{ s.key }}/souffle/out/add_fact.csv: souffle {{ alt if is_file(alt) else main }} | {{ main }} $public_dir/{{ s.key }}/souffle/facts.dl
+build $public_dir/{{ s.key }}/souffle/out/add_fact.csv: souffle {{ s.souffle_script }} | {{ main }} $public_dir/{{ s.key }}/souffle/facts.dl
work = $public_dir/{{ s.key }}/souffle
build {{ s.part_db }}: part-apply-souffle-post $public_dir/{{ s.key }}/souffle/out/add_fact.csv