From bc7bf2a09fe430bb2048842626ecbb476bc6b40c Mon Sep 17 00:00:00 2001 From: Luchs Date: Thu, 16 Apr 2015 14:39:39 +0200 Subject: [PATCH] Print LICENSE on top of the amalgamation --- script/generate_amalgamation.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/script/generate_amalgamation.py b/script/generate_amalgamation.py index cf34cc02..01faad6c 100755 --- a/script/generate_amalgamation.py +++ b/script/generate_amalgamation.py @@ -5,10 +5,19 @@ from os.path import basename, dirname, join import re INCLUDE_PATTERN = re.compile(r'^\s*#include "([\w.]+)"') +WREN_DIR = dirname(dirname(realpath(__file__))) seen_files = set() out = sys.stdout +# Prints a plain text file, adding comment markers. +def add_comment_file(filename): + with open(filename, 'r') as f: + for line in f: + out.write('// ') + out.write(line) + +# Prints the given C source file, recursively resolving local #includes. def add_file(filename): bname = basename(filename) # Only include each file at most once. @@ -27,5 +36,9 @@ def add_file(filename): out.write(line) out.write('// End file "{0}"\n'.format(filename)) +# Print license on top. +add_comment_file(join(WREN_DIR, 'LICENSE')) +out.write('\n') +# Source files. for f in sys.argv[1:]: add_file(f)