From 9739fe95e608845311f5cdc60d07d02af0b96b81 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 12 Aug 2019 14:22:44 +0200 Subject: ninja: Working detection of custom supplier Datalog files. --- src/ee/tools/ninja.py | 15 ++++++++++++--- src/ee/tools/templates/build.ninja.j2 | 4 +--- 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 -- cgit v1.2.3