aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ee/__init__.py5
-rw-r--r--src/ee/bom.py8
-rw-r--r--src/ee/tools/create_bom.py5
-rw-r--r--src/ee/tools/templates/build.ninja.j212
4 files changed, 21 insertions, 9 deletions
diff --git a/src/ee/__init__.py b/src/ee/__init__.py
index ea887b1..bbb9281 100644
--- a/src/ee/__init__.py
+++ b/src/ee/__init__.py
@@ -8,6 +8,7 @@ from ee.formatting import eng_str
__all__ = [
"EeException",
+ "StopToolException",
"EeVal",
"EeValType",
"resistance_type",
@@ -21,6 +22,10 @@ class EeException(Exception):
pass
+class StopToolException(EeException):
+ pass
+
+
class EeValType(object):
def __init__(self, symbol, alternate_symbols):
self.symbol = symbol
diff --git a/src/ee/bom.py b/src/ee/bom.py
index 96da25a..e12260c 100644
--- a/src/ee/bom.py
+++ b/src/ee/bom.py
@@ -3,7 +3,7 @@ import pydoc
from pathlib import Path
from typing import List, Optional
-from ee import EeException
+from ee import EeException, StopToolException
from ee.db import ObjDb
from ee.logging import log
from ee.part import PartDb, load_db, save_db, Part, fact_keys
@@ -134,12 +134,12 @@ def create_bom(project: Project, schematic_path: Path, out_path: Path, part_dbs:
bom_parts.add_multi_index("supplier,part", lambda op: (
op.selected_part.supplier, op.selected_part.uri) if op.selected_part else None)
- if len(unresolved_parts) and fail_on_missing_parts:
- raise EeException("The bom has parts that can't be found from any supplier")
-
out_file = project.report_dir / (os.path.splitext(out_path.name)[0] + ".rst")
make_report(out_file, unresolved_parts, bom_parts, supplier_parts)
+ if len(unresolved_parts) and fail_on_missing_parts:
+ raise StopToolException("The bom has parts that can't be found from any supplier")
+
out_parts = PartDb()
found_parts = 0
for bom_part in bom_parts:
diff --git a/src/ee/tools/create_bom.py b/src/ee/tools/create_bom.py
index afeb67e..f98edd9 100644
--- a/src/ee/tools/create_bom.py
+++ b/src/ee/tools/create_bom.py
@@ -24,11 +24,14 @@ parser.add_argument("--part-db",
parser.add_argument("--strategy",
metavar="FUNC")
+parser.add_argument("--fail-on-missing",
+ action="store_true")
+
args = parser.parse_args()
ee.tools.process_default_argparse_group(args)
project = Project.load()
part_db_dirs = [Path(part_db) for part_db in args.part_db]
-fail_on_missing_parts = False
+fail_on_missing_parts = args.fail_on_missing
create_bom(project, Path(args.schematic), Path(args.out), part_db_dirs, fail_on_missing_parts, args.strategy)
diff --git a/src/ee/tools/templates/build.ninja.j2 b/src/ee/tools/templates/build.ninja.j2
index 5bdb686..ddb47d5 100644
--- a/src/ee/tools/templates/build.ninja.j2
+++ b/src/ee/tools/templates/build.ninja.j2
@@ -63,7 +63,7 @@ rule element14-search-parts
command = $ee element14-search-parts {{ log }} --in $in --out $out
rule create-bom
- command = $ee create-bom {{ log }} --schematic $schematic --part-db $part_dbs --out $out $strategy
+ command = $ee create-bom {{ log }} --schematic $schematic --part-db $part_dbs --out $out $strategy $args
rule split-bom-by-supplier
command = $ee split-bom-by-supplier {{ log }} --bom $in $part_dbs $suppliers $orders
@@ -95,7 +95,7 @@ default gerbers
{% if sch is defined -%}
{%- set cfg = project.cfg["kicad-project"] %}
build $public_dir/kicad/sch.xml: kicad-make-bom $sch
-{#
+{#-
build $public_dir/sch.xml: part-apply-function $public_dir/kicad/sch.xml
execution = kicad
{%- if cfg and "functions" in cfg and cfg["functions"] %}
@@ -143,7 +143,7 @@ build $public_dir/{{ s.key }}/datasheets.xml: part-download-datasheets $public_d
dir = $public_dir/{{ s.key }}/datasheets
{%- set _=datasheets.append("$public_dir/" + s.key + "/datasheets.xml") %}
-{#
+{#-
build $public_dir/{{ s.key }}/parts.xml: part-apply-function $public_dir/{{ s.key }}/downloaded.xml
execution = {{ s.key }}
{%- if cfg and "functions" in cfg and cfg["functions"] %}
@@ -153,6 +153,7 @@ build $public_dir/{{ s.key }}/parts.xml: part-apply-function $public_dir/{{ s.ke
arguments = --argument {{ cfg["function-arguments"] }}
{%- endif %}
#}
+
build $public_dir/{{ s.key }}/souffle/facts.dl: part-apply-souffle-pre $public_dir/{{ s.key }}/downloaded.xml
work = $public_dir/{{ s.key }}/souffle
@@ -164,7 +165,7 @@ build {{ s.part_db }}: part-apply-souffle-post $public_dir/{{ s.key }}/souffle/o
work = $public_dir/{{ s.key }}/souffle
rule {{ s.key }}-create-bom
- command = $ee {{ s.key }}-create-bom {{ log }} --bom $in --out $out $part_dbs --allow-incomplete
+ command = $ee {{ s.key }}-create-bom {{ log }} --bom $in --out $out $part_dbs
build {{ s.bom_output }}: {{ s.key }}-create-bom {{ s.bom_input }}
part_dbs = --part-db {{ s.part_db }}
@@ -178,6 +179,9 @@ build {{ out }}: import-parts-yaml {{ f }}
build $public_dir/bom.xml | $report_dir/bom.rst: create-bom $public_dir/sch.xml {%- for s in suppliers %} {{ s.part_db }}{% endfor %}
schematic = $public_dir/sch.xml
+{%- if project.cfg["create-bom"] and project.cfg["create-bom"]["args"] %}
+ args = {{ project.cfg["create-bom"]["args"] }}
+{%- endif %}
part_dbs = {%- for s in suppliers %} {{ s.part_db }}{% endfor %}
{%- if project.cfg["create-bom"] and project.cfg["create-bom"]["strategy"] %}
strategy = --strategy {{ project.cfg["create-bom"]["strategy"] }}