]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Get most of the wasm build (re)working and much prettier.
authorstephan <stephan@noemail.net>
Tue, 23 Sep 2025 13:49:44 +0000 (13:49 +0000)
committerstephan <stephan@noemail.net>
Tue, 23 Sep 2025 13:49:44 +0000 (13:49 +0000)
FossilOrigin-Name: a5a7890c75003a637a227b700dc342f4f4a24bd368b216bdb168b4ddfbe8f015

ext/wasm/GNUmakefile
ext/wasm/mkwasmbuilds.c
manifest
manifest.uuid

index dc7e3547e6b1786377b12c8bb44190de828fbf5a..3de6572fa83ada136f80fada17fffb36c13856f0 100644 (file)
@@ -224,20 +224,6 @@ $(sqlite3.h):
 #      $(MAKE) -C $(dir.top) sqlite3.c
 $(sqlite3.c): $(sqlite3.h)
 
-########################################################################
-# barebones=1 disables all "extraneous" stuff from sqlite3-wasm.c, the
-# goal being to create a WASM file with only the core APIs.
-ifeq (1,$(barebones))
-  wasm-bare-bones = 1
-  $(info ==============================================================)
-  $(info == This is a bare-bones build. It trades away features for)
-  $(info == a smaller .wasm file.)
-  $(info ==============================================================)
-else
-  wasm-bare-bones = 0
-endif
-# undefine barebones # relatively new gmake feature, not ubiquitous
-
 # Common options for building sqlite3-wasm.c and speedtest1.c.
 # Explicit ENABLEs...
 SQLITE_OPT.common = \
@@ -510,7 +496,7 @@ endif
 SQLITE.strip-emcc-js-cruft = \
   sed -i -e '/^.*= \(_sqlite3\|_fiddle\)[^=]*=.*createExportWrapper/d' \
   -e '/^var \(_sqlite3\|_fiddle\)[^=]*=.*makeInvalidEarlyAccess/d' $@ || exit; \
-  echo '$(1) $(emo.disk) (Probably) /createExportWrapper()/d and /makeInvalidEarlyAccess()/d.'
+  echo '$(1) $(emo.garbage) (Probably) /createExportWrapper()/d and /makeInvalidEarlyAccess()/d.'
 
 # When passing emcc_opt from the CLI, += and re-assignment have no
 # effect, so emcc_opt+=-g3 doesn't work. So...
@@ -765,28 +751,6 @@ $(sqlite3-api-build-version.js): $(MKDIR.bld) $(bin.version-info) $(MAKEFILE)
     echo '});'; \
   } > $@
 
-########################################################################
-# --post-js and --pre-js are emcc flags we use to append/prepend JS to
-# the generated emscripten module file. These rules set up the core
-# pre/post files for use by the various builds. --pre-js is used to
-# inject code which needs to run as part of the pre-WASM-load phase.
-# --post-js injects code which runs after the WASM module is loaded
-# and includes the entirety of the library plus some
-# Emscripten-specific post-bootstrapping code.
-pre-js.js.in = $(dir.api)/pre-js.c-pp.js
-post-js.js.in = $(dir.tmp)/post-js.c-pp.js
-post-jses.js = \
-  $(dir.api)/post-js-header.js \
-  $(sqlite3-api.js.in) \
-  $(dir.api)/post-js-footer.js
-$(post-js.js.in): $(MKDIR.bld) $(post-jses.js) $(MAKEFILE)
-       @echo "Making $@..."
-       @for i in $(post-jses.js); do \
-               echo "/* BEGIN FILE: $$i */"; \
-               cat $$i; \
-               echo "/* END FILE: $$i */"; \
-       done > $@
-
 
 # Undocumented Emscripten feature: if the target file extension is
 # "mjs", it defaults to ES6 module builds:
@@ -893,6 +857,56 @@ EXPORTED_FUNCTIONS.fiddle = $(dir.tmp)/EXPORTED_FUNCTIONS.fiddle
 #$(dir.dout)/sqlite3-node.mjs: $(sqlite3.mjs)
 #CLEAN_FILES += $(sqlite3.wasm)
 
