From db80ff609d570f6074eb35758304a0141a24050a Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 15 Aug 2019 13:33:29 +0200 Subject: create-bom: Add support for passing arguments to tool. Implement fail_on_missing_parts in the CLI. ee: Add StopToolException, makes for a more graceful exit(1) if a tool wants to stop immediately. --- src/ee/tools/create_bom.py | 5 ++++- src/ee/tools/templates/build.ninja.j2 | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/ee/tools') 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"] }} -- cgit v1.2.3