1.1 --- a/generator.py Wed Jan 25 00:03:08 2017 +0100
1.2 +++ b/generator.py Fri Jan 27 15:27:17 2017 +0100
1.3 @@ -98,9 +98,10 @@
1.4
1.5 self.check_output()
1.6 self.write_structures()
1.7 - self.copy_templates(debug)
1.8 + self.write_scripts(debug)
1.9 + self.copy_templates()
1.10
1.11 - def copy_templates(self, debug=False):
1.12 + def copy_templates(self):
1.13
1.14 "Copy template files to the generated output directory."
1.15
1.16 @@ -108,20 +109,6 @@
1.17
1.18 for filename in listdir(templates):
1.19 target = self.output
1.20 -
1.21 - # Handle debug resources.
1.22 -
1.23 - if filename.endswith("-debug"):
1.24 - if debug:
1.25 - target = join(self.output, filename[:-len("-debug")])
1.26 - else:
1.27 - continue
1.28 -
1.29 - # Handle non-debug resources.
1.30 -
1.31 - if debug and exists(join(templates, "%s-debug" % filename)):
1.32 - continue
1.33 -
1.34 pathname = join(templates, filename)
1.35
1.36 # Copy files into the target directory.
1.37 @@ -438,6 +425,34 @@
1.38 f_signatures.close()
1.39 f_code.close()
1.40
1.41 + def write_scripts(self, debug):
1.42 +
1.43 + "Write scripts used to build the program."
1.44 +
1.45 + f_native = open(join(self.output, "native.mk"), "w")
1.46 + f_options = open(join(self.output, "options.mk"), "w")
1.47 + try:
1.48 + if debug:
1.49 + print >>f_options, "CFLAGS = -g"
1.50 +
1.51 + # Identify native modules used by the program.
1.52 +
1.53 + native_modules = ["native/common.c"]
1.54 +
1.55 + for name in self.importer.modules.keys():
1.56 + parts = name.split(".", 1)
1.57 +
1.58 + # Identify source files to be built.
1.59 +
1.60 + if parts[0] == "native":
1.61 + native_modules.append("native/%s.c" % parts[1])
1.62 +
1.63 + print >>f_native, "SRC =", " ".join(native_modules)
1.64 +
1.65 + finally:
1.66 + f_native.close()
1.67 + f_options.close()
1.68 +
1.69 def make_literal_constant(self, f_decls, f_defs, n, constant):
1.70
1.71 """