aboutsummaryrefslogtreecommitdiff
path: root/src/ee/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/tools')
-rw-r--r--src/ee/tools/ninja.py7
-rw-r--r--src/ee/tools/part_apply_souffle_post.py13
-rw-r--r--src/ee/tools/templates/build.ninja.j27
3 files changed, 24 insertions, 3 deletions
diff --git a/src/ee/tools/ninja.py b/src/ee/tools/ninja.py
index c5ee959..a58f0ed 100644
--- a/src/ee/tools/ninja.py
+++ b/src/ee/tools/ninja.py
@@ -58,9 +58,14 @@ def generate(project: Project):
"ee": "{} -m ee".format(os.path.relpath(sys.executable, Path("."))),
"project": project,
"part_dbs": part_dbs,
- "souffle_ee_src": Path(__file__).parent.parent / "souffle",
+ "souffle_ee_src": str(Path(__file__).parent.parent / "souffle"),
+ "is_file": lambda p: os.path.isfile(str(p)),
}
+ kicad_souffle_dl = project.project_dir / "ee" / "custom" / "kicad-souffle.dl"
+ if kicad_souffle_dl.is_file():
+ params["kicad_souffle_dl"] = str(kicad_souffle_dl)
+
gerber_zip = None
if project.cfg.has_section("kicad-project"):
diff --git a/src/ee/tools/part_apply_souffle_post.py b/src/ee/tools/part_apply_souffle_post.py
index 4c23128..961b0c0 100644
--- a/src/ee/tools/part_apply_souffle_post.py
+++ b/src/ee/tools/part_apply_souffle_post.py
@@ -19,6 +19,8 @@ def work(in_path: Path, out_path: Path, work_dir: Path):
for part in in_parts:
out_parts.add_entry(part, False)
+ mpn_csv = work_dir / "out" / "mpn.csv"
+
with (work_dir / "out" / "fact.csv").open("r") as f:
reader = csv.reader(f, dialect="excel-tab")
for uri, key, value in reader:
@@ -33,6 +35,17 @@ def work(in_path: Path, out_path: Path, work_dir: Path):
print("New fact for {}: {}={}".format(uri, key, value))
part.facts.add(key, value)
+ if mpn_csv.is_file():
+ with mpn_csv.open("r") as f:
+ reader = csv.reader(f, dialect="excel-tab")
+ for uri, mpn in reader:
+ try:
+ part = uri_idx.get_single(uri)
+ except KeyError:
+ raise EeException("Unknown part found in output: uri={}".format(uri))
+
+ part.add_mpn(mpn)
+
save_db(out_path, out_parts)
diff --git a/src/ee/tools/templates/build.ninja.j2 b/src/ee/tools/templates/build.ninja.j2
index 894365b..5ae6085 100644
--- a/src/ee/tools/templates/build.ninja.j2
+++ b/src/ee/tools/templates/build.ninja.j2
@@ -98,8 +98,9 @@ build ee/sch.xml: part-apply-function ee/kicad/sch.xml
build ee/kicad/souffle/facts.dl: part-apply-souffle-pre ee/kicad/sch.xml
work = ee/kicad/souffle
-build ee/kicad/souffle/out/fact.csv: souffle {{ souffle_ee_src }}/kicad.dl | ee/kicad/souffle/facts.dl
+build ee/kicad/souffle/out/fact.csv: souffle {{ kicad_souffle_dl if kicad_souffle_dl else souffle_ee_src + "/kicad.dl" }} | ee/kicad/souffle/facts.dl
work = ee/kicad/souffle
+{#- includes = {{ (souffle_ee_src + "/kicad.dl") if kicad_souffle_dl else "" }}#}
build ee/sch.xml: part-apply-souffle-post ee/kicad/souffle/out/fact.csv
in_sch = ee/kicad/sch.xml
@@ -135,7 +136,9 @@ build ee/{{ s }}/parts.xml: part-apply-function ee/{{ s }}/downloaded.xml
build ee/{{ s }}/souffle/facts.dl: part-apply-souffle-pre ee/{{ s }}/downloaded.xml
work = ee/{{ s }}/souffle
-build ee/{{ s }}/souffle/out/fact.csv: souffle {{ souffle_ee_src }}/{{ s }}.dl | ee/{{ s }}/souffle/facts.dl
+{%- set main=souffle_ee_src + "/" + s + ".dl" %}
+{%- set alt="ee/custom/" + s + "-souffle.dl" %}
+build ee/{{ s }}/souffle/out/fact.csv: souffle {{ alt if is_file(alt) else main }} | ee/{{ s }}/souffle/facts.dl
work = ee/{{ s }}/souffle
build ee/{{ s }}/parts.xml: part-apply-souffle-post ee/{{ s }}/souffle/out/fact.csv