+
+########################################################################
+# barebones=1 disables all "extraneous" stuff from sqlite3-wasm.c, the
+# goal being to create a WASM file with only the core APIs.
+ifeq (1,$(barebones))
+  wasm-bare-bones = 1
+  $(info ==============================================================)
+  $(info == This is a bare-bones build. It trades away features for)
+  $(info == a smaller .wasm file.)
+  $(info ==============================================================)
+else
+  wasm-bare-bones = 0
+endif
+# undefine barebones # relatively new gmake feature, not ubiquitous
+
+#
+# Only add wasmfs if wasmfs.enable=1 or we're running (dist)clean
+#
+ifneq (,$(filter wasmfs,$(MAKECMDGOALS)))
+wasmfs.enable ?= 1
+else
+# Unconditionally enable wasmfs for [dist]clean so that the wasmfs
+# sub-make can clean up.
+wasmfs.enable ?= $(MAKING_CLEAN)
+endif
+ifeq (1,$(wasmfs.enable))
+# wasmfs build disabled 2022-10-19 per /chat discussion.
+# OPFS-over-wasmfs was initially a stopgap measure and a convenient
+# point of comparison for the OPFS sqlite3_vfs's performance, but it
+# currently doubles our deliverables and build maintenance burden for
+# little benefit.
+#
+########################################################################
+# Some platforms do not support the WASMFS build. Raspberry Pi OS is
+# one of them (or was when that comment was initially written). As
+# such platforms are discovered, add their (uname -m) name to
+# PLATFORMS_WITH_NO_WASMFS to exclude the wasmfs build parts.
+PLATFORMS_WITH_NO_WASMFS = aarch64 # add any others here
+THIS_ARCH = $(shell /usr/bin/uname -m)
+ifneq (,$(filter $(THIS_ARCH),$(PLATFORMS_WITH_NO_WASMFS)))
+$(info This platform does not support the WASMFS build.)
+HAVE_WASMFS = 0
+else
+HAVE_WASMFS = 1
+endif
+endif
+# /wasmfs
+########################################################################
+
+
 # This block MUST come between the above definitions of
 # sqlite3-...js/mjs and the $(eval) calls below this block which use
 # SQLITE.CALL.C-PP.FILTER.
@@ -1139,39 +1153,6 @@ oz: clean
 # https://sqlite.org/fiddle application...
 include $(MAKEFILE.fiddle)
 
-# Only add wasmfs if wasmfs.enable=1 or we're running (dist)clean
-ifneq (,$(filter wasmfs,$(MAKECMDGOALS)))
-wasmfs.enable ?= 1
-else
-# Unconditionally enable wasmfs for [dist]clean so that the wasmfs
-# sub-make can clean up.
-wasmfs.enable ?= $(MAKING_CLEAN)
-endif
-ifeq (1,$(wasmfs.enable))
-# wasmfs build disabled 2022-10-19 per /chat discussion.
-# OPFS-over-wasmfs was initially a stopgap measure and a convenient
-# point of comparison for the OPFS sqlite3_vfs's performance, but it
-# currently doubles our deliverables and build maintenance burden for
-# little benefit.
-#
-########################################################################
-# Some platforms do not support the WASMFS build. Raspberry Pi OS is
-# one of them (or was when that comment was initially written). As
-# such platforms are discovered, add their (uname -m) name to
-# PLATFORMS_WITH_NO_WASMFS to exclude the wasmfs build parts.
-PLATFORMS_WITH_NO_WASMFS = aarch64 # add any others here
-THIS_ARCH = $(shell /usr/bin/uname -m)
-ifneq (,$(filter $(THIS_ARCH),$(PLATFORMS_WITH_NO_WASMFS)))
-$(info This platform does not support the WASMFS build.)
-HAVE_WASMFS = 0
-else
-HAVE_WASMFS = 1
-include wasmfs.make
-endif
-endif
-# /wasmfs
-########################################################################
-
 ########################################################################
 # Push files to public wasm-testing.sqlite.org server
 wasm-testing.include = *.js *.mjs *.html \
index 5072899ee6e3f2b118cb8371753344449569e8a7..0f70135a994505b4315791df73a5fd084dac6272 100644 (file)
@@ -96,6 +96,7 @@ struct BuildDef {
   const char *zCmppD;     /* Extra -D... flags for c-pp */
   const char *zEmcc;      /* Extra flags for emcc */
   const char *zEnv;       /* emcc -sENVIRONMENT=X flag */
+  const char *zIfCond;    /* "ifeq (...)" or similar */
   int flags;              /* Flags from LibModeFlags */
 };
 typedef struct BuildDef BuildDef;
@@ -146,6 +147,7 @@ const BuildDefs oBuildDefs = {
     .zCmppD      = 0,
     .zEmcc       = 0,
     .zEnv        = "web,worker",
+    .zIfCond     = 0,
     .flags       = CP_ALL
   },
 
