aboutsummaryrefslogtreecommitdiffstats
path: root/wscript
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-04-29 14:07:29 +0200
committerDavid Robillard <d@drobilla.net>2020-06-21 18:12:03 +0200
commit531b6c972df84a8f7545af2158236e9d0c3a460c (patch)
tree23ea435146f9f66e26fb3e615c97899f15cd2ba5 /wscript
parent7d25d7319564fe0b1c89690a99d033952df8e55f (diff)
downloadserd-531b6c972df84a8f7545af2158236e9d0c3a460c.tar.gz
serd-531b6c972df84a8f7545af2158236e9d0c3a460c.tar.bz2
serd-531b6c972df84a8f7545af2158236e9d0c3a460c.zip
Clean up and separate internal headers
Diffstat (limited to 'wscript')
-rw-r--r--wscript30
1 files changed, 21 insertions, 9 deletions
diff --git a/wscript b/wscript
index 8b368811..f902a67e 100644
--- a/wscript
+++ b/wscript
@@ -252,22 +252,34 @@ 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/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']: