aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-05-21 11:00:50 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-05-21 11:00:50 +0200
commitc94c94837bb74defa9001688ca32cbb7a8597d99 (patch)
treea214b398958c65d8e193feaf8142643f310ce3e8 /src
parentc84c6c6bd59a03b21bd285b4f8117f566a23f8d3 (diff)
downloadee-python-c94c94837bb74defa9001688ca32cbb7a8597d99.tar.gz
ee-python-c94c94837bb74defa9001688ca32cbb7a8597d99.tar.bz2
ee-python-c94c94837bb74defa9001688ca32cbb7a8597d99.tar.xz
ee-python-c94c94837bb74defa9001688ca32cbb7a8597d99.zip
ninja/init: Let init specify defaults, ninja just drops arguments if not
specified.
Diffstat (limited to 'src')
-rw-r--r--src/ee/digikey/functions.py5
-rw-r--r--src/ee/tools/init.py2
-rw-r--r--src/ee/tools/templates/build.ninja.j219
3 files changed, 12 insertions, 14 deletions
diff --git a/src/ee/digikey/functions.py b/src/ee/digikey/functions.py
index c902b71..f95fd4c 100644
--- a/src/ee/digikey/functions.py
+++ b/src/ee/digikey/functions.py
@@ -5,7 +5,10 @@ from ee import EeVal, EeException
from ee.part import Part
from ee.xml import types, uris
-__all__ = ["normalize_facts"]
+__all__ = [
+ "normalize_facts",
+ "default",
+]
# TODO: this should be moved to a generic normalizer
diff --git a/src/ee/tools/init.py b/src/ee/tools/init.py
index f77b60b..1e01dc7 100644
--- a/src/ee/tools/init.py
+++ b/src/ee/tools/init.py
@@ -38,7 +38,7 @@ def init_kicad_project(basedir: Path, cfg, args):
def init_digikey(project: Project):
project.cfg.add_section("supplier:digikey")
- project.cfg["supplier:digikey"]["function"] = "ee.kicad.digikey.functions.default"
+ project.cfg["supplier:digikey"]["function"] = "ee.digikey.functions.default"
def init_seeed_opl(project: Project):
diff --git a/src/ee/tools/templates/build.ninja.j2 b/src/ee/tools/templates/build.ninja.j2
index 4d2e22f..522b010 100644
--- a/src/ee/tools/templates/build.ninja.j2
+++ b/src/ee/tools/templates/build.ninja.j2
@@ -72,18 +72,15 @@ build {{ gerber_zip }}: kicad-gerber $pcb
{%- endif %}
{% if sch is defined -%}
+{%- set cfg = project.cfg["kicad-project"] %}
build ee/kicad-sch.xml: kicad-make-bom $sch
build ee/sch.xml: part-apply-function ee/kicad-sch.xml
execution = kicad
-{%- if project.cfg["kicad-project"]["functions"] %}
- functions = --function {{ project.cfg["kicad-project"]["functions"] }}
-{%- else %}
- functions = --function ee.kicad.functions.default
+{%- if cfg and "functions" in cfg and cfg["functions"] %}
+ functions = --function {{ cfg["functions"] }}
{%- endif %}
-{%- if project.cfg["kicad-project"]["function-arguments"] %}
- arguments = --argument {{ project.cfg["kicad-project"]["function-arguments"] }}
-{%- else %}
- arguments =
+{%- if cfg and "function-arguments" in cfg and cfg["function-arguments"] %}
+ arguments = --argument {{ cfg["function-arguments"] }}
{%- endif %}
{%- endif %}
@@ -103,12 +100,10 @@ build ee/{{ s }}/downloaded.xml | ee/{{ s }}/downloaded.rst: {{ s }}-search-part
build ee/{{ s }}/parts.xml: part-apply-function ee/{{ s }}/downloaded.xml
execution = {{ s }}
-{%- if cfg and "functions" in cfg %}
+{%- if cfg and "functions" in cfg and cfg["functions"] %}
functions = --function {{ cfg["functions"] }}
-{%- else %}
- functions = --function ee.{{ s }}.functions.default
{%- endif %}
-{%- if cfg and "function-arguments" in cfg %}
+{%- if cfg and "function-arguments" in cfg and cfg["function-arguments"] %}
arguments = --argument {{ cfg["function-arguments"] }}
{%- endif %}
{%- endfor %}