summaryrefslogtreecommitdiff
path: root/support/openscad
diff options
context:
space:
mode:
authorMichael Schwarz <michi.schwarz@gmail.com>2014-12-25 15:16:42 +0100
committerMichael Schwarz <michi.schwarz@gmail.com>2014-12-25 15:16:42 +0100
commitd08e4be25f157d59075e0b2a669e6388cb462474 (patch)
tree29b1363948f6dc83fff4c68052b6924f81d215d8 /support/openscad
parent2433482b8768533244480bf15ba759eee3f51969 (diff)
parentbdf3ae0ae3d66235bbff5710ffe1b34e9d7f12d2 (diff)
downloadpogojig-d08e4be25f157d59075e0b2a669e6388cb462474.tar.gz
pogojig-d08e4be25f157d59075e0b2a669e6388cb462474.tar.bz2
pogojig-d08e4be25f157d59075e0b2a669e6388cb462474.zip
Merge branch 'master' into no-examples
Conflicts: .gitignore
Diffstat (limited to 'support/openscad')
-rw-r--r--support/openscad/__main__.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/support/openscad/__main__.py b/support/openscad/__main__.py
index 08b2ab6..3c103e5 100644
--- a/support/openscad/__main__.py
+++ b/support/openscad/__main__.py
@@ -21,17 +21,32 @@ def main(in_path, out_path, deps_path):
temp_mk_path = os.path.join(temp_dir, 'mk')
temp_files_path = os.path.join(temp_dir, 'files')
- _openscad(in_path, out_path, temp_deps_path)
+ # OpenSCAD requires the output file name to end in .stl
+ temp_stl_path = os.path.join(temp_dir, 'out.stl')
+
+ _openscad(in_path, temp_stl_path, temp_deps_path)
mk_content = '%:; echo "$@" >> {}'.format(util.bash_escape_string(temp_files_path))
+ # Use make to parse the dependency makefile written by OpenSCAD
util.write_file(temp_mk_path, mk_content.encode())
util.command(['make', '-s', '-B', '-f', temp_mk_path, '-f', temp_deps_path])
+ # All dependencies as paths relative to the project root.
deps = set(map(relpath, util.read_file(temp_files_path).decode().splitlines()))
- ignored_files = set(map(relpath, [temp_deps_path, temp_mk_path, in_path, out_path]))
+ # Relative paths to all files that should not appear in the dependency makefile.
+ ignored_files = set(map(relpath, [in_path, temp_deps_path, temp_mk_path, temp_stl_path]))
+
+ # Write output files.
_write_dependencies(deps_path, relpath(out_path), deps - ignored_files)
+ os.rename(temp_stl_path, out_path)
-main(*sys.argv[1:])
+try:
+ main(*sys.argv[1:])
+except util.UserError as e:
+ print 'Error:', e
+ sys.exit(1)
+except KeyboardInterrupt:
+ sys.exit(2)