diff options
-rw-r--r-- | src/ee/tools/kicad_mkdeps.py | 65 |
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 |