Skip to content

Commit

Permalink
Cleanup|CMake: Tweaked source file merging script
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jul 28, 2016
1 parent a41d1d3 commit 206297a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doomsday/cmake/merge_sources.py
Expand Up @@ -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'):
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 206297a

Please sign in to comment.