@@ -156,7 +158,8 @@ const BuildDefs oBuildDefs = {
     .zCmppD      = 0,
     .zEmcc       = "-sMEMORY64=1",
     .zEnv        = 0,
-    .flags       = CP_ALL | F_64BIT // | F_NOT_IN_ALL
+    .zIfCond     = 0,
+    .flags       = CP_ALL | F_64BIT// | F_NOT_IN_ALL
   },
 
   .esm = {
@@ -166,6 +169,7 @@ const BuildDefs oBuildDefs = {
     .zCmppD      = "-Dtarget=es6-module",
     .zEmcc       = 0,
     .zEnv        = 0,
+    .zIfCond     = 0,
     .flags       = CP_JS | F_ESM
   },
 
@@ -176,6 +180,7 @@ const BuildDefs oBuildDefs = {
     .zCmppD      = "-Dtarget=es6-module",
     .zEmcc       = "-sMEMORY64=1",
     .zEnv        = 0,
+    .zIfCond     = 0,
     .flags       = CP_JS | F_ESM | F_64BIT // | F_NOT_IN_ALL
   },
 
@@ -191,16 +196,18 @@ const BuildDefs oBuildDefs = {
     .zCmppD      = "$(c-pp.D.esm) -Dtarget=es6-bundler-friendly",
     .zEmcc       = 0,
     .zEnv        = 0,
+    .zIfCond     = 0,
     .flags       = CP_JS | F_BUNDLER_FRIENDLY | F_ESM
   },
 
   .bundler64 = {
     .zEmo        = "📦",
-    .zBaseName   = "sqlite3",
+    .zBaseName   = "sqlite3-bundler-friendly",
     .zDotWasm    = 0,
     .zCmppD      = "$(c-pp.D.bundler)",
     .zEmcc       = "-sMEMORY64=1",
     .zEnv        = 0,
+    .zIfCond     = 0,
     .flags       = CP_JS | F_ESM | F_BUNDLER_FRIENDLY | F_64BIT
   },
 
@@ -218,6 +225,7 @@ const BuildDefs oBuildDefs = {
       Emscripten to generate code which confuses node: it cannot
       reliably determine whether the build is for a browser or for
       node.  */
+    .zIfCond     = 0,
     .flags       = CP_ALL | F_UNSUPPORTED | F_NODEJS
   },
 
@@ -229,6 +237,7 @@ const BuildDefs oBuildDefs = {
     .zCmppD      = "-Dtarget=node $(c-pp.D.bundler)",
     .zEmcc       = 0,
     .zEnv        = "node",
+    .zIfCond     = 0,
     .flags       = CP_ALL | F_UNSUPPORTED | F_NODEJS | F_64BIT
   },
 
@@ -240,6 +249,7 @@ const BuildDefs oBuildDefs = {
     .zCmppD      = "$(c-pp.D.bundler)",
     .zEmcc       = "-sEXPORT_ES6 -sUSE_ES6_IMPORT_META",
     .zEnv        = 0,
+    .zIfCond     = "ifeq (1,$(HAVE_WASMFS))",
     .flags       = CP_ALL | F_UNSUPPORTED | F_WASMFS
   }
 };
@@ -275,6 +285,41 @@ static void mk_prologue(void){
     ps("endif");
   }
 
