diff options
author | David Robillard <d@drobilla.net> | 2018-04-29 14:07:29 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-11-25 09:21:03 +0100 |
commit | c8a91d6fcae2b5c7121f059f75e2a164735e56c1 (patch) | |
tree | 17ac52eddfb294bd8746fd1d6db046f6ef97ec98 /wscript | |
parent | f6511f88fe6cab53f6e9e2044926876fac59938b (diff) | |
download | serd-c8a91d6fcae2b5c7121f059f75e2a164735e56c1.tar.gz serd-c8a91d6fcae2b5c7121f059f75e2a164735e56c1.tar.bz2 serd-c8a91d6fcae2b5c7121f059f75e2a164735e56c1.zip |
Clean up and separate internal headers
Diffstat (limited to 'wscript')
-rw-r--r-- | wscript | 32 |
1 files changed, 22 insertions, 10 deletions
@@ -187,23 +187,35 @@ def lint(ctx): def amalgamate(ctx): "builds single-file amalgamated source" import shutil + import re shutil.copy('serd/serd.h', 'build/serd.h') + + def include_line(line): + return (not re.match('#include "[^/]*\.h"', line) and + not re.match('#include "serd/serd.h"', line)) + with open('build/serd.c', 'w') as amalgamation: - with open('src/serd_internal.h') as serd_internal_h: - for l in serd_internal_h: - amalgamation.write(l.replace('serd/serd.h', 'serd.h')) + amalgamation.write('/* This is amalgamated code, do not edit! */\n') + amalgamation.write('#include "serd.h"\n\n') + + for header_path in ['src/serd_internal.h', + 'src/byte_sink.h', + 'src/byte_source.h', + 'src/stack.h', + 'src/string_utils.h', + 'src/uri_utils.h', + 'src/reader.h']: + with open(header_path) as header: + for l in header: + if include_line(l): + amalgamation.write(l) for f in lib_source: with open(f) as fd: amalgamation.write('\n/**\n @file %s\n*/' % f) - header = True for l in fd: - if header: - if l == '*/\n': - header = False - else: - if l != '#include "serd_internal.h"\n': - amalgamation.write(l) + if include_line(l): + amalgamation.write(l) for i in ['c', 'h']: Logs.info('Wrote build/serd.%s' % i) |