33# Creates the amalgamated source files.
44#
55
6+ import zipfile
67import sys
78import os .path
89import subprocess
1819PROJECTPATH = os .path .dirname (SCRIPTPATH )
1920print (f"SCRIPTPATH={ SCRIPTPATH } PROJECTPATH={ PROJECTPATH } " )
2021
21-
22- print ("We are about to amalgamate all ada files into one source file." )
23- print ("See https://www.sqlite.org/amalgamation.html and https://en.wikipedia.org/wiki/Single_Compilation_Unit for rationale." )
2422if "AMALGAMATE_SOURCE_PATH" not in os .environ :
2523 AMALGAMATE_SOURCE_PATH = os .path .join (PROJECTPATH , "src" )
2624else :
@@ -71,7 +69,7 @@ def dofile(fid, prepath, filename):
7169 RELFILE = os .path .relpath (file , PROJECTPATH )
7270 # Last lines are always ignored. Files should end by an empty lines.
7371 print (f"/* begin file { RELFILE } */" , file = fid )
74- includepattern = re .compile ('\s*#\s*include "(.*)"' )
72+ includepattern = re .compile ('\\ s*#\ \ s*include "(.*)"' )
7573 with open (file , 'r' ) as fid2 :
7674 for line in fid2 :
7775 line = line .rstrip ('\n ' )
@@ -84,7 +82,7 @@ def dofile(fid, prepath, filename):
8482
8583 if includedfile .startswith ('../' ):
8684 includedfile = includedfile [2 :]
87- # we explicitly include ada headers, one time each
85+ # we explicitly include ada headers, one time each
8886 doinclude (fid , includedfile , line , filename )
8987 else :
9088 print (line , file = fid )
@@ -132,7 +130,6 @@ def dofile(fid, prepath, filename):
132130 shutil .copy2 (os .path .join (SCRIPTPATH ,"demo.cpp" ),AMALGAMATE_OUTPUT_PATH )
133131 shutil .copy2 (os .path .join (SCRIPTPATH ,"README.md" ),AMALGAMATE_OUTPUT_PATH )
134132
135- import zipfile
136133zf = zipfile .ZipFile (os .path .join (AMALGAMATE_OUTPUT_PATH ,'singleheader.zip' ), 'w' , zipfile .ZIP_DEFLATED )
137134zf .write (os .path .join (AMALGAMATE_OUTPUT_PATH ,"ada.cpp" ), "ada.cpp" )
138135zf .write (os .path .join (AMALGAMATE_OUTPUT_PATH ,"ada.h" ), "ada.h" )
0 commit comments