diff options
author | David Robillard <d@drobilla.net> | 2020-08-14 15:51:12 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-08-14 19:07:52 +0200 |
commit | 3f5ba5908117cf3351702c144a2509f4bf48d75b (patch) | |
tree | 3b0434d1ee5a6749ea1d4b5fecc7492b0272bbd0 /wscript | |
parent | 45cdfed515dbbcb85c6d54076b6103788d097400 (diff) | |
download | serd-3f5ba5908117cf3351702c144a2509f4bf48d75b.tar.gz serd-3f5ba5908117cf3351702c144a2509f4bf48d75b.tar.bz2 serd-3f5ba5908117cf3351702c144a2509f4bf48d75b.zip |
Clean up and separate internal headers
Diffstat (limited to 'wscript')
-rw-r--r-- | wscript | 33 |
1 files changed, 24 insertions, 9 deletions
@@ -91,6 +91,7 @@ def configure(conf): ], 'gcc': [ '-Wno-bad-function-cast', + '-Wno-suggest-attribute=malloc' ], 'msvc': [ '/wd4706', # assignment within conditional expression @@ -147,6 +148,7 @@ lib_source = ['src/byte_source.c', 'src/node.c', 'src/reader.c', 'src/string.c', + 'src/system.c', 'src/uri.c', 'src/writer.c'] @@ -298,22 +300,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(r'#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/system.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_headers + 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 - elif (not l.startswith('#include "') and - l != '#include "serd.h"\n'): + if include_line(l): amalgamation.write(l) for i in ['c', 'h']: |