# HG changeset patch # User Paul Boddie # Date 1487949208 -3600 # Node ID 170ffd3868264b9419adb46f3a6c625bfbf07cb5 # Parent 41c666f36a6ed9fde22c0401cb26b7e09c5d3738 Write compilation options to the generator and translator output details, causing output removal if the options are changed, preserving output where appropriate otherwise. diff -r 41c666f36a6e -r 170ffd386826 common.py --- a/common.py Fri Feb 24 13:27:44 2017 +0100 +++ b/common.py Fri Feb 24 16:13:28 2017 +0100 @@ -31,7 +31,7 @@ "Common output functionality." - def check_output(self): + def check_output(self, options=None): "Check the existing output and remove it if irrelevant." @@ -41,10 +41,14 @@ details = self.importer.get_cache_details() recorded_details = self.get_output_details() - if recorded_details != details: + # Combine cache details with any options. + + full_details = options and (details + " " + options) or details + + if recorded_details != full_details: self.remove_output() - writefile(self.get_output_details_filename(), details) + writefile(self.get_output_details_filename(), full_details) def get_output_details_filename(self): diff -r 41c666f36a6e -r 170ffd386826 generator.py --- a/generator.py Fri Feb 24 13:27:44 2017 +0100 +++ b/generator.py Fri Feb 24 16:13:28 2017 +0100 @@ -82,7 +82,7 @@ "Write the generated code." - self.check_output() + self.check_output("debug=%r gc_sections=%r" % (debug, gc_sections)) self.write_structures() self.write_scripts(debug, gc_sections) self.copy_templates() diff -r 41c666f36a6e -r 170ffd386826 lplc --- a/lplc Fri Feb 24 13:27:44 2017 +0100 +++ b/lplc Fri Feb 24 16:13:28 2017 +0100 @@ -293,7 +293,7 @@ if timings: now = stopwatch("Generation", now) t = translator.Translator(i, d, o, generated_dir) - t.to_output() + t.to_output(debug, gc_sections) if timings: now = stopwatch("Translation", now) diff -r 41c666f36a6e -r 170ffd386826 translator.py --- a/translator.py Fri Feb 24 13:27:44 2017 +0100 +++ b/translator.py Fri Feb 24 16:13:28 2017 +0100 @@ -47,7 +47,7 @@ self.optimiser = optimiser self.output = output - def to_output(self): + def to_output(self, debug=False, gc_sections=False): "Write a program to the configured output directory." @@ -60,7 +60,7 @@ # Clean the output directory of irrelevant data. - self.check_output() + self.check_output("debug=%r gc_sections=%r" % (debug, gc_sections)) for module in self.importer.modules.values(): output_filename = join(output, "%s.c" % module.name)