From 206297a71eff7d113fbfbc70009caf206bb689b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Thu, 28 Jul 2016 19:19:55 +0300 Subject: [PATCH] Cleanup|CMake: Tweaked source file merging script --- doomsday/cmake/merge_sources.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doomsday/cmake/merge_sources.py b/doomsday/cmake/merge_sources.py index c1fa43672f..189413997e 100755 --- a/doomsday/cmake/merge_sources.py +++ b/doomsday/cmake/merge_sources.py @@ -7,17 +7,22 @@ usings = set() code = [] +# Read and process all input source files. for fn in sys.argv[2:]: preamble = True in_body = False if_level = 0 source = codecs.open(fn, 'r', 'utf-8').read() for line in source.split(u'\n'): + # Strip BOMs. if line.startswith(BOM): line = line[1:] original_line = line.rstrip() line = line.strip() + # Ignore empty lines and single-line comments. if len(line) == 0: continue + if line.startswith(u'//'): continue + # Keep track of define blocks, they will be included as-is. if line.startswith(u'#if'): if_level += 1 elif line.startswith(u'#endif'): @@ -51,6 +56,7 @@ NL = u'\n' +# Write the merged source file. out_file = codecs.open(sys.argv[1], 'w', 'utf-8') out_file.write(BOM) # BOM # Merged preamble.