From 5a6ab34565fa3d783337a68e07e3500361c8fcf5 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 4 Mar 2019 00:06:32 +0100 Subject: o PartDB: don't die if the directory exist *and* is empty. Ninja creates empty parent directories. o PartDB: escape some path names. o new comamnd: "ninja". Generates a build.ninja from a sch. Not done! --- demo/thirdparty/olinuxino/.gitignore | 2 ++ demo/thirdparty/olinuxino/build.ninja | 56 ++++++++++++++++++++++++++++++ demo/thirdparty/olinuxino/py/olinuxino.py | 57 +++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 demo/thirdparty/olinuxino/.gitignore create mode 100644 demo/thirdparty/olinuxino/build.ninja create mode 100644 demo/thirdparty/olinuxino/py/olinuxino.py (limited to 'demo/thirdparty/olinuxino') diff --git a/demo/thirdparty/olinuxino/.gitignore b/demo/thirdparty/olinuxino/.gitignore new file mode 100644 index 0000000..a0536f7 --- /dev/null +++ b/demo/thirdparty/olinuxino/.gitignore @@ -0,0 +1,2 @@ +ee +.ninja_* diff --git a/demo/thirdparty/olinuxino/build.ninja b/demo/thirdparty/olinuxino/build.ninja new file mode 100644 index 0000000..f25e6ca --- /dev/null +++ b/demo/thirdparty/olinuxino/build.ninja @@ -0,0 +1,56 @@ +ee = ../../../env/bin/python3 -m ee +sch = ../../../thirdparty/olinuxino/HARDWARE/A64-OLinuXino/A64-OLinuXino_Rev_D/A64-OlinuXino_Rev_D.sch +sch_files = $ + ../../../thirdparty/olinuxino/HARDWARE/A64-OLinuXino/A64-OLinuXino_Rev_D/A64-OlinuXino_Rev_D.sch $ + ../../../thirdparty/olinuxino/HARDWARE/A64-OLinuXino/A64-OLinuXino_Rev_D/NAND$ Flash$ ,$ eMMC,$ T-Card$ and$ Audio.sch $ + ../../../thirdparty/olinuxino/HARDWARE/A64-OLinuXino/A64-OLinuXino_Rev_D/Power$ Supply,$ Extensions$ and$ MiPi-DSI$ .sch $ + ../../../thirdparty/olinuxino/HARDWARE/A64-OLinuXino/A64-OLinuXino_Rev_D/USB&HDMI,WiFi&BT,Ethernet,LCD.sch +pcb = ../../../thirdparty/olinuxino/HARDWARE/A64-OLinuXino/A64-OLinuXino_Rev_D/A64-OlinuXino_Rev_D.kicad_pcb + +rule kicad-gerber + description = kicad-gerber + command = $ee kicad-gerber $ + --output-dir $gerber_dir $ + --pcb $pcb +# mkdir -p $( +# (cd $(GERBER_DIR); zip tmp.zip $(foreach GBR,$(GERBERS),$(notdir $(GBR)))) +# mv $(GERBER_DIR)/tmp.zip $@ + +rule kicad-make-bom + description = kicad-make-bom $out_dir + command = $ee kicad-make-bom --sch $sch --out $out_dir $strategy + +rule part-create-distributor-search-list + description = part-create-distributor-search-list distributor=$distributor $in_dir => $out_dir + command = $ee part-create-distributor-search-list --in $in_dir --out $out_dir + +rule digikey-search-parts + description = digikey-search-parts + command = $ee digikey-search-parts --in $in_dir --out $out_dir + +rule digikey-normalize-facts + description = digikey-normalize-facts + command = $ee digikey-normalize-facts --in $in_dir --out $out_dir + + +build gerbers: phony prod/gerber.zip +build prod/gerber.zip: kicad-gerber $pcb + gerber_dir = prod + +build ee/sch/index.xml: kicad-make-bom $sch + out_dir = ee/sch + strategy = --strategy olinuxino.make_bom_strategy + +build ee/digikey/search-list/index.xml: part-create-distributor-search-list ee/sch/index.xml + in_dir = ee/sch + out_dir = ee/digikey/search-list + +build ee/digikey/downloaded/index.xml: digikey-search-parts ee/digikey/search-list/index.xml + in_dir = ee/digikey/search-list + out_dir = ee/digikey/downloaded + +build ee/digikey/normalized/index.xml: digikey-normalize-facts ee/digikey/downloaded/index.xml + in_dir = ee/digikey/downloaded + out_dir = ee/digikey/normalized + +default ee/digikey/normalized/index.xml diff --git a/demo/thirdparty/olinuxino/py/olinuxino.py b/demo/thirdparty/olinuxino/py/olinuxino.py new file mode 100644 index 0000000..cc33a81 --- /dev/null +++ b/demo/thirdparty/olinuxino/py/olinuxino.py @@ -0,0 +1,57 @@ +import re + +from ee.kicad import Component +from ee.kicad.make_bom import MakeBomStrategy +from ee.xml import bomFile +from ee.xml.bom_file_utils import facts + + +class OlinuxinoMakeBomStrategy(MakeBomStrategy): + def process_part(self, component: Component, part: bomFile.Part): + print(component.ref) + print(" value={}".format(component.value)) + print(" footprint={}".format(component.footprint)) + + if component.ref_type == "C": + v = component.value + + if v == "NA": + print(" NA".format()) + return part + + na = v.startswith("NA(") and v.endswith(")") + v = v[3:-1] if na else v + + r = re.compile("([0-9]+\\.?[0-9]*[pnum]F)/([0-9]+\\.?[0-9]*[k]?V)/([0-9]+%)(?:/([A-Z][0-9][A-Z]))?") + + m = r.match(v) + + if m: + capacitance = m.group(1) + " F" + voltage = m.group(2) + " V" + tolerance = m.group(3) + "%" + derating = m.group(4) + + print(" capacitance {}".format(capacitance)) + print(" voltage {}".format(voltage)) + print(" tolerance {}".format(tolerance)) + if derating: + print(" derating {}".format(derating)) + if na: + print(" NA".format()) + + fs = facts(part, create=True) + fs.add_fact(bomFile.Fact(key="capacitance", value=capacitance)) + fs.add_fact(bomFile.Fact(key="max_voltage", value=voltage)) + fs.add_fact(bomFile.Fact(key="tolerance", value=tolerance)) + if derating: + fs.add_fact(bomFile.Fact(key="derating", value=derating)) + + else: + print("FAIL") + + return part + + +def make_bom_strategy(): + return OlinuxinoMakeBomStrategy() -- cgit v1.2.3