From 892109542b3083735a3048836dba7202eaa2c69d Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 24 Sep 2025 17:46:08 +0000 Subject: [PATCH] Generate 64-bit variants of tester1.js/html. Enhance c-pp to accept multiple input files. FossilOrigin-Name: ef6c55e4499957fb46b213540786e5d3928ec096eae1fe759066ed011518e7a2 --- ext/wasm/GNUmakefile | 22 ++++++++++++++----- ext/wasm/c-pp.c | 42 +++++++++++++++++++++++------------- ext/wasm/index.html | 21 ++++++++++-------- ext/wasm/tester1-worker.html | 12 +++++++---- ext/wasm/tester1.c-pp.html | 17 +++++++++++++-- ext/wasm/tester1.c-pp.js | 19 +++++++++++----- ext/wasm/util.make | 24 +++++++++++---------- manifest | 24 ++++++++++----------- manifest.uuid | 2 +- 9 files changed, 119 insertions(+), 64 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 56111316a6..2bb3fa1ce6 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -1019,7 +1019,6 @@ $(out.speedtest1-vanilla.js): $(MAKEFILE) $(speedtest1.cfiles) \ @ls -la $@ $(speedtest1.wasm) speedtest1: $(out.speedtest1-vanilla.js) -#xxx#all: speedtest1 # end speedtest1.js ######################################################################## @@ -1038,12 +1037,25 @@ speedtest1: $(out.speedtest1-vanilla.js) # tester1.js: cases 1 and 2 # tester1.mjs: cases 3 and 4 # +# Then we need those again in 64-bit builds, which require a 64-bit +# pair of js/wasm files. +# # To create those, we filter tester1.c-pp.js with $(bin.c-pp)... -$(eval $(call b.eval.c-pp,filter,tester1.c-pp.js,tester1.js,$(c-pp.D.vanilla))) -$(eval $(call b.eval.c-pp,filter,tester1.c-pp.js,tester1.mjs,$(c-pp.D.esm))) -$(eval $(call b.eval.c-pp,filter,tester1.c-pp.html,tester1.html,$(c-pp.D.vanilla))) -$(eval $(call b.eval.c-pp,filter,tester1.c-pp.html,tester1-esm.html,$(c-pp.D.esm))) +c-pp.D.64bit = -D64bit +$(eval $(call b.eval.c-pp,test,tester1.c-pp.js,tester1.js,$(c-pp.D.vanilla))) +$(eval $(call b.eval.c-pp,test,tester1.c-pp.js,tester1-64bit.js,$(c-pp.D.vanilla64) $(c-pp.D.64bit))) +$(eval $(call b.eval.c-pp,test,tester1.c-pp.js,tester1.mjs,$(c-pp.D.esm))) +$(eval $(call b.eval.c-pp,test,tester1.c-pp.js,tester1-64bit.mjs,$(c-pp.D.esm64) $(c-pp.D.64bit))) +$(eval $(call b.eval.c-pp,test,tester1.c-pp.html,tester1.html,$(c-pp.D.vanilla))) +$(eval $(call b.eval.c-pp,test,tester1.c-pp.html,tester1-64bit.html,$(c-pp.D.vanilla64) $(c-pp.D.64bit))) +$(eval $(call b.eval.c-pp,test,tester1.c-pp.html,tester1-esm.html,$(c-pp.D.esm))) +$(eval $(call b.eval.c-pp,test,tester1.c-pp.html,tester1-esm-64bit.html,$(c-pp.D.esm64) $(c-pp.D.64bit))) +tester1.js: $(out.vanilla.wasm) +tester1.mjs: $(out.esm.wasm) +tester1-64bit.js: $(out.vanilla64.wasm) +tester1-64bit.mjs: $(out.esm64.wasm) tester1: tester1.js tester1.mjs tester1.html tester1-esm.html +tester1: tester1-64bit.js tester1-64bit.mjs tester1-64bit.html tester1-esm-64bit.html # We do not include $(dir.dout)/sqlite3-bundler-friendly.mjs in this # because bundlers are client-specific. We don't use any of them. all quick: tester1 diff --git a/ext/wasm/c-pp.c b/ext/wasm/c-pp.c index 0968a68690..605e8ba5a7 100644 --- a/ext/wasm/c-pp.c +++ b/ext/wasm/c-pp.c @@ -278,6 +278,8 @@ void fatalv(char const *zFmt, va_list va){ vfprintf(stderr, zFmt, va); } fputc('\n', stderr); + fflush(stdout); + fflush(stderr); exit(1); } @@ -1417,15 +1419,16 @@ void cmpp_process_keyword(CmppTokenizer * const t){ void cmpp_process_file(const char * zName){ FileWrapper fw = FileWrapper_empty; CmppTokenizer ct = CmppTokenizer_empty; - FileWrapper_open(&fw, zName, "r"); FileWrapper_slurp(&fw); g_debug(1,("Read %u byte(s) from [%s]\n", fw.nContent, fw.zName)); - ct.zName = zName; - ct.zBegin = fw.zContent; - ct.zEnd = fw.zContent + fw.nContent; - while(cmpp_next_keyword_line(&ct)){ - cmpp_process_keyword(&ct); + if( fw.zContent ){ + ct.zName = zName; + ct.zBegin = fw.zContent; + ct.zEnd = fw.zContent + fw.nContent; + while(cmpp_next_keyword_line(&ct)){ + cmpp_process_keyword(&ct); + } } FileWrapper_close(&fw); if(0!=ct.level.ndx){ @@ -1438,13 +1441,13 @@ void cmpp_process_file(const char * zName){ static void usage(int isErr){ FILE * const fOut = isErr ? stderr : stdout; fprintf(fOut, - "Usage: %s [flags] [infile]\n" + "Usage: %s [flags] [infile...]\n" "Flags:\n", g.zArgv0); #define arg(F,D) fprintf(fOut," %s\n %s\n",F, D) arg("-f|--file FILE","Read input from FILE (default=- (stdin)).\n" - " Alternately, the first non-flag argument is assumed to " - "be the input file."); + " Alternately, non-flag arguments are assumed to " + "be the input files."); arg("-o|--outfile FILE","Send output to FILE (default=- (stdout))"); arg("-DXYZ","Define XYZ to true"); arg("-UXYZ","Undefine XYZ (equivalent to false)"); @@ -1459,13 +1462,16 @@ int main(int argc, char const * const * argv){ int rc = 0; int i; int inclCount = 0; - const char * zInfile = 0; + int nFile = 0; + char const *zFileList[128] = {0}; #define M(X) (0==strcmp(X,zArg)) #define ISFLAG(X) else if(M(X)) #define ISFLAG2(X,Y) else if(M(X) || M(Y)) #define ARGVAL \ if(i+1>=argc) fatal("Missing value for flag '%s'", zArg); \ zArg = argv[++i] + + memset(zFileList, 0, sizeof(zFileList)); g.zArgv0 = argv[0]; atexit(cmpp_atexit); cmpp_initdb(); @@ -1497,8 +1503,10 @@ int main(int argc, char const * const * argv){ ISFLAG2("f","file"){ ARGVAL; do_infile: - if(zInfile) fatal("Cannot use -i more than once."); - zInfile = zArg; + if( nFile>=sizeof(zFileList)/sizeof(zFileList[0]) ){ + fatal("Too many file arguments"); + } + zFileList[nFile++] = zArg; } ISFLAG2("d","delimiter"){ ARGVAL; @@ -1508,17 +1516,21 @@ int main(int argc, char const * const * argv){ } ISFLAG("debug"){ ++g.doDebug; - }else if(!zInfile && '-'!=argv[i][0]){ + }else if('-'!=*zArg){ goto do_infile; }else{ fatal("Unhandled flag: %s", argv[i]); } } - if(!zInfile) zInfile = "-"; + if(!nFile){ + zFileList[nFile++] = "-"; + } if(!g.out.zName) g.out.zName = "-"; if(!inclCount) db_include_dir_add("."); FileWrapper_open(&g.out, g.out.zName, "w"); - cmpp_process_file(zInfile); + for(i = 0; i < nFile; ++i){ + cmpp_process_file(zFileList[i]); + } FileWrapper_close(&g.out); end: return rc ? EXIT_FAILURE : EXIT_SUCCESS; diff --git a/ext/wasm/index.html b/ext/wasm/index.html index fb8a585604..75d7620973 100644 --- a/ext/wasm/index.html +++ b/ext/wasm/index.html @@ -49,20 +49,23 @@