aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-08-04 17:22:53 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2017-08-04 17:22:53 +0200
commite640b3b361a401b4670be04badf14f610a8ad62a (patch)
treec18c67ddd18e35c29a4df3f4c27198aa01a53e6d
parent8842da13087e8331bb37e04653782fe33c8650bf (diff)
downloadkicad-utils-e640b3b361a401b4670be04badf14f610a8ad62a.tar.gz
kicad-utils-e640b3b361a401b4670be04badf14f610a8ad62a.tar.bz2
kicad-utils-e640b3b361a401b4670be04badf14f610a8ad62a.tar.xz
kicad-utils-e640b3b361a401b4670be04badf14f610a8ad62a.zip
o Write the list of files to generate to a file from the python code instead of piping the standard output as it can contain output from KiCAD.
-rw-r--r--cmake/kicad_gerber.cmake16
-rwxr-xr-xpy/kicad_gerber.py16
2 files changed, 21 insertions, 11 deletions
diff --git a/cmake/kicad_gerber.cmake b/cmake/kicad_gerber.cmake
index 8c189c6..327733c 100644
--- a/cmake/kicad_gerber.cmake
+++ b/cmake/kicad_gerber.cmake
@@ -1,5 +1,5 @@
function(kicad_gerber)
- set(options ALL UPPERCASE_EXTENSIONS)
+ set(options ALL UPPERCASE_EXTENSIONS SHOW_OUTPUTS)
set(one_value_args TARGET PCB_FILE DIR ZIP_FILE NAMING_STYLE)
set(multi_value_args LAYER_EXTENSION)
cmake_parse_arguments(ARGS "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
@@ -48,8 +48,11 @@ function(kicad_gerber)
set(prefix "${out_dir}/${basename}")
execute_process(
- COMMAND "${KicadUtilsPyDir}/kicad_gerber.py" --pcb "${pcb_file}" --output-directory "${out_dir}" ${protel} ${uppercase_extensions} ${les} --detect-files-only
- OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${target}-gerber-index.txt
+ COMMAND "${KicadUtilsPyDir}/kicad_gerber.py"
+ --pcb "${pcb_file}"
+ --output-directory "${out_dir}"
+ --detect-files-only ${CMAKE_CURRENT_BINARY_DIR}/${target}-gerber-index.txt
+ ${protel} ${uppercase_extensions} ${les}
OUTPUT_VARIABLE out
ERROR_VARIABLE out
RESULT_VARIABLE res)
@@ -62,7 +65,12 @@ function(kicad_gerber)
file(STRINGS ${CMAKE_CURRENT_BINARY_DIR}/${target}-gerber-index.txt outputs)
list(SORT outputs)
- message("outputs=${outputs}")
+ if (ARGS_SHOW_OUTPUTS)
+ foreach(o ${outputs})
+ get_filename_component(o ${o} NAME)
+ message("Gerber output file: ${o}")
+ endforeach()
+ endif()
add_custom_command(
OUTPUT ${outputs}
COMMAND cmake -E make_directory "${out_dir}"
diff --git a/py/kicad_gerber.py b/py/kicad_gerber.py
index bc73a44..173aae1 100755
--- a/py/kicad_gerber.py
+++ b/py/kicad_gerber.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import sys
import os
import argparse
@@ -27,8 +28,8 @@ parser.add_argument('--output-directory',
parser.add_argument('--detect-files-only',
dest='detect_files_only',
- action='store_true',
- help='Don\'t create the GERBER files, just list the files to be created')
+ action='store',
+ help='Don\'t create the GERBER files, just write a list of to be created')
parser.add_argument('--create-drill-map-file',
dest='create_drill_map_file',
@@ -161,12 +162,13 @@ for plan in plot_plan:
# print "filename: " + plan.filename
if args.detect_files_only:
- for plan in plot_plan:
- print plan.filename
+ with open(args.detect_files_only, "w") as f:
+ for plan in plot_plan:
+ print(plan.filename, file=f)
- if args.protel_extensions:
- print drlFileOut
- print drlNpthFileOut
+ if args.protel_extensions:
+ print(drlFileOut, file=f)
+ print(drlNpthFileOut, file=f)
sys.exit(0)
# Set some important plot options: