aboutsummaryrefslogtreecommitdiff
path: root/src/ee/tools/kicad_gerber.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/tools/kicad_gerber.py')
-rwxr-xr-xsrc/ee/tools/kicad_gerber.py60
1 files changed, 41 insertions, 19 deletions
diff --git a/src/ee/tools/kicad_gerber.py b/src/ee/tools/kicad_gerber.py
index d9b0dc1..9f5ade7 100755
--- a/src/ee/tools/kicad_gerber.py
+++ b/src/ee/tools/kicad_gerber.py
@@ -8,10 +8,10 @@ try:
from pcbnew import *
except ImportError as e:
ee_hack = os.environ.get("EE_HACK", "0")
- print("ee_hack={}".format(ee_hack), file=sys.stderr)
+ # print("ee_hack={}".format(ee_hack), file=sys.stderr)
try_p2 = ee_hack == "0"
try_system = ee_hack == "1"
- print("Could not import 'pcbnew' module. Make sure you run this command with KiCAD's python.", file=sys.stderr)
+ # print("Could not import 'pcbnew' module. Make sure you run this command with KiCAD's python.", file=sys.stderr)
ret = 1
try:
@@ -23,20 +23,19 @@ except ImportError as e:
cmd = "/usr/bin/python2 {} {}".format(__file__, " ".join(argv))
env = dict(os.environ)
env["EE_HACK"] = "1"
- print(cmd, file=sys.stderr)
+ # print(cmd, file=sys.stderr)
ret = subprocess.call(cmd, shell=True, env=env)
- print("ret={}".format(ret), file=sys.stderr)
elif try_system:
argv = sys.argv[1:]
# Try with the OS's main python, hopefully the KiCAD packages support that
cmd = "/usr/bin/python3 {} {}".format(__file__, " ".join(argv))
env = dict(os.environ)
env["EE_HACK"] = "2"
- print(cmd, file=sys.stderr)
+ # print(cmd, file=sys.stderr)
ret = subprocess.call(cmd, shell=True, env=env)
- print("ret={}".format(ret), file=sys.stderr)
finally:
pass
+ # print("ret={}".format(ret), file=sys.stderr)
sys.exit(ret)
@@ -70,8 +69,10 @@ parser.add_argument('--detect-files-only',
parser.add_argument('-M',
dest='mkdep',
- action='store_true',
- help='Don\'t create the GERBER files, output a Makefile-compatible file')
+ help='Output a Makefile-compatible file')
+
+parser.add_argument('--index',
+ dest='index')
parser.add_argument('--create-drill-map-file',
dest='create_drill_map_file',
@@ -149,6 +150,7 @@ pctl = PLOT_CONTROLLER(board)
popt = pctl.GetPlotOptions()
output_directory = args.output_directory
+output_directory = os.path.abspath(args.output_directory)
popt.SetOutputDirectory(output_directory)
if not os.path.isdir(output_directory):
@@ -217,20 +219,40 @@ for plan in plot_plan:
# print "filename = " + plan.filename + ", postfix=" + plan.postfix
# print "filename: " + plan.filename
-if args.detect_files_only or args.mkdep:
- if not args.mkdep:
+if args.mkdep:
+ with open(args.mkdep, "w") as f:
+ pcb = os.path.abspath(args.pcb)
+
+ def w(path):
+ p = path[len(os.path.commonprefix([path, pcb])):]
+ print("{}: {}".format(p, args.pcb), file=f)
+
for plan in plot_plan:
- print(plan.filename)
+ w(plan.filename)
+
+ w(drlFileOut)
+ w(drlNpthFileOut)
+
+if args.index:
+ with open(args.index, "w") as f:
+ pcb = os.path.abspath(args.pcb)
+
+ def w(path):
+ p = path[len(os.path.commonprefix([path, pcb])):]
+ print("{}".format(p), file=f)
- print(drlFileOut)
- print(drlNpthFileOut)
- else:
- print("GERBERS = ")
for plan in plot_plan:
- print("GERBERS += {}".format(plan.filename))
- print("GERBERS += {}".format(drlFileOut, args.pcb))
- print("GERBERS += {}".format(drlNpthFileOut, args.pcb))
- print("$(GERBERS): {}".format(args.pcb))
+ w(plan.filename)
+
+ w(drlFileOut)
+ w(drlNpthFileOut)
+
+if args.detect_files_only:
+ for plan in plot_plan:
+ print(plan.filename)
+
+ print(drlFileOut)
+ print(drlNpthFileOut)
sys.exit(0)