1.1 --- a/generator.py Tue Nov 15 19:12:12 2016 +0100
1.2 +++ b/generator.py Tue Nov 15 22:55:57 2016 +0100
1.3 @@ -30,7 +30,7 @@
1.4 encode_symbol, encode_tablename, \
1.5 encode_type_attribute
1.6 from os import listdir
1.7 -from os.path import isdir, join, split
1.8 +from os.path import exists, isdir, join, split
1.9 from referencing import Reference
1.10
1.11 def copy(source, target):
1.12 @@ -73,22 +73,37 @@
1.13 self.optimiser = optimiser
1.14 self.output = output
1.15
1.16 - def to_output(self):
1.17 + def to_output(self, debug=False):
1.18
1.19 "Write the generated code."
1.20
1.21 self.check_output()
1.22 self.write_structures()
1.23 - self.copy_templates()
1.24 + self.copy_templates(debug)
1.25
1.26 - def copy_templates(self):
1.27 + def copy_templates(self, debug=False):
1.28
1.29 "Copy template files to the generated output directory."
1.30
1.31 templates = join(split(__file__)[0], "templates")
1.32
1.33 for filename in listdir(templates):
1.34 - copy(join(templates, filename), self.output)
1.35 + target = self.output
1.36 +
1.37 + # Handle debug resources.
1.38 +
1.39 + if filename.endswith("-debug"):
1.40 + if debug:
1.41 + target = join(self.output, filename[:-len("-debug")])
1.42 + else:
1.43 + continue
1.44 +
1.45 + # Handle non-debug resources.
1.46 +
1.47 + if debug and exists(join(templates, "%s-debug" % filename)):
1.48 + continue
1.49 +
1.50 + copy(join(templates, filename), target)
1.51
1.52 def write_structures(self):
1.53