mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-18 10:59:45 +00:00
Now src contains exactly what's embedded in mongoose.c and .h, nothing more. Added `tools/amalgam.sh` to aamlgamate both files at once. There are no functional changes to mongoose.c, .h in this PR, only slight filename changes.
44 lines
1.1 KiB
Python
Executable File
44 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import sys
|
|
import re
|
|
import os
|
|
|
|
cur_src = None
|
|
in_mod = False
|
|
ofile = None
|
|
|
|
strip_re = re.compile(r'/\* Amalgamated: (.*) \*/')
|
|
def clean(l):
|
|
return strip_re.sub(r'\1', l)
|
|
|
|
manifest = []
|
|
fname = sys.argv[1]
|
|
with open(fname) as f:
|
|
for l in f:
|
|
if re.match('#ifdef .*_MODULE_LINES', l):
|
|
l = next(f)
|
|
g = re.match(r'#line [01] "(.*)"', l)
|
|
cur_src = g.group(1)
|
|
|
|
# if there is currently opened file, close it
|
|
if ofile:
|
|
ofile.close()
|
|
|
|
cur_src = re.sub(r'\.\./', '', cur_src)
|
|
|
|
# create directory for the next file if needed
|
|
cur_src_dir = os.path.dirname(cur_src)
|
|
if cur_src_dir != '' and not os.path.exists(cur_src_dir):
|
|
os.makedirs(cur_src_dir)
|
|
|
|
# open next file for writing
|
|
ofile = open(cur_src, "w")
|
|
print('=> %s' % cur_src, file=sys.stderr)
|
|
manifest.append(cur_src)
|
|
next(f)
|
|
elif ofile:
|
|
ofile.write(clean(l))
|
|
|
|
with open('src/%s.manifest' % os.path.basename(fname), 'w') as m:
|
|
print('\n'.join(manifest), file=m)
|