Missing targets now named when dependency checking.

This commit is contained in:
Chris Palmer 2019-08-18 10:53:22 +01:00
parent 49c3b6be2c
commit be324c31da
4 changed files with 8 additions and 14 deletions

View File

@ -37,9 +37,10 @@ def read_deps(dname):
deps.append(dep)
return deps
def check_deps(target_mtime, dname):
def check_deps(target, dname):
target_mtime = mtime(target)
if not target_mtime:
return "target missing"
return target + " missing"
if not os.path.isfile(dname):
return "no deps"
deps = read_deps(dname)

View File

@ -84,7 +84,6 @@ def make_parts(target, part_type, parts = None):
# Find all the scad files
#
lib_dir = os.environ['OPENSCADPATH'] + '/NopSCADlib/printed'
used = []
module_suffix = '_dxf' if part_type == 'svg' else '_' + part_type
for dir in [source_dir, lib_dir]:
for filename in os.listdir(dir):
@ -113,7 +112,7 @@ def make_parts(target, part_type, parts = None):
#
part_file = target_dir + "/" + part
dname = deps_name(deps_dir, filename)
changed = check_deps(mtime(part_file), dname)
changed = check_deps(part_file, dname)
changed = times.check_have_time(changed, part)
if part_type == 'stl' and not changed and not part in bounds_map:
changed = "No bounds"
@ -125,14 +124,9 @@ def make_parts(target, part_type, parts = None):
if part_type == 'stl':
bounds = c14n_stl.canonicalise(part_file)
bounds_map[part] = bounds
targets.remove(part)
os.remove(part_maker_name)
#
# Add the files on the BOM to the used list for plates.py
#
for line in open("openscad.log"):
if line[:7] == 'ECHO: "' and line[-6:] == '.' + part_type + '"\n':
used.append(line[7:-2])
#
# Write new bounds file
#
@ -150,4 +144,3 @@ def make_parts(target, part_type, parts = None):
print("Could not find a module called", part[:-4] + module_suffix, "to make", part)
sys.exit(1)
times.print_times()
return used

View File

@ -187,7 +187,7 @@ def tests(tests):
body += ["![%s](%s)\n" %(base_name, png_name)]
dname = deps_name(deps_dir, scad)
oldest = min(mtime(png_name), mtime(bom_name))
oldest = png_name if mtime(png_name) < mtime(bom_name) else bom_name
changed = check_deps(oldest, dname)
changed = times.check_have_time(changed, scad_name)
if changed:

View File

@ -154,14 +154,14 @@ def views(target, do_assemblies = None):
f.write("use <%s/%s>\n" % (dir, filename))
f.write("%s();\n" % module);
#
# Run openscad on the created file
# Run openscad on th created file
#
dname = deps_name(deps_dir, filename)
for explode in [0, 1]:
png_name = target_dir + '/' + module + '.png'
if not explode:
png_name = png_name.replace('_assembly', '_assembled')
changed = check_deps(mtime(png_name), dname)
changed = check_deps(png_name, dname)
changed = times.check_have_time(changed, png_name)
tmp_name = 'tmp.png'
if changed: