aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-02-10 14:27:49 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2019-02-10 14:27:49 +0100
commit5faf705c8e3c0d8c380e2cb7ad11e4ca15d6364f (patch)
treeb0d91d5dda91e5c71bbbd4d7cd20c1e6d9cf9c4d
parentc313e6de8c06017739402ea89f55ce3b36ac0f2b (diff)
downloadee-python-5faf705c8e3c0d8c380e2cb7ad11e4ca15d6364f.tar.gz
ee-python-5faf705c8e3c0d8c380e2cb7ad11e4ca15d6364f.tar.bz2
ee-python-5faf705c8e3c0d8c380e2cb7ad11e4ca15d6364f.tar.xz
ee-python-5faf705c8e3c0d8c380e2cb7ad11e4ca15d6364f.zip
o kicad-mkdeps: making individual dep files for sch and pcb.
-rw-r--r--src/ee/tools/kicad_mkdeps.py65
1 files changed, 31 insertions, 34 deletions
diff --git a/src/ee/tools/kicad_mkdeps.py b/src/ee/tools/kicad_mkdeps.py
index 10c7e97..3094232 100644
--- a/src/ee/tools/kicad_mkdeps.py
+++ b/src/ee/tools/kicad_mkdeps.py
@@ -12,51 +12,45 @@ def p(msg):
def work(args):
- sch = kicad.read_schematics(args.sch)
-
- p("# This file is generated")
- p("ifeq ($(EE),)")
- p(" $(error EE must be set)")
- p("endif")
- p("")
- p("SCH_FILES =")
- for s in sch.schematics:
- p("SCH_FILES += {}".format(s.path))
-
- if args.gerber:
- p("# Gerber rules")
- p("ifeq ($(GERBER_ZIP),)")
- p(" $(error GERBER_ZIP must be set)")
+ if args.sch:
+ sch = kicad.read_schematics(args.sch)
+
+ p("# This file is generated")
+ p("ifeq ($(EE),)")
+ p(" $(error EE must be set)")
p("endif")
- p("gerbers: $(GERBER_ZIP)")
- p("$(GERBER_ZIP): $(SCH_FILES)")
- p("\t@echo GERBER")
- p("\t$(EE) kicad-gerber \\")
- p("\t\t--output-dir $(GERBER_DIR) \\")
- p("\t\t--pcb $(PROJECT).kicad_pcb \\")
- p("\t\t$(GERBER_ARGS)")
- p("\tmkdir -p $(dir $@)")
- p("\t(cd $(GERBER_DIR); zip tmp.zip $(foreach GBR,$(GERBERS),$(notdir $(GBR))))")
- p("\tmv $(GERBER_DIR)/tmp.zip $@")
- p("EE_OUTPUTS += $(GERBER_ZIP)")
p("")
-
- p("")
- p("# Utility targets")
- p(".PHONY: schematic pcb gerber")
- p("schematic: $(SCH_FILES)")
- p("pcb: {}".format(args.pcb))
+ p("SCH_FILES =")
+ for s in sch.schematics:
+ p("SCH_FILES += {}".format(s.path))
+
+ if args.pcb:
+ if args.gerber:
+ p("# Gerber rules")
+ p("ifeq ($(GERBER_ZIP),)")
+ p(" $(error GERBER_ZIP must be set)")
+ p("endif")
+ p("gerbers: $(GERBER_ZIP)")
+ p("$(GERBER_ZIP): $(SCH_FILES)")
+ p("\t@echo GERBER")
+ p("\t$(EE) kicad-gerber \\")
+ p("\t\t--output-dir $(GERBER_DIR) \\")
+ p("\t\t--pcb $(PROJECT).kicad_pcb \\")
+ p("\t\t$(GERBER_ARGS)")
+ p("\tmkdir -p $(dir $@)")
+ p("\t(cd $(GERBER_DIR); zip tmp.zip $(foreach GBR,$(GERBERS),$(notdir $(GBR))))")
+ p("\tmv $(GERBER_DIR)/tmp.zip $@")
+ p("EE_OUTPUTS += $(GERBER_ZIP)")
+ p("")
parser = argparse.ArgumentParser(description="Create a Makefile with all dependencies")
parser.add_argument("--sch",
- required=True,
metavar="SCH",
help="Schematic file")
parser.add_argument("--pcb",
- required=True,
metavar="PCB",
help="PCB file")
@@ -70,6 +64,9 @@ parser.add_argument("--gerber",
args = parser.parse_args()
+if not args.sch and not args.pcb:
+ print("At least one of --sch or --pcb has to be used", file=sys.stderr)
+
if args.out:
with open(args.out, "w") as f:
out_file = f