+  ps(zBanner
+     "emo.disk = 💾\n"
+     "emo.fire = 🔥\n"
+     "emo.done = 🏆\n" /*🏁*/
+     "emo.bug = 🐞\n"
+     "emo.megaphone = 📣\n"
+     "emo.mute = 🔇\n"
+     "emo.tool = 🔨\n"
+     "emo.compile = ⏳\n"
+     "emo.info =\n"
+     "emo.stop =🛑\n"
+     "emo.strip =🪚\n" /*🔪*/
+     "emo.garbage =🗑\n"
+  );
+
+  ps(zBanner
+     /** $1 = build name
+         $2 = Input file(s): cat $(2) | c-pp ...
+         $3 = Output file: c-pp -o $(3)
+         $4 = optional c-pp -D... flags */
+     "define b.do.c-pp\n"
+     "$(3): $$(MAKEFILE_LIST) $$(bin.c-pp) $(2)\n"
+     "\t@echo '$$(logtag.$(1)) $$(emo.disk) $(4)'; mkdir -p $$(dir $$@)\n"
+     "\t@cat $(2) | $$(bin.c-pp) -o $(3) $(4) $$(SQLITE.CALL.C-PP.FILTER.global) || exit $$$$?\n"
+     "\nCLEAN_FILES += $(2)\n"
+     "endef\n"
+  );
+
+  ps(zBanner
+     /** $1 = build name */
+     "b.do.wasm-strip = "
+     "echo '$(logtag.$(1)) $(emo.strip) wasm-strip $(out.$(1).wasm)'; "
+     "$(bin.wasm-strip) $(out.$(1).wasm)\n"
+  );
+
   ps(zBanner
      "# Inputs for the sqlite3-api.js family.\n"
      "#\n"
@@ -324,7 +369,7 @@ static void mk_prologue(void){
      "# support -e SCRIPT.\n"
      "$(sqlite3-license-version.js): $(MKDIR.bld) $(sqlite3.h) "
      "$(dir.api)/sqlite3-license-version-header.js $(MAKEFILE)\n"
-     "\t@echo 'Making $@...'; { \\\n"
+     "\t@echo '$(emo.disk) $@'; { \\\n"
      "\t\tcat $(dir.api)/sqlite3-license-version-header.js;  \\\n"
      "\t\techo '/*'; \\\n"
      "\t\techo '** This code was built from sqlite3 version...'; \\\n"
@@ -341,7 +386,7 @@ static void mk_prologue(void){
      "# $(sqlite3-api-build-version.js) injects the build version info into\n"
      "# the bundle in JSON form.\n"
      "$(sqlite3-api-build-version.js): $(MKDIR.bld) $(bin.version-info) $(MAKEFILE)\n"
-     "\t@echo 'Making $@...'; { \\\n"
+     "\t@echo '$(emo.disk) $@'; { \\\n"
      "\t\techo 'globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){'; \\\n"
      "\t\techo -n '  sqlite3.version = '; \\\n"
      "\t\t$(bin.version-info) --json; \\\n"
@@ -354,7 +399,7 @@ static void mk_prologue(void){
      "# extern-post-js* and extern-pre-js* are files for use with\n"
      "# Emscripten's --extern-pre-js and --extern-post-js flags.\n"
      "extern-pre-js.js = $(dir.api)/extern-pre-js.js\n"
-     "extern-post-js.js.in = $(dir.api)/extern-post-js.c-pp.js\n"
+     "extern-post-js.in.js = $(dir.api)/extern-post-js.c-pp.js\n"
      "# Emscripten flags for --[extern-][pre|post]-js=... for the\n"
      "# various builds.\n"
      "# pre-post-jses.*.deps = lists of dependencies for the\n"
@@ -363,30 +408,8 @@ static void mk_prologue(void){
      "$(extern-pre-js.js) $(sqlite3-license-version.js)"
   );
 
-  pf(zBanner
-     "define emcc.do.build\n"
-     /* $1 = build name */
-     "$(bin.emcc) -o $@ $(emcc_opt_full) $(emcc.flags) "
-     "$(emcc.jsflags) -sENVIRONMENT=$(emcc.environment.$(1)) "
-     "\t\t$(pre-post.$(1).flags) "
-     "\t\t$(emcc.flags.$(1)) "
-     "\t\t$(cflags.common) $(cflags.$(1)) "
-     "\t\t$(SQLITE_OPT) "
-     "\t\t$(cflags.wasm_extra_init) $(sqlite3-wasm.cfiles)\n"
-     "endef\n"
-  );
-
   ps(zBanner
-     "emo.disk = 💾\n"
-     "emo.fire = 🔥\n"
-     "emo.done = 🏆\n" /*🏁*/
-     "emo.bug = 🐞\n"
-     "emo.megaphone = 📣\n"
-     "emo.mute = 🔇\n"
-     "emo.tool = 🔨\n"
-  );
-  ps(
-    "emcc.loud ?= 1\n"
+    "emcc.loud ?= 0\n"
     "ifeq (1,$(emcc.loud))\n"
     "$(info $(emo.megaphone) Emitting loud build info."
     " Pass emcc.loud=0 to disable it.)\n"
@@ -398,6 +421,38 @@ static void mk_prologue(void){
     "endif\n"
   );
 
+  ps(zBanner
+     "# --post-js and --pre-js are emcc flags we use to append/prepend JS to\n"
+     "# the generated emscripten module file. These rules set up the core\n"
+     "# pre/post files for use by the various builds. --pre-js is used to\n"
+     "# inject code which needs to run as part of the pre-WASM-load phase.\n"
+     "# --post-js injects code which runs after the WASM module is loaded\n"
+     "# and includes the entirety of the library plus some\n"
+     "# Emscripten-specific post-bootstrapping code.\n"
+     "pre-js.in.js = $(dir.api)/pre-js.c-pp.js\n"
+     "post-js.in.js = $(dir.tmp)/post-js.c-pp.js\n"
+     "post-jses.js = $(dir.api)/post-js-header.js $(sqlite3-api.js.in) $(dir.api)/post-js-footer.js\n"
+     "$(post-js.in.js): $(MKDIR.bld) $(post-jses.js) $(MAKEFILE)\n"
+     " @echo '$(emo.disk) $@'\n"
+     " @for i in $(post-jses.js); do \\n"
+     "         echo \"/* BEGIN FILE: $$i */\"; \\n"
+     "         cat $$i; \\n"
+     "         echo \"/* END FILE: $$i */\"; \\n"
+     " done > $@\n"
+  );
+  pf(zBanner
+     "define b.do.emcc\n"
+     /* $1 = build name */
+     "$(bin.emcc) -o $@ $(emcc_opt_full) $(emcc.flags) "
+     "$(emcc.jsflags) -sENVIRONMENT=$(emcc.environment.$(1)) "
+     "\t\t$(pre-post.$(1).flags) "
+     "\t\t$(emcc.flags.$(1)) "
+     "\t\t$(cflags.common) $(cflags.$(1)) "
+     "\t\t$(SQLITE_OPT) "
+     "\t\t$(cflags.wasm_extra_init) $(sqlite3-wasm.cfiles)\n"
+     "endef\n"
+  );
+
   {
     /* SQLITE.CALL.WASM-OPT = shell code to run $(1) (source wasm file
     ** name) through $(bin.wasm-opt) */
@@ -469,7 +524,7 @@ static void mk_prologue(void){
         "\t\tls -l $(1); \\\n"
 #endif
         "\telse \\\n"
-        "\t\techo '$(2) 🔥 ignoring wasm-opt failure'; \\\n"
+        "\t\techo '$(2) $(emo.fire) ignoring wasm-opt failure'; \\\n"
         "\tfi\n",
         zOptFlags
       );
@@ -489,7 +544,6 @@ static void mk_pre_post(char const *zBuildName,
 /* Very common printf() args combo. */
 
   pf("%s# Begin --pre/--post flags for %s\n", zBanner, zBuildName);
-  pf("c-pp.D.%s = %s\n", zBuildName, pB->zCmppD ? pB->zCmppD : "");
 
   ps("\n# --pre-js=...");
   pf("pre-js.%s.js = $(dir.tmp)/pre-js.%s.js\n"
@@ -501,8 +555,9 @@ static void mk_pre_post(char const *zBuildName,
      zBuildName);
 
   if( 0==WASM_CUSTOM_INSTANTIATE ){
-    pf("\tcat $(pre-js.js.in) | $(bin.c-pp) -o $@ $(c-pp.D.%s)\n",
-       zBuildName);
+    pf("\t@echo '$(logtag.%s) $(emo.disk) $(c-pp.D.%s)'; "
+       "cat $(pre-js.in.js) | $(bin.c-pp) -o $@ $(c-pp.D.%s)\n",
+       zBuildName, zBuildName, zBuildName);
   }else{
 #if 0
     fixme;
@@ -511,14 +566,15 @@ static void mk_pre_post(char const *zBuildName,
     pf("pre-js.%s.js.intermediary = "
        "$(dir.tmp)/pre-js.%s.intermediary.js\n",
        zBuildName, zBuildName);
-    pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(pre-js.js.in),"
+    pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(pre-js.in.js),"
        "$(pre-js.%s.js.intermediary),"
        C_PP_D_CUSTOM_INSTANTIATE "$(c-pp.D.%s)))\n",
        zBuildName, zBuildName);
     pf("$(pre-js.%s.js): $(pre-js.%s.js.intermediary)\n",
        zBuildName, zBuildName);
     pf("\tcp $(pre-js.%s.js.intermediary) $@\n", zBuildName);
-    pf("\t@echo 'sIMS.wasmFilename = \"%s\";' >> $@\n", zWasmOut)
+    pf("\t@echo 'sIMS.wasmFilename = \"$(out.%s.wasm)\";' >> $@\n",
+       zBuildName)
       /* see api/pre-js.c-pp.js:Module.instantiateModule() */;
 #endif
   }
@@ -531,17 +587,23 @@ static void mk_pre_post(char const *zBuildName,
      "$(sqlite3-api.%s.js) "
      "$(dir.api)/post-js-footer.js\n",
      zBuildName, zBuildName);
-  pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(post-jses.%s),"
-     "$(post-js.%s.js),$(c-pp.D.%s)))\n",
-     zBuildName, zBuildName, zBuildName);
+  pf("$(eval $(call b.do.c-pp,"
+     "%s,"
+     "$(post-jses.%s),"
+     "$(post-js.%s.js),"
+     "$(c-pp.D.%s)"
+     "))\n",
+     zBuildName, zBuildName, zBuildName, zBuildName);
 
   ps("\n# --extern-post-js=...");
   pf("extern-post-js.%s.js = $(dir.tmp)/extern-post-js.%s.js\n",
      zBuildName, zBuildName);
-  pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,$(extern-post-js.js.in),"
+  pf("$(eval $(call b.do.c-pp,"
+     "%s,"
+     "$(extern-post-js.in.js),"
      "$(extern-post-js.%s.js),"
      C_PP_D_CUSTOM_INSTANTIATE "$(c-pp.D.%s)))\n",
-     zBuildName, zBuildName);
+     zBuildName, zBuildName, zBuildName);
 
   ps("\n# --pre/post misc...");
   /* Combined flags for use with emcc... */
@@ -589,7 +651,7 @@ static void mk_fiddle(void){
        "$(pre-post-fiddle-module-vanilla.flags) $(fiddle.cses)\n",
        zTail);
     ps("\t@chmod -x $(basename $@).wasm");
-    ps("\t@$(maybe-wasm-strip) $(basename $@).wasm");
+    pf("\t@$(call b.do.wasm-strip,%s)\n", zBuildName);
     ps("\t@$(call SQLITE.strip-emcc-js-cruft,NAME_GOES_HERE)");
     pf("\t@cp -p $(SOAP.js) $(dir $@)\n");
     if( 1==i ){/*fiddle.debug*/
@@ -623,7 +685,6 @@ static void mk_fiddle(void){
 ** Emits makefile code for one build of the library.
 */
 void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
-  const char * zWasmOut = "$(basename $@).wasm"
     /* The various targets named X.js or X.mjs also generate X.wasm,
     ** and we need that part of the name to perform some
     ** post-processing after Emscripten generates X.wasm. */;
@@ -641,16 +702,21 @@ void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
      pB->zCmppD ? pB->zCmppD : "", zBaseName);
 
   pf("logtag.%s = [%s %s $@]:\n", zBuildName, pB->zEmo, zBuildName);
+  if( pB->zIfCond ){
+    pf("%s\n", pB->zIfCond );
+  }
+  pf("$(info $(logtag.%s) Setting up target b-%s)\n",
+     zBuildName, zBuildName );
+
   pf("dir.dout.%s ?= $(dir.dout)/%s\n", zBuildName, zBuildName);
   pf("out.%s.base = $(dir.dout.%s)/%s\n",
      zBuildName, zBuildName, zBaseName);
   pf("out.%s.js = $(dir.dout.%s)/%s%s\n",
      zBuildName, zBuildName, zBaseName, zJsExt);
   pf("out.%s.wasm = $(dir.dout.%s)/%s.wasm\n",
+     //"$(basename $@).wasm"
      zBuildName, zBuildName, zBaseName);
-  pf("$(info $(logtag.%s) Setting up build. "
-     "Use the 'b-%s' target to build just this.)\n",
-     zBuildName, zBuildName );
+  pf("c-pp.D.%s = %s\n", zBuildName, pB->zCmppD ? pB->zCmppD : "");
   pf("emcc.environment.%s = %s\n", zBuildName,
      pB->zEnv ? pB->zEnv : oBuildDefs.vanilla.zEnv);
   pf("emcc.flags.%s = %s\n", zBuildName, pB->zEmcc ? pB->zEmcc : "");
@@ -664,7 +730,7 @@ void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
     pf("c-pp.D.%s = %s\n", zBuildName, pB->zCmppD ? pB->zCmppD: "" );
 
     pf("$(sqlite3-api.%s.c-pp.js): $(sqlite3-api.jses)\n"
-       "\t@echo '$(logtag.%s) Making $@ ...'; \\\n"
+       "\t@echo '$(logtag.%s) $(emo.disk)'; \\\n"
        "\tmkdir -p $(dir.dout.%s); \\\n"
        "\tfor i in $(sqlite3-api.jses); do \\\n"
        "\t\techo \"/* BEGIN FILE: $$i */\"; \\\n"
@@ -673,14 +739,16 @@ void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
        "\tdone > $@\n",
        zBuildName, zBuildName, zBuildName);
 
-    pf("$(sqlite3-api.%s.js): $(sqlite3-api.%s.c-pp.js)\n",
-       zBuildName, zBuildName);
-    pf("$(eval $(call SQLITE.CALL.C-PP.FILTER,"
-       "$(sqlite3-api.%s.c-pp.js), " /* $1 = src(es) */
-       "$(sqlite3-api.%s.js), "      /* $2 = tgt */
-       "$(c-pp.D.%s)"                /* $3 = c-pp -Dx=Y flags */
+    pf("$(sqlite3-api.%s.js): $(sqlite3-api.%s.c-pp.js)\n"
+       "$(eval $(call b.do.c-pp,"
+       "%s,"
+       "$(sqlite3-api.%s.c-pp.js),"
+       "$(sqlite3-api.%s.js),"
+       "$(c-pp.D.%s)"
        "))\n",
-       zBuildName, zBuildName, zBuildName);
+       zBuildName, zBuildName,
+       zBuildName, zBuildName,
+       zBuildName, zBuildName);
   }
 
   mk_pre_post(zBuildName, pB);
@@ -698,7 +766,7 @@ void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
        "\n",
        zBuildName, zBuildName, zBuildName);
 
-    pf("\t@echo '$(logtag.%s) building ...'\n"
+    pf("\t@echo '$(logtag.%s) $(emo.compile) building $@ ...'\n"
        "\t@mkdir -p $(dir $@);\n",
        zBuildName);
 
@@ -706,7 +774,7 @@ void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
       pf("\t@echo '$(logtag.%s) $(emo.fire)$(emo.fire)$(emo.fire): "
          "unsupported build. Use at your own risk.'\n", zBuildName);
     }
-    pf("\t$(emcc.squelch)$(call emcc.do.build,%s)\n", zBuildName);
+    pf("\t$(emcc.squelch)$(call b.do.emcc,%s)\n", zBuildName);
 
     { /* Post-compilation transformations and copying to
          $(dir.dout)... */
@@ -721,11 +789,12 @@ void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
         );
       }
 
-      pf("\t@chmod -x %s\n", zWasmOut
+      pf("\t@chmod -x $(out.%s.wasm)\n", zBuildName
          /* althttpd will automatically try to execute wasm files
             if they have the +x bit set. Why that bit is set
             at all is a mystery. */);
-      pf("\t@$(maybe-wasm-strip) %s\n", zWasmOut);
+      pf("\t@$(call b.do.wasm-strip,%s)\n", zBuildName);
+
       pf("\t@$(call SQLITE.CALL.WASM-OPT,%s,$(logtag.%s))\n",
          zBuildName, zBuildName);
       pf("\t@$(call SQLITE.strip-emcc-js-cruft,$(logtag.%s))\n", zBuildName);
@@ -737,9 +806,10 @@ void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
         );
       }
       if( CP_WASM & pB->flags ){
-        pf("\t@cp -f %s $(dir.dout)/. || exit; \\\n"
-           "\techo '$(logtag.%s) $(emo.disk) $(dir.dout)/$(notdir %s)'\n",
-           zWasmOut, zBuildName, zWasmOut);
+        pf("\t@cp -f $(out.%s.wasm) $(dir.dout)/. || exit; \\\n"
+           "\techo '[%s %s $(out.%s.wasm)] $(emo.disk) "
+           "$(dir.dout)/$(notdir $(out.%s.wasm))'\n",
+           zBuildName, pB->zEmo, zBuildName, zBuildName, zBuildName);
       }
       /*
       ** $(bin.emcc) will write out $@ and will create a like-named
@@ -754,7 +824,7 @@ void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
       if( pB->zDotWasm && (CP_JS & pB->flags) ){
         pf("\t@echo '$(logtag.%s) $(emo.disk) "
            "s/\"%s.wasm\"/\"%s.wasm\"/g "
-           "$(dir.dout)/$(notdir $@)'; \\\n"
+           "in $(dir.dout)/$(notdir $@)'; \\\n"
            "sed "
            "-e 's/\"%s.wasm\"/\"%s.wasm\"/g' "
            "-e \"s/'%s.wasm'/'%s.wasm'/g\" "
@@ -779,15 +849,34 @@ void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
   pf("\t@echo '$(logtag.%s) $(emo.done)'\n", zBuildName);
 
   pf("\n%dbit: $(out.%s.js)\n"
-     "b-%s: $(out.%s.js)\n",
-     (F_64BIT & pB->flags) ? 64 : 32,
+     "$(out.%s.wasm): $(out.%s.js)\n"
+     "b-%s: $(out.%s.js) $(out.%s.wasm)\n",
+     (F_64BIT & pB->flags) ? 64 : 32, zBuildName,
+     zBuildName, zBuildName,
      zBuildName, zBuildName, zBuildName);
 
+  if( CP_JS & pB->flags ){
+    pf("$(dir.dout)/%s%s: $(out.%s.js)\n",
+       pB->zBaseName, zJsExt, zBuildName
+    );
+  }
+  if( CP_WASM & pB->flags ){
+    pf("$(dir.dout)/%s.wasm: $(out.%s.wasm)\n",
+       pB->zBaseName, zBuildName
+    );
+  }
+
   if( 0==(F_NOT_IN_ALL & pB->flags)
       && 0==(F_UNSUPPORTED & pB->flags) ){
     pf("all: $(out.%s.js)\n", zBuildName);
   }
 
+  if( pB->zIfCond ){
+    pf("else\n"
+       "$(info $(logtag.%s) $(emo.stop) disabled by condition: %s)\n"
+       "endif\n",
+       zBuildName, pB->zIfCond);
+  }
   pf("# End build [%s]%s", zBuildName, zBanner);
 }
 
@@ -799,6 +888,18 @@ int main(void){
 #define E(N) mk_lib_mode(# N, &oBuildDefs.N);
   BuildDefs_map(E)
 #undef E
+  pf(zBanner
+     "$(dir.dout)/sqlite3.js: $(out.vanilla.js)\n"
+     "$(dir.dout)/sqlite3.mjs: $(out.esm.js)\n"
+     "$(dir.dout)/sqlite3.wasm: $(out.vanilla.wasm)\n"
+     "$(dir.dout)/sqlite3-64bit.js: $(out.vanilla64.js)\n"
+     "$(dir.dout)/sqlite3-64bit.mjs: $(out.esm64.js)\n"
+     "$(dir.dout)/sqlite3-64bit.wasm: $(out.vanilla64.wasm)\n"
+     "b-vanilla: $(dir.dout)/sqlite3.wasm\n"
+     "b-vanilla64: $(dir.dout)/sqlite3-64bit.wasm\n"
+     "b-esm: $(dir.dout)/sqlite3.mjs\n"
+     "b-esm64: $(dir.dout)/sqlite3-64bit.mjs\n"
+  );
 #if 0
   mk_fiddle();
   mk_pre_post(0, "speedtest1","vanilla", 0, "speedtest1.wasm");
index 32452d4742fe63a1e1bb2891bac798fdbbf7b92d..d9f85f91e840f6b884b7f18ad8220d8f024395c3 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Cosmetic\swasm\sbuild\stweaks.\sFixed\swasm-opt\suse,\sbroken\sby\sthis\sbranch's\srefactoring.
-D 2025-09-23T10:46:17.318
+C Get\smost\sof\sthe\swasm\sbuild\s(re)working\sand\smuch\sprettier.
+D 2025-09-23T13:49:44.420
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -578,7 +578,7 @@ F ext/session/sqlite3session.c 9cd47bfefb23c114b7a5d9ee5822d941398902f30516bf0dd
 F ext/session/sqlite3session.h 7404723606074fcb2afdc6b72c206072cdb2b7d8ba097ca1559174a80bc26f7a
 F ext/session/test_session.c 8766b5973a6323934cb51248f621c3dc87ad2a98f023c3cc280d79e7d78d36fb
 F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c
-F ext/wasm/GNUmakefile 1732bc9928eecf48047d8cbc9361145de993aa70b3770a387a55271c67001edb
+F ext/wasm/GNUmakefile 7bd5b216a66af20f18515bb3668330e3834bf2dd562c26c40775bd0d95610680
 F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a
 F ext/wasm/README.md 66ace67ae98a45e4116f2ca5425b716887bcee4d64febee804ff6398e1ae9ec7
 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff
@@ -639,7 +639,7 @@ F ext/wasm/index-dist.html 56132399702b15d70c474c3f1952541e25cb0922942868f70daf1
 F ext/wasm/index.html bcaa00eca521b372a6a62c7e7b17a870b0fcdf3e418a5921df1fd61e5344080d
 F ext/wasm/jaccwabyt/jaccwabyt.js bbac67bc7a79dca34afe6215fd16b27768d84e22273507206f888c117e2ede7d
 F ext/wasm/jaccwabyt/jaccwabyt.md 167fc0b624c9bc2c477846e336de9403842d81b1a24fc4d3b24317cb9eba734f
-F ext/wasm/mkwasmbuilds.c 1eb6ab3370a388b17ee4d88bee61d2a25fea400cd2b3638fff75a02fed6208a1
+F ext/wasm/mkwasmbuilds.c d90795491b85a79d63d6087a6725fc99623eb5ac56510998001b7687ec1c110c
 F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337
 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96
 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63
@@ -2175,8 +2175,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 913af3dd6a8da577ef19b0d82c8afec0c626d7fa5fddbdf418d2eb16c3050ab1
-R 485ed5081b5443d0e12ca88c1d18d423
+P 4d7eff2afbcf023291bc1133c4413d1ea44f4096bb515e4bcd40bc8fc8d2a591
+R e8886245b28a331e670aa538541aa363
 U stephan
-Z 1d0c8daab3af2d36aff745c502e348b6
+Z 82e89b29e3b7887e8b71ff36239b271d
 # Remove this line to create a well-formed Fossil manifest.
index 1e8268275ecb2cf0b7eac387e19154808316366a..e4191b86643eac6b355fc56a07484115e0a284e2 100644 (file)
@@ -1 +1 @@
-4d7eff2afbcf023291bc1133c4413d1ea44f4096bb515e4bcd40bc8fc8d2a591
+a5a7890c75003a637a227b700dc342f4f4a24bd368b216bdb168b4ddfbe8f015