]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Move the static makefile code from mkwamsbuilds.c into the makefile. Move util.make...
authorstephan <stephan@noemail.net>
Wed, 24 Sep 2025 23:07:45 +0000 (23:07 +0000)
committerstephan <stephan@noemail.net>
Wed, 24 Sep 2025 23:07:45 +0000 (23:07 +0000)
FossilOrigin-Name: 18beeb26bfa48f806866e0e330024535adabcf668071abc4b6251eb39de2701d

ext/wasm/GNUmakefile
ext/wasm/c-pp.c
ext/wasm/index.html
ext/wasm/mkwasmbuilds.c
ext/wasm/util.make [deleted file]
manifest
manifest.uuid

index 536d6032d0df61fb6162b59fdb706a0ec85136ad..b88a675f0c98847b9bddfc877c18a42201fd3d0b 100644 (file)
 #      by the target name. Rebuild is necessary for all components to get
 #      the desired optimization level.
 #
-#  quick, q = do just build the essentials for testing
-#      (sqlite3.js/wasm, tester1) for faster development-mode
-#      turnaround.
-#
 #  dist = create end user deliverables. Add dist.build=oX to build
 #      with a specific optimization level, where oX is one of the
 #      above-listed o? or qo? target names.
@@ -37,7 +33,6 @@
 # - InfoZip for 'dist' zip file
 ########################################################################
 default: all
-#default: quick
 MAKEFILE = $(lastword $(MAKEFILE_LIST))
 MAKEFILE.fiddle = fiddle.make
 CLEAN_FILES =
@@ -46,20 +41,65 @@ MAKING_CLEAN = $(if $(filter %clean,$(MAKECMDGOALS)),1,0)
 .PHONY: clean distclean
 clean:
        -rm -f $(CLEAN_FILES)
-       -rm -fr $(dir.fiddle-debug) $(dir.dout) $(dir.dout) $(dir.tmp)
+       -rm -fr $(dir.fiddle-debug) $(dir.dout) $(dir.tmp)
 
 distclean: clean
        -rm -f $(DISTCLEAN_FILES)
 
 more: all
-include util.make
 
-########################################################################
+# dir.top = the top dir of the canonical build tree, where
+# sqlite3.[ch] live.
+dir.top = ../..
+# Maintenance reminder: some Emscripten flags require absolute paths
+# but we want relative paths for most stuff simply to reduce
+# noise. The $(abspath...) GNU make function can transform relative
+# paths to absolute.
+dir.wasm = $(patsubst %/,%,$(dir $(MAKEFILE)))
+dir.api = api
+dir.jacc = jaccwabyt
+dir.common = common
+dir.fiddle = fiddle
+dir.fiddle-debug = fiddle-debug
+dir.tool = $(dir.top)/tool
+# dir.dout = output dir for deliverables
+dir.dout = $(dir.wasm)/jswasm
+# dir.tmp = output dir for intermediary build files, as opposed to
+# end-user deliverables.
+dir.tmp = $(dir.wasm)/bld
+dir.wasmfs = $(dir.dout)
+
+CLEAN_FILES += *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~ $(dir.fiddle)/*~ \
+
+#
+# Emoji for log messages.
+#
+emo.bug       = ๐Ÿž
+emo.compile   = โณ
+emo.roadblock = ๐Ÿšง
+emo.disk      = ๐Ÿ’พ
+emo.done      = โœ…
+emo.fire      = ๐Ÿ”ฅ
+emo.folder    = ๐Ÿ“
+emo.garbage   = ๐Ÿ—‘
+emo.lock      = ๐Ÿ”’
+emo.magic     = ๐Ÿง™
+emo.megaphone = ๐Ÿ“ฃ
+emo.mute      = ๐Ÿ”‡
+emo.stop      = ๐Ÿ›‘
+emo.strip     = ๐Ÿ’ˆ
+emo.test      = ๐Ÿงช
+emo.tool      = ๐Ÿ”จ
+emo.wasm-opt  = ๐Ÿงผ
+# ๐Ÿ‘ท๐Ÿช„๐Ÿงฎ๐Ÿงซ๐Ÿงฝ๐Ÿฟโ›ฝ๐Ÿšง๐ŸŽฑ๐Ÿชš๐Ÿ†๐Ÿงผ
+
+#
 # Special-case builds for which we require certain pre-conditions
 # which, if not met, may cause warnings or fatal errors in the build.
 # This also affects the default optimization level flags.  The fiddle
 # targets are in this list because they are used for generating
 # sqlite.org/fiddle.
+#
 OPTIMIZED_TARGETS = dist snapshot fiddle fiddle.debug
 
 ifeq (1,$(MAKING_CLEAN))
@@ -71,7 +111,7 @@ ifeq (1,$(MAKING_CLEAN))
 else
   # Include config.make and perform some bootstrapping...
   ifeq (,$(wildcard ./config.make))
-    $(error Missing config.make (gets generated by the configure script if the EMSDK is found))
+    $(error Missing config.make. It gets generated by the configure script if the EMSDK is found)
   endif
   include ./config.make
   ifeq (,$(bin.bash))
@@ -83,22 +123,24 @@ else
   emcc.version = $(shell $(bin.emcc) --version | sed -n 1p | sed -e 's/^.* \([3-9][^ ]*\) .*$$/\1/;')
   $(info using emcc version [$(emcc.version)])
   ifeq (,$(bin.wasm-strip))
-    ####################################################################
+    #
     # We need wasm-strip for release builds (see below for why) but
     # not strictly for non-release builds.
-    $(info WARNING: *******************************************************************)
-    $(info WARNING: Builds using -Oz will minify WASM-exported names, breaking)
-    $(info WARNING:  _All The Things_. The workaround for that is to build)
-    $(info WARNING: with -g3 (which explodes the file size) and then strip the debug)
-    $(info WARNING: info after compilation, using wasm-strip, to shrink the wasm file.)
-    $(info WARNING: wasm-strip was not found in the PATH so we cannot strip those.)
-    $(info WARNING: If this build uses any optimization level higher than -O1 then)
-    $(info WARNING: the ***resulting JS code WILL NOT BE USABLE***.)
-    $(info WARNING: wasm-strip is part of the wabt package:)
-    $(info WARNING:    https://github.com/WebAssembly/wabt)
-    $(info WARNING: on Ubuntu-like systems it can be installed with:)
-    $(info WARNING:    sudo apt install wabt)
-    $(info WARNING: *******************************************************************)
+    #
+    achtung = $(emo.fire)WARNING
+    $(info $(achtung): *******************************************************************)
+    $(info $(achtung): Builds using -Oz will minify WASM-exported names, breaking)
+    $(info $(achtung):  _All The Things_. The workaround for that is to build)
+    $(info $(achtung): with -g3 (which explodes the file size) and then strip the debug)
+    $(info $(achtung): info after compilation, using wasm-strip, to shrink the wasm file.)
+    $(info $(achtung): wasm-strip was not found in the PATH so we cannot strip those.)
+    $(info $(achtung): If this build uses any optimization level higher than -O1 then)
+    $(info $(achtung): the ***resulting JS code WILL NOT BE USABLE***.)
+    $(info $(achtung): wasm-strip is part of the wabt package:)
+    $(info $(achtung):    https://github.com/WebAssembly/wabt)
+    $(info $(achtung): on Ubuntu-like systems it can be installed with:)
+    $(info $(achtung):    sudo apt install wabt)
+    $(info $(achtung): *******************************************************************)
     ifneq (,$(filter $(OPTIMIZED_TARGETS),$(MAKECMDGOALS)))
       $(error Cannot make release-quality binary because wasm-strip is not available.)
     endif
@@ -112,68 +154,125 @@ else
   endif
 endif
 # ^^^ end of are-we-MAKING_CLEAN
-maybe-wasm-strip = $(bin.wasm-strip)
 
-########################################################################
-# JS_BUILD_NAMES exists for documentation purposes only. It enumerates
-# the core build styles:
 #
-# - sqlite3 = canonical library build
+# Common vars and $(call)able utilities for the SQLite WASM build.
 #
-# - sqlite3-wasmfs = WASMFS-capable library build
+# The "b." prefix on some APIs is for "build". It was initially used
+# only for build-specific features. That's no longer the case, but the
+# naming convention has stuck.
 #
-JS_BUILD_NAMES = sqlite3 sqlite3-wasmfs
 
-########################################################################
-# JS_BUILD_MODES exists for documentation purposes only. It enumerates
-# the various "flavors" of build, each of which requires slight
-# customization of the output:
+loud ?= 0
+ifeq (1,$(loud))
+  $(info $(emo.megaphone) Emitting loud build info. Pass loud=0 to disable it.)
+  b.cmd@ =
+  loud.if = 1
+else
+  $(info $(emo.mute) Eliding loud build info. Pass loud=1 to enable it.)
+  b.cmd@ = @
+  loud.if =
+endif
+
+#
+# logtag.X value for log context labeling. logtag.OTHERX can be
+# assigned to customize it for a given X. This tag is used by the
+# b.call.X and b.eval.X for logging.
 #
-# - vanilla = plain-vanilla JS for use in browsers. This is the
-#   canonical build mode.
+logtag.@ = [$@]
+logtag.filter = [$(emo.disk) $@]
+logtag.test = [$(emo.test) $@]
+
 #
-# - esm = ES6 module, a.k.a. ESM, for use in browsers.
+# $(call b.echo,LOGTAG,msg)
+#
+b.echo = echo $(logtag.$(1)) $(2)
+
 #
-# - bundler-friendly = esm slightly tweaked for "bundler"
-#   tools. Bundlers are invariably based on node.js, so these builds
-#   are intended to be read at build-time by node.js but with a final
-#   target of browsers. All bundler-friendly builds are UNTESTED.
-#   They are provided primarily for use by the community-supported
-#   subproject which hosts npm builds of sqlite3, and they are
-#   actively supported only to the extent needed by that subproject.
+# $(call b.call.mkdir@)
 #
-# - node = for use by node.js for node.js, as opposed to by node.js on
-#   behalf of browser-side code (use bundler-friendly for that). Note
-#   that persistent storage (OPFS) is not available in these builds.
-#   These builds are UNTESTED and UNSUPPORTED!
+# $1 = optional LOGTAG
 #
-JS_BUILD_MODES = vanilla esm bunder-friendly node
+b.call.mkdir@ = if [ ! -d $(dir $@) ]; then \
+  echo '[$(emo.folder)+] $(if $(1),$(logtag.$(1)),[$(dir $@)])'; \
+  mkdir -p $(dir $@) || exit; fi
 
-########################################################################
-# dir.top = the top dir of the canonical build tree, where
-# sqlite3.[ch] live.
-dir.top = ../..
-# Maintenance reminder: some Emscripten flags require absolute paths
-# but we want relative paths for most stuff simply to reduce
-# noise. The $(abspath...) GNU make function can transform relative
-# paths to absolute.
-dir.wasm = $(patsubst %/,%,$(dir $(MAKEFILE)))
-dir.api = api
-dir.jacc = jaccwabyt
-dir.common = common
-dir.fiddle = fiddle
-dir.fiddle-debug = fiddle-debug
-dir.tool = $(dir.top)/tool
-# dir.dout = output dir for deliverables
-dir.dout = $(dir.wasm)/jswasm
-# dir.tmp = output dir for intermediary build files, as opposed to
-# end-user deliverables.
-dir.tmp = $(dir.wasm)/bld
-dir.wasmfs = $(dir.dout)
+#
+# $(call b.call.cp,@,src,dest)
+#
+# $1 = build name, $2 = src file(s). $3 = dest dir
+b.call.cp = $(call b.call.mkdir@); \
+  echo '$(logtag.$(1)) $(emo.disk) $(2) ==> $3'; \
+  cp -p $(2) $(3) || exit
 
-CLEAN_FILES += *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~ $(dir.fiddle)/*~ \
+#
+# $(eval $(call b.eval.c-pp,@,src,dest,-Dx=y...))
+#
+# $1 = build name
+# $2 = Input file(s): cat $(2) | $(bin.c-pp) ...
+# $3 = Output file: $(bin.c-pp) -o $(3)
+# $4 = optional $(bin.c-pp) -D... flags */
+#
+define b.eval.c-pp
+$(3): $$(MAKEFILE_LIST) $$(bin.c-pp) $(2)
+       @$$(call b.call.mkdir@); \
+       $$(call b.echo,$(1),$$(emo.disk)$$(emo.lock) $$(bin.c-pp) $(4) $(if $(loud.if),$(2))); \
+       rm -f $(3); \
+       $$(bin.c-pp) -o $(3) $(4) $(2) || exit; \
+       chmod -w $(3)
+CLEAN_FILES += $(3)
+endef
 
-########################################################################
+#
+# $(call b.call.strip-emcc-js-cruft)
+#
+# Our JS code installs bindings of each sqlite3_...() WASM export. The
+# generated Emscripten JS file does the same using its own framework,
+# but we don't use those results and can speed up lib init, and reduce
+# memory cost a bit, by stripping them out. Emscripten-side changes
+# can "break" this, causing this to be a no-op, but the worst that can
+# happen in that case is that it doesn't actually strip anything,
+# leading to slightly larger JS files.
+#
+# This snippet is intended to be used in makefile targets which
+# generate an Emscripten module and where $@ is the module's .js/.mjs
+# file.
+#
+# $1 = an optional log message prefix
+b.call.strip-emcc-js-cruft = \
+  sed -i -e '/^.*= \(_sqlite3\|_fiddle\)[^=]*=.*createExportWrapper/d' \
+  -e '/^var \(_sqlite3\|_fiddle\)[^=]*=.*makeInvalidEarlyAccess/d' $@ || exit; \
+  echo '$(1) $(emo.garbage) (Probably) /createExportWrapper()/d and /makeInvalidEarlyAccess()/d'
+
+
+#
+# bin.version-info = binary to output various sqlite3 version info for
+# embedding in the JS files and in building the distribution zip file.
+# It must NOT be in $(dir.tmp) because we need it to survive the
+# cleanup process for the dist build to work properly.
+#
+# Slight caveat: this uses the version info from the in-tree
+# sqlite3.c/h, which may diff from a user-provided $(sqlite3.c).  The
+# end result is that the generated JS files may have static version
+# info from $(bin.version-info) which differ from their runtime-emitted
+# version info (e.g. from sqlite3_libversion()).
+bin.version-info = $(dir.top)/version-info
+$(bin.version-info): $(dir.tool)/version-info.c $(sqlite3.h) $(dir.top)/Makefile
+       $(MAKE) -C $(dir.top) version-info
+
+#
+# bin.stripcomments is used for stripping C/C++-style comments from JS
+# files. The JS files contain large chunks of documentation which we
+# don't need for all builds. That app's -k flag is of particular
+# importance here, as it allows us to retain the opening comment
+# block(s), which contain the license header and version info.
+bin.stripccomments = $(dir.tool)/stripccomments
+$(bin.stripccomments): $(bin.stripccomments).c $(MAKEFILE)
+       $(CC) -o $@ $<
+DISTCLEAN_FILES += $(bin.stripccomments)
+
+
+#
 # Set up sqlite3.c and sqlite3.h...
 #
 # To build with SEE (https://sqlite.org/see), either put sqlite3-see.c
@@ -206,9 +305,10 @@ else
 endif
 
 
-########################################################################
+#
 # 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 ==============================================================)
@@ -220,7 +320,7 @@ else
 endif
 # undefine barebones # relatively new gmake feature, not ubiquitous
 
-########################################################################@
+#
 # It's important that sqlite3.h be built to completion before any
 # other parts of the build run, thus we use .NOTPARALLEL to disable
 # parallel build of that file and its dependants. However, that makes
@@ -229,6 +329,7 @@ endif
 # sqlite3.c) from the top of the tree before running this build.
 #
 #.NOTPARALLEL: $(sqlite3.h)
+#
 $(sqlite3.h):
        @echo "$(sqlite3.h) is out of date. "; \
        echo "To avoid problems with parallel builds, we're exiting now. Please do:"; \
@@ -320,7 +421,6 @@ endif
 # deprecated and alternatives are in place, but this crash behavior
 # can be used to find errant uses of sqlite3_js_vfs_create_file()
 # in client code.
-
 ########################################################################
 # The following flags are hard-coded into sqlite3-wasm.c and cannot be
 # modified via the build process:
@@ -362,32 +462,6 @@ ifneq (,$(sqlite3_wasm_extra_init.c))
   cflags.wasm_extra_init = -DSQLITE_WASM_EXTRA_INIT
 endif
 
-#########################################################################
-# bin.version-info = binary to output various sqlite3 version info for
-# embedding in the JS files and in building the distribution zip file.
-# It must NOT be in $(dir.tmp) because we need it to survive the
-# cleanup process for the dist build to work properly.
-#
-# Slight caveat: this uses the version info from the in-tree
-# sqlite3.c/h, which may diff from a user-provided $(sqlite3.c).  The
-# end result is that the generated JS files may have static version
-# info from $(bin.version-info) which differ from their runtime-emitted
-# version info (e.g. from sqlite3_libversion()).
-bin.version-info = $(dir.top)/version-info
-$(bin.version-info): $(dir.tool)/version-info.c $(sqlite3.h) $(dir.top)/Makefile
-       $(MAKE) -C $(dir.top) version-info
-
-#########################################################################
-# bin.stripcomments is used for stripping C/C++-style comments from JS
-# files. The JS files contain large chunks of documentation which we
-# don't need for all builds. That app's -k flag is of particular
-# importance here, as it allows us to retain the opening comment
-# block(s), which contain the license header and version info.
-bin.stripccomments = $(dir.tool)/stripccomments
-$(bin.stripccomments): $(bin.stripccomments).c $(MAKEFILE)
-       $(CC) -o $@ $<
-DISTCLEAN_FILES += $(bin.stripccomments)
-
 #
 # If $(WASM_CUSTOM_INSTANTIATE) is 1 then mkwasmbuilds will add
 # -Dcustom-Module.instantiateWasm to some of the builds. This is
@@ -398,11 +472,10 @@ DISTCLEAN_FILES += $(bin.stripccomments)
 WASM_CUSTOM_INSTANTIATE = 0
 
 ########################################################################
-# SQLITE.CALL.C-PP.FILTER: a $(call)able to transform $(1) to $(2) via:
+# $(bin.c-pp): a minimal text file preprocessor. Like C's but much
+# less so.
 #
-#   cat $(1) | ./c-pp -o $(2) $(3)
-#
-# Historical notes:
+# Historical notes about preprocessing files in this project:
 #
 # - We first attempted to use gcc and/or clang to preprocess JS files
 #   in the same way we would normally do C files, but C-specific quirks
@@ -424,8 +497,8 @@ WASM_CUSTOM_INSTANTIATE = 0
 # builds but is maintained as a standalone project:
 # https://fossil.wanderinghorse.net/r/c-pp
 #
-# Note that the SQLITE_... build flags used here have NO EFFECT on the
-# JS/WASM build. They are solely for use with $(bin.c-pp) itself.
+# The SQLITE_... build flags used here have NO EFFECT on the JS/WASM
+# build. They are solely for use with $(bin.c-pp) itself.
 #
 # -D... flags which should be included in all invocations should be
 # appended to $(b.eval.c-pp.flags).
@@ -440,18 +513,6 @@ b.eval.c-pp.flags ?=
 ifeq (1,$(SQLITE_C_IS_SEE))
   b.eval.c-pp.flags += -Denable-see
 endif
-define SQLITE.CALL.C-PP.FILTER
-# Create $2 from $1 using $(bin.c-pp)
-# $1 = Input file(s): cat $(1) | c-pp ...
-# $2 = Output file: c-pp -o $(2).js
-# $3 = optional c-pp -D... flags
-$(2): $(1) $$(MAKEFILE_LIST) $$(bin.c-pp)
-       @$$(call b.call.mkdir@)
-       cat $(1) | $$(bin.c-pp) -o $$@ $(3) $(b.eval.c-pp.flags)
-CLEAN_FILES += $(2)
-endef
-# /end SQLITE.CALL.C-PP.FILTER
-########################################################################
 
 # cflags.common = C compiler flags for all builds
 cflags.common =  -I. -I$(dir $(sqlite3.c))
@@ -467,17 +528,6 @@ emcc.MEMORY64 ?= 0
 # 1.0.34) or will fail to strip with "tables may not be 64-bit".
 ########################################################################
 
-ifneq (0,$(emcc.MEMORY64))
-  emcc.WASM_BIGINT = 1
-  # -sMEMORY64=1+ assumes -sWASM_BIGINT=1, so we'll make it explicit
-
-  # b.eval.c-pp.flags += -D64bit
-  # ^^ We no longer need build-time code filtering for 64-bit but if
-  # we ever do again, just uncomment that line or, if it's just needed
-  # in specific builds, update that build's -D flags in
-  # mkwasmbuilds.c.
-endif
-
 # emcc_opt = optimization-related flags. These are primarily used by
 # the various oX targets. build times for -O levels higher than 0 are
 # painful at dev-time.
@@ -495,9 +545,6 @@ else
   emcc_opt ?= -Oz
 endif
 
-# old name - to remove
-SQLITE.strip-emcc-js-cruft = $(b.call.strip-emcc-js-cruft)
-
 # When passing emcc_opt from the CLI, += and re-assignment have no
 # effect, so emcc_opt+=-g3 doesn't work. So...
 emcc_opt_full = $(emcc_opt) -g3
@@ -544,19 +591,11 @@ $(EXPORTED_FUNCTIONS.api): $(EXPORTED_FUNCTIONS.api.in) $(sqlite3.c) $(MAKEFILE)
        @$(call b.call.mkdir@)
        cat $(EXPORTED_FUNCTIONS.api.in) > $@
 
-########################################################################
-# SOAP.js is an external API file which is part of our distribution
-# but not part of the sqlite3-api.js amalgamation. It's a component of
-# the first OPFS VFS and necessarily an external file.
-SOAP.js.in = $(dir.api)/sqlite3-opfs-async-proxy.js
-SOAP.js = $(dir.dout)/sqlite3-opfs-async-proxy.js
-$(SOAP.js): $(SOAP.js.in)
-       @$(call b.call.cp,@,$<,$@)
 #
 # $(sqlite3-api.ext.jses) = API-related files which are standalone
 # files, not part of the amalgamation.
 #
-sqlite3-api.ext.jses = $(SOAP.js)
+sqlite3-api.ext.jses = $(dir.api)/sqlite3-opfs-async-proxy.js
 
 ########################################################################
 # emcc flags for .c/.o/.wasm/.js.
@@ -566,17 +605,19 @@ emcc.flags += -v
 # -v is _very_ loud but also informative about what it's doing
 endif
 
-
-########################################################################
+#
 # emcc flags for .c/.o.
+#
 emcc.cflags =
 emcc.cflags += -std=c99 -fPIC
 # -------------^^^^^^^^ we need c99 for $(sqlite3-wasm.c), primarily
 # for variadic macros and snprintf() to implement
 # sqlite3__wasm_enum_json().
 emcc.cflags += -I. -I$(dir.top)
-########################################################################
+
+#
 # emcc flags specific to building .js/.wasm files...
+#
 emcc.jsflags = -fPIC
 #emcc.jsflags += -Wno-gcc-install-dir-libstdcxx
 #emcc is not passing ^^^ this on to clang
@@ -610,7 +651,7 @@ emcc.jsflags += -sSTRICT_JS=0
 # -sSTRICT=1 Causes failures about unknown symbols which the build
 # tools should be installing, e.g. __syscall_geteuid32
 
-########################################################################
+#
 # -sINITIAL_MEMORY: How much memory we need to start with is governed
 # at least in part by whether -sALLOW_MEMORY_GROWTH is enabled. If so,
 # we can start with less. If not, we need as much as we'll ever
@@ -626,6 +667,12 @@ emcc.jsflags += -sSTRICT_JS=0
 # but also says (in its changelog): "Note that it is currently not
 # supported in all configurations (#21071)."
 # https://github.com/emscripten-core/emscripten/blob/main/ChangeLog.md
+#
+# 2025-09-25: it turns out that _this_ WASM's heap size is not
+# affected by Emscripten's in-memory virtual filesystem, so we don't
+# strictly need a lot of heap. Resizing the heap is slow, though, so
+# we want to start off with some room to grow.
+#
 emcc.jsflags += -sALLOW_MEMORY_GROWTH
 emcc.INITIAL_MEMORY.128 = 134217728
 emcc.INITIAL_MEMORY.96  = 100663296
@@ -633,9 +680,10 @@ emcc.INITIAL_MEMORY.64  = 67108864
 emcc.INITIAL_MEMORY.32  = 33554432
 emcc.INITIAL_MEMORY.16  = 16777216
 emcc.INITIAL_MEMORY.8   = 8388608
-emcc.INITIAL_MEMORY ?= 8
+emcc.INITIAL_MEMORY.4   = 4194304
+emcc.INITIAL_MEMORY    ?= 8
 ifeq (,$(emcc.INITIAL_MEMORY.$(emcc.INITIAL_MEMORY)))
-$(error emcc.INITIAL_MEMORY must be one of: 8, 16, 32, 64, 96, 128 (megabytes))
+$(error emcc.INITIAL_MEMORY must be one of: 4, 8, 16, 32, 64, 96, 128 (megabytes))
 endif
 emcc.jsflags += -sINITIAL_MEMORY=$(emcc.INITIAL_MEMORY.$(emcc.INITIAL_MEMORY))
 # /INITIAL_MEMORY
@@ -715,12 +763,12 @@ sqlite3-wasmfs.cfiles = $(sqlite3-wasm.cfiles)
 # of building a shared copy of sqlite3-wasm.o to link against.
 ########################################################################
 
-########################################################################
-# SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT is used by mkwasmbuilds.c and the
+#
+# b.call.patch-export-default is used by mkwasmbuilds.c and the
 # wasmfs build. $1 is 1 if the build mode needs this workaround
 # (modes: esm, bundler-friendly, node) and 0 if not (vanilla). $2 must
 # be 0 for all builds except sqlite3-wasmfs.mjs, in which case it must
-# be 1.
+# be 1. $(3) is an optional log prefix, defaulting to $(logtag.@)
 #
 # Reminder for ESM builds: even if we use -sEXPORT_ES6=0, emcc _still_
 # adds:
@@ -737,13 +785,13 @@ sqlite3-wasmfs.cfiles = $(sqlite3-wasm.cfiles)
 #
 # Maintenance reminder: Mac sed works differently than GNU sed, so we
 # use awk instead of sed for this.
-define SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT
+define b.call.patch-export-default
 if [ x1 = x$(1) ]; then \
-               echo "$(3) $(emo.bug) Fragile workaround for emscripten/issues/18237." \
-               "See SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT."; \
+               echo "$(if $(3),$(3),$(logtag.@)) $(emo.bug) Fragile workaround for emscripten/issues/18237." \
+               "See b.call.patch-export-default."; \
                {\
                        awk '/^export default/ && !f{f=1; next} 1' $@ > $@.tmp && mv $@.tmp $@; \
-               } || exit $$?; \
+               } || exit; \
                if [ x1 = x$(2) ]; then \
                        if ! grep -q '^export default' $@; then \
                                echo "Cannot find export default." 1>&2; \
@@ -754,8 +802,8 @@ fi
 endef
 
 #
-# We define these to assist in deps handling to avoid concurrent
-# builds (more notes on that below).
+# We may not need these anymore in this file. They're primarily for
+# use in mkwasmbuilds.c.
 #
 sqlite3.js = $(dir.dout)/sqlite3.js
 sqlite3.mjs = $(dir.dout)/sqlite3.mjs
@@ -765,6 +813,7 @@ sqlite3-64bit.mjs = $(dir.dout)/sqlite3-64bit.mjs
 sqlite3-64bit.wasm = $(dir.dout)/sqlite3-64bit.wasm
 EXPORTED_FUNCTIONS.fiddle = $(dir.tmp)/EXPORTED_FUNCTIONS.fiddle
 
+#
 # The various -D... values used by *.c-pp.js include:
 #
 # -Dtarget=es6-module: for all ESM module builds
@@ -778,34 +827,16 @@ EXPORTED_FUNCTIONS.fiddle = $(dir.tmp)/EXPORTED_FUNCTIONS.fiddle
 #    as string literals so that bundlers' static-analysis tools can
 #    find those files and include them in their bundles.
 #
-# -Dtarget=es6-module -Dtarget=es6-bundler-friendly -Dtarget=node: is
-#    intended for use by node.js for node.js, as opposed to by
-#    node.js on behalf of a browser. Mixing -sENVIRONMENT=web and
-#    -sENVIRONMENT=node leads to ambiguity and confusion on node's
-#    part, as it's unable to reliably determine whether the target is
-#    a browser or node.
+# -Dtarget=es6-module -Dtarget=node: is intended for use by node.js
+#    for node.js, as opposed to by node.js on behalf of a
+#    browser. Mixing -sENVIRONMENT=web and -sENVIRONMENT=node leads to
+#    ambiguity and confusion on node's part, as it's unable to
+#    reliably determine whether the target is a browser or node.
 #
-# We repeat: all node.js builds are 100% untested and unsupported.
+# To repeat: all node.js builds are 100% untested and unsupported.
 #
 ########################################################################
 
-########################################################################
-# We have to ensure that we do not build $(sqlite3*.*js) in parallel
-# for any builds which result in the creation of $(sqlite3.wasm). We
-# have no way to build just a .[m]js file without also building the
-# .wasm file because the generated .[m]js file has to include info
-# about the imports needed by the wasm file, so they have to be built
-# together. i.e.  we're building $(sqlite3.wasm) multiple times, but
-# that's unavoidable (and harmless, but is a significant waste of
-# build time).
-#$(sqlite3.wasm): $(sqlite3.js)
-#$(sqlite3.mjs): $(sqlite3.js)
-#$(sqlite3-64bit.wasm): $(sqlite3-64bit.js)
-#$(sqlite3-64bit.mjs): $(sqlite3-64bit.js)
-#$(dir.dout)/sqlite3-bundler-friendly.mjs: $(sqlite3.mjs)
-#$(dir.dout)/sqlite3-node.mjs: $(sqlite3.mjs)
-#CLEAN_FILES += $(sqlite3.wasm)
-
 #
 # Only add wasmfs if wasmfs.enable=1 or we're running (dist)clean
 #
@@ -840,7 +871,102 @@ endif
 # /wasmfs
 ########################################################################
 
-########################################################################
+#
+# Inputs/outputs for the sqlite3-api.js family.
+#
+# sqlite3-api.jses = the list of JS files which make up
+# sqlite3-api.js, in the order they need to be assembled.
+sqlite3-api.jses = $(sqlite3-license-version.js)
+sqlite3-api.jses += $(dir.api)/sqlite3-api-prologue.js
+sqlite3-api.jses += $(dir.common)/whwasmutil.js
+sqlite3-api.jses += $(dir.jacc)/jaccwabyt.js
+sqlite3-api.jses += $(dir.api)/sqlite3-api-glue.c-pp.js
+sqlite3-api.jses += $(sqlite3-api-build-version.js)
+sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.c-pp.js
+sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.c-pp.js
+sqlite3-api.jses += $(dir.api)/sqlite3-vfs-helper.c-pp.js
+ifeq (0,$(wasm-bare-bones))
+  sqlite3-api.jses += $(dir.api)/sqlite3-vtab-helper.c-pp.js
+endif
+sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs.c-pp.js
+sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs-sahpool.c-pp.js
+sqlite3-api.jses += $(dir.api)/sqlite3-api-cleanup.js
+
+#
+# $(sqlite3-license-version.js) contains the license header and
+# in-comment build version info.
+#
+# Maintenance reminder: there are awk binaries out there which do not
+# support -e SCRIPT.
+#
+sqlite3-license-version.js = $(dir.tmp)/sqlite3-license-version.js
+$(sqlite3-license-version.js): $(bin.version-info) \
+  $(dir.api)/sqlite3-license-version-header.js
+       @echo '$(logtag.@) $(emo.disk)'; { \
+               $(call b.call.mkdir@); \
+               cat $(dir.api)/sqlite3-license-version-header.js || exit $$?;  \
+               echo '/*'; \
+               echo '** This code was built from sqlite3 version...'; \
+               echo '**'; \
+               awk '/define SQLITE_VERSION/{$$1=""; print "**" $$0}' $(sqlite3.h); \
+               awk '/define SQLITE_SOURCE_ID/{$$1=""; print "**" $$0}' $(sqlite3.h); \
+               echo '**'; echo '** Emscripten SDK: $(emcc.version)'; \
+               echo '**'; \
+               echo '*/'; \
+       } > $@
+
+#
+# $(sqlite3-api-build-version.js) injects the build version info into
+# the bundle in JSON form.
+#
+sqlite3-api-build-version.js = $(dir.tmp)/sqlite3-api-build-version.js
+$(sqlite3-api-build-version.js): $(bin.version-info) $(MAKEFILE)
+       @echo '$(logtag.@) $(emo.disk)'; { \
+               $(call b.call.mkdir@); \
+               echo 'globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){'; \
+               echo -n '  sqlite3.version = '; \
+               $(bin.version-info) --json; \
+               echo ';'; \
+               echo '});'; \
+       } > $@
+
+#
+# extern-post-js* and extern-pre-js* are files for use with
+# Emscripten's --extern-pre-js and --extern-post-js flags.
+#
+extern-pre-js.js = $(dir.api)/extern-pre-js.js
+extern-post-js.in.js = $(dir.api)/extern-post-js.c-pp.js
+
+#
+# Emscripten flags for --[extern-][pre|post]-js=... for the
+# various builds.
+# pre-post-jses.*.deps = lists of dependencies for the
+# --[extern-][pre/post]-js files.
+#
+pre-post-jses.common.deps = $(extern-pre-js.js) $(sqlite3-license-version.js)
+
+# --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.in.js = $(dir.api)/pre-js.c-pp.js
+post-js.in.js = $(dir.tmp)/post-js.c-pp.js
+post-jses.js = \
+ $(dir.api)/post-js-header.js \
+ $(sqlite3-api.jses) \
+ $(dir.api)/post-js-footer.js
+$(post-js.in.js): $(MKDIR.bld) $(post-jses.js) $(MAKEFILE)
+       @$(call b.echo,@,$(emo.disk)); \
+       for i in $(post-jses.js); do \
+               echo "/* BEGIN FILE: $$i */"; \
+               cat $$i || exit $$?; \
+               echo "/* END FILE: $$i */"; \
+       done > $@
+
+#
 # bin.mkwb is used for generating much of the makefile code for the
 # various wasm builds. It used to be generated in this makefile via a
 # difficult-to-read/maintain block of $(eval)'d code. Attempts were
@@ -849,8 +975,11 @@ endif
 # native makefile code. Somewhat surprisingly, moving that code generation
 # to C makes it slightly less illegible than the previous 3 options.
 #
-# Maintenance note: the various $(c-pp.D.XYZ) vars are defined via
-# $(bin.mkwb).
+# Maintenance notes:
+#
+# - Ordering of this block within this file is fragile. The generated
+#   makefile sets up many vars which are useful for the other targets.
+#
 bin.mkwb = ./mkwasmbuilds
 ifneq (1,$(MAKING_CLEAN))
 $(bin.mkwb): $(bin.mkwb).c $(MAKEFILE)
@@ -864,12 +993,6 @@ $(bin.mkwb): $(bin.mkwb).c $(MAKEFILE)
 endif
 CLEAN_FILES += .wasmbuilds.make $(bin.mkwb)
 
-#$(error sqlite3-api.ext.jses=$(sqlite3-api.ext.jses))
-all quick: $(sqlite3-api.ext.jses)
-q: quick
-64bit: # populated by $(bin.mkwb)
-
-
 ########################################################################
 # We need separate copies of certain supplementary JS files for the
 # bundler-friendly build. Concretely, any supplemental JS files which
@@ -929,6 +1052,15 @@ endef
 $(eval $(call gen-dwp,.js,.html,$(c-pp.D.vanilla)))
 $(eval $(call gen-dwp,.mjs,-esm.html,$(c-pp.D.esm)))
 
+#
+# Add a dep of $(sqlite3-api.ext.jses) on every build's JS file.
+# The primary purpose of this is to force them to be copied early
+# in the build process, which is sometimes a time-saver during
+# development, allowing the developer to reload a test page while
+# other parts of the build are still running.
+#
+$(foreach B,$(b.names),$(eval $(out.$(B).js): $(sqlite3-api.ext.jses)))
+
 
 ########################################################################
 # batch-runner.js is part of one of the test apps which reads in SQL
@@ -1080,8 +1212,7 @@ tester1: tester1-64bit.js tester1-64bit.mjs tester1-64bit.html tester1-esm-64bit
 tester1: tester1-worker.html tester1-worker-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
-quick: $(sqlite3.js)
+all: tester1
 
 ########################################################################
 # Convenience rules to rebuild with various -Ox levels. Much
@@ -1109,7 +1240,7 @@ o2: clean
 o3: clean
        $(MAKE) -e "emcc_opt=-O3 $(emcc-opt-extra)"
 os: clean
-       @echo "WARNING: -Os can result in a build with mysteriously missing pieces!"
+       @echo "$(emo.fire)WARNING$(emo.fire): -Os can result in a build with mysteriously missing pieces!"
        $(MAKE) -e "emcc_opt=-Os $(emcc-opt-extra)"
 oz: clean
        $(MAKE) -j2 -e "emcc_opt=-Oz $(emcc-opt-extra)"
index 605e8ba5a79c0e94c710f6c2084b868d1088cb93..791bc319ce97f21b32c1bbc4d42b75cc3ba8b0ef 100644 (file)
@@ -1504,7 +1504,8 @@ int main(int argc, char const * const * argv){
       ARGVAL;
       do_infile:
       if( nFile>=sizeof(zFileList)/sizeof(zFileList[0]) ){
-        fatal("Too many file arguments");
+        fatal("Too many file arguments. Max is %d.",
+              (int)(sizeof(zFileList)/sizeof(zFileList[0])));
       }
       zFileList[nFile++] = zArg;
     }
index 4ecbfd2c12b4263b6185841d91ce399c6bf11ab7..d77a655e62a7564f7721bf047683f657658bcd45 100644 (file)
               demonstrates usage of the OPFS SAHPool VFS's "pause" feature to coordinate
               access to a database.
             </li>
+            <li><a href='SQLTester/index.html'>SQLTester</a> is
+              another testing tool for the library but making use of
+              it requires tests from an external, proprietary
+              project. Despite not being useful to the general public,
+              a link to it is in this list so that its developer has
+              easy access to it.
+            </li>
           </ul>
         </li>
         <li><strong>WASMFS</strong>-specific tests which require that
index a8c796abd8c81adc2c271bb92cf5a6c9344a48d0..051dbd691faafc23e118f65caca4ef11caade39f 100644 (file)
@@ -63,7 +63,6 @@ enum {
   /* Indicates a wasmfs build (untested and unsupported). */
   F_WASMFS           = 1<<6,
 
-
   /**
      Which compiled files from $(dir.dout)/buildName/*.{js,mjs,wasm}
      to copy to $(dir.dout) after creating them.
@@ -195,7 +194,7 @@ const BuildDefs oBuildDefs = {
     .zBaseName   = "sqlite3-64bit",
     .zDotWasm    = 0,
     .zCmppD      = 0,
-    .zEmcc       = "-sMEMORY64=1",
+    .zEmcc       = "-sMEMORY64=1 -sWASM_BIGINT=1",
     .zEnv        = 0,
     .zIfCond     = 0,
     .flags       = CP_ALL | F_64BIT
@@ -219,7 +218,7 @@ const BuildDefs oBuildDefs = {
     .zBaseName   = "sqlite3-64bit",
     .zDotWasm    = 0,
     .zCmppD      = "-Dtarget=es6-module",
-    .zEmcc       = "-sMEMORY64=1",
+    .zEmcc       = "-sMEMORY64=1 -sWASM_BIGINT=1",
     .zEnv        = 0,
     .zIfCond     = 0,
     .flags       = CP_JS | F_ESM | F_64BIT
@@ -249,14 +248,13 @@ const BuildDefs oBuildDefs = {
   /* 64-bit bundler-friendly. */
   .bundler64 = {
     .zEmo        = "๐Ÿ“ฆ",
-    .zBaseName   = "sqlite3-bundler-friendly",
-    .zDotWasm    = 0,
+    .zBaseName   = "sqlite3-bundler-friendlyu",
+    .zDotWasm    = "sqlite3-64bit",
     .zCmppD      = "$(c-pp.D.bundler)",
     .zEmcc       = "-sMEMORY64=1",
     .zEnv        = 0,
     .zIfCond     = 0,
-    .flags       = CP_JS | F_ESM | F_BUNDLER_FRIENDLY | F_64BIT
-    //| F_NOT_IN_ALL
+    .flags       = CP_JS | F_ESM | F_BUNDLER_FRIENDLY | F_64BIT | F_NOT_IN_ALL
   },
 
   /*
@@ -336,120 +334,13 @@ static void mk_prologue(void){
     ps("endif");
   }
 
-#if 0
-  ps(zBanner
-     /** $1 = build name. */
-     "b.call.mkdir@ = "
-     "if [ ! -d $(dir $@) ]; then"
-     " echo '[$(emo.folder)+] $(if $(1),$(logtag.$(1)),[$(dir $@)])';"
-     " mkdir -p $(dir $@) || exit $$?;"
-     "fi"
-  );
-#endif
-
   ps(zBanner
      /** $1 = build name */
      "b.call.wasm-strip = "
-     "echo '$(logtag.$(1)) $(emo.strip) wasm-strip $(out.$(1).wasm)'; "
+     "echo '[$(emo.b.$(1)) $(out.$(1).wasm)] $(emo.strip) wasm-strip'; "
      "$(bin.wasm-strip) $(out.$(1).wasm)\n"
   );
 
-  ps(zBanner
-     "# Inputs/outputs for the sqlite3-api.js family.\n"
-     "#\n"
-     "sqlite3-license-version.js = $(dir.tmp)/sqlite3-license-version.js\n"
-     "sqlite3-api-build-version.js = $(dir.tmp)/sqlite3-api-build-version.js\n"
-     "# sqlite3-api.jses = the list of JS files which make up\n"
-     "# sqlite3-api.js, in the order they need to be assembled.\n"
-     "sqlite3-api.jses = $(sqlite3-license-version.js)\n"
-     "sqlite3-api.jses += $(dir.api)/sqlite3-api-prologue.js\n"
-     "sqlite3-api.jses += $(dir.common)/whwasmutil.js\n"
-     "sqlite3-api.jses += $(dir.jacc)/jaccwabyt.js\n"
-     "sqlite3-api.jses += $(dir.api)/sqlite3-api-glue.c-pp.js\n"
-     "sqlite3-api.jses += $(sqlite3-api-build-version.js)\n"
-     "sqlite3-api.jses += $(dir.api)/sqlite3-api-oo1.c-pp.js\n"
-     "sqlite3-api.jses += $(dir.api)/sqlite3-api-worker1.c-pp.js\n"
-     "sqlite3-api.jses += $(dir.api)/sqlite3-vfs-helper.c-pp.js\n"
-     "ifeq (0,$(wasm-bare-bones))\n"
-     "  sqlite3-api.jses += $(dir.api)/sqlite3-vtab-helper.c-pp.js\n"
-     "endif\n"
-     "sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs.c-pp.js\n"
-     "sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs-sahpool.c-pp.js\n"
-     "sqlite3-api.jses += $(dir.api)/sqlite3-api-cleanup.js"
-  );
-
-  ps(zBanner
-     "# $(sqlite3-license-version.js) contains the license header and\n"
-     "# in-comment build version info.\n"
-     "#\n"
-     "# Maintenance reminder: there are awk binaries out there which do not\n"
-     "# support -e SCRIPT.\n"
-     "$(sqlite3-license-version.js): $(sqlite3.h) "
-     "$(dir.api)/sqlite3-license-version-header.js $(MAKEFILE)\n"
-     "\t@echo '$(logtag.@) $(emo.disk)'; { \\\n"
-     "\t\t$(call b.call.mkdir@); \\\n"
-     "\t\tcat $(dir.api)/sqlite3-license-version-header.js || exit $$?;  \\\n"
-     "\t\techo '/*'; \\\n"
-     "\t\techo '** This code was built from sqlite3 version...'; \\\n"
-     "\t\techo '**'; \\\n"
-     "\t\tawk '/define SQLITE_VERSION/{$$1=\"\"; print \"**\" $$0}' $(sqlite3.h); \\\n"
-     "\t\tawk '/define SQLITE_SOURCE_ID/{$$1=\"\"; print \"**\" $$0}' $(sqlite3.h); \\\n"
-     "\t\techo '**'; \\\n"
-     "\t\techo '** with the help of Emscripten SDK version $(emcc.version).'; \\\n"
-     "\t\techo '*/'; \\\n"
-     "\t} > $@"
-  );
-
-  ps(zBanner
-     "# $(sqlite3-api-build-version.js) injects the build version info into\n"
-     "# the bundle in JSON form.\n"
-     "$(sqlite3-api-build-version.js): $(bin.version-info) $(MAKEFILE)\n"
-     "\t@echo '$(logtag.@) $(emo.disk)'; { \\\n"
-     "\t\t$(call b.call.mkdir@); \\\n"
-     "\t\techo 'globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){'; \\\n"
-     "\t\techo -n '  sqlite3.version = '; \\\n"
-     "\t\t$(bin.version-info) --json; \\\n"
-     "\t\techo ';'; \\\n"
-     "\t\techo '});'; \\\n"
-     "\t} > $@"
-  );
-
-  ps(zBanner
-     "# 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.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"
-     "# --[extern-][pre/post]-js files.\n"
-     "pre-post-jses.common.deps = "
-     "$(extern-pre-js.js) $(sqlite3-license-version.js)"
-  );
-
-  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.jses)"
-     " $(dir.api)/post-js-footer.js\n"
-     "$(post-js.in.js): $(MKDIR.bld) $(post-jses.js) $(MAKEFILE)\n"
-     "\t@echo '$(logtag.@) $(emo.disk)'\n"
-     "\t@for i in $(post-jses.js); do \\n"
-     "\t\techo \"/* BEGIN FILE: $$i */\"; \\n"
-     "\t\tcat $$i || exit $$?; \\n"
-     "\t\techo \"/* END FILE: $$i */\"; \\n"
-     "\tdone > $@\n"
-  );
-
   pf(zBanner
      "define b.do.emcc\n"
      /* $1 = build name */
@@ -510,30 +401,30 @@ static void mk_prologue(void){
       ;
     ps(zBanner
        "# post-compilation WASM file optimization");
-    ps("ifeq (,$(bin.wasm-opt))");
-    {
-      ps("define b.do.wasm-opt");
-      ps("echo '$(logtag.$(1)) wasm-opt not available'");
-      ps("endef");
+
+    /* b.do.wasm-opt $1 = build name*/
+    ps("ifeq (,$(bin.wasm-opt))"); {
+      ps("b.do.wasm-opt = echo '$(logtag.$(1)) wasm-opt not available'");
     }
-    ps("else");
-    {
+    ps("else"); {
       ps("define b.do.wasm-opt"
-         /* $1 = build name*/
       );
       pf(
-        "echo '$(logtag.$(1)) $(emo.tool) Applying $(bin.wasm-opt)';\\\n"
-        "\trm -f wasm-opt-tmp.$(1).wasm;\\\n"
-        /* It's very likely that the set of wasm-opt flags varies from
-        ** version to version, so we'll ignore any errors here. */
-        "\tif $(bin.wasm-opt) $(out.$(1).wasm) -o wasm-opt-tmp.$(1).wasm \\\n"
+        "echo '[$(emo.b.$(1)) $(out.$(1).wasm)] $(emo.wasm-opt) $(bin.wasm-opt)';\\\n"
+        "\ttmpfile=$(dir.dout.$(1))/wasm-opt-tmp.$(1).wasm; \\\n"
+        "\trm -f $$tmpfile; \\\n"
+        "\tif $(bin.wasm-opt) $(out.$(1).wasm) "
+        "-o $$tmpfile \\\n"
         "\t\t%s; then \\\n"
-        "\t\tmv wasm-opt-tmp.$(1).wasm $(out.$(1).wasm); \\\n"
+        "\t\tmv $$tmpfile $(out.$(1).wasm); \\\n"
 #if 0
         "\t\techo -n 'After wasm-opt: '; \\\n"
         "\t\tls -l $(1); \\\n"
 #endif
+        /* It's very likely that the set of wasm-opt flags varies from
+        ** version to version, so we'll ignore any errors here. */
         "\telse \\\n"
+        "\t\trm -f $$tmpfile; \\\n"
         "\t\techo '$(2) $(emo.fire) ignoring wasm-opt failure'; \\\n"
         "\tfi\n",
         zOptFlags
@@ -658,7 +549,7 @@ static void emit_compile_start(char const *zBuildName){
 */
 static void emit_api_js(char const *zBuildName,
                         char const *zCmppD){
-  pf("c-pp.D.%s ?= %s\n"
+  pf("c-pp.D.%s = %s\n"
      "sqlite3-api.%s.js = $(dir.tmp)/sqlite3-api.%s.js\n",
      zBuildName, zCmppD ? zCmppD: "",
      zBuildName, zBuildName);
@@ -666,9 +557,9 @@ static void emit_api_js(char const *zBuildName,
      "%s,"
      "$(sqlite3-api.jses),"
      "$(sqlite3-api.%s.js),"
-     "$(c-pp.D.%s) %s"
+     "$(c-pp.D.%s)"
      "))\n",
-     zBuildName, zBuildName, zBuildName, zCmppD ? zCmppD : "");
+     zBuildName, zBuildName, zBuildName);
   pf("$(out.%s.js): $(sqlite3-api.%s.js)\n",
      zBuildName, zBuildName);
 }
@@ -688,6 +579,12 @@ static void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
   pf("# zCmppD=%s\n# zBaseName=%s\n",
      pB->zCmppD ? pB->zCmppD : "", zBaseName);
 
+  pf(
+    "b.names += %s\n"
+    "emo.b.%s = %s\n",
+    zBuildName, zBuildName, pB->zEmo);
+  pf("b.names += %s\n", zBuildName);
+
   pf("logtag.%s ?= [%s [%s] $@]:\n", zBuildName, pB->zEmo, zBuildName);
   if( pB->zIfCond ){
     pf("%s\n", pB->zIfCond );
@@ -725,13 +622,7 @@ static void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
     pf(zBanner
        "$(out.%s.js): $(MAKEFILE_LIST) $(sqlite3-wasm.cfiles)"
        " $(EXPORTED_FUNCTIONS.api)"
-       " $(bin.mkwb) $(pre-post.%s.deps) "
-       " $(sqlite3-api.ext.jses)"
-       /* maintenance reminder: we set these ^^^^ as deps so that they
-       ** get copied into place early. That allows the developer to
-       ** reload the base-most test pages while the later-stage builds
-       ** are still compiling, which is especially helpful when
-       ** running builds with long build times (like -Oz). */
+       " $(bin.mkwb) $(pre-post.%s.deps)"
        "\n",
        zBuildName, zBuildName);
 
@@ -750,7 +641,7 @@ static void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
         ** code.  OTOH, we also use this $(call) in the speedtest1-wasmfs
         ** build, which is not part of the rules emitted by this
         ** program. */
-        pf("\t@$(call SQLITE.CALL.xJS.ESM-EXPORT-DEFAULT,1,%d,$(logtag.%s))\n",
+        pf("\t@$(call b.call.patch-export-default,1,%d,$(logtag.%s))\n",
            (F_WASMFS & pB->flags) ? 1 : 0,
            zBuildName
         );
@@ -766,13 +657,13 @@ static void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
       pf("\t@$(call b.call.strip-js-cruft,$(logtag.%s))\n", zBuildName);
 
       if( CP_JS & pB->flags && !(pB->zDotWasm/*handled below*/) ){
-        pf("\t@$(call b.call.cp,%s,$@,$(dir.dout)/.)\n",
+        pf("\t@$(call b.call.cp,%s,$@,$(dir.dout))\n",
            zBuildName
         );
       }
       if( CP_WASM & pB->flags ){
-        pf("\t@$(call b.call.cp,%s,$(out.%s.wasm),$(dir.dout)/.)\n",
-           zBuildName, zBuildName
+        pf("\t@$(call b.call.cp,%s,$(basename $@).wasm,$(dir.dout))\n",
+           zBuildName
            //"\techo '[%s $(out.%s.wasm)] $(emo.disk) $(dir.dout)/$(notdir $(out.%s.wasm))'
            //pB->zEmo, zBuildName
         );
@@ -812,7 +703,7 @@ static void mk_lib_mode(const char *zBuildName, const BuildDef * pB){
          "exit 1; fi;\n", zBuildName);
     }
   }
-  pf("\t@echo '$(logtag.%s) $(emo.done)'\n", zBuildName);
+  pf("\t@$(call b.echo,%s,$(emo.done) done!)\n", zBuildName);
 
   pf("\n%dbit: $(out.%s.js)\n"
      "$(out.%s.wasm): $(out.%s.js)\n"
@@ -892,8 +783,7 @@ static void mk_fiddle(void){
       pf("$(out.%s.js): $(MAKEFILE_LIST) $(MAKEFILE.fiddle) "
          "$(EXPORTED_FUNCTIONS.fiddle) "
          "$(fiddle.cses) "
-         "$(pre-post.%s.deps) "
-         "$(SOAP.js)\n",
+         "$(pre-post.%s.deps)\n",
          zBuildName, zBuildName);
       emit_compile_start(zBuildName);
       pf("\t$(b.cmd@)$(bin.emcc) -o $@"
@@ -905,7 +795,10 @@ static void mk_fiddle(void){
       pf("\t@chmod -x $(out.%s.wasm)\n", zBuildName);
       pf("\t@$(call b.call.wasm-strip,%s)\n", zBuildName);
       pf("\t@$(call b.call.strip-js-cruft,$(logtag.%s))\n", zBuildName);
-      pf("\t@$(call b.call.cp,%s,$(SOAP.js),$(dir $@))\n", zBuildName);
+      pf("\t@$(call b.call.cp,"
+         "%s,"
+         "$(dir.api)/sqlite3-opfs-async-proxy.js,"
+         "$(dir $@))\n", zBuildName);
       if( isDebug ){
         pf("\t@$(call b.call.cp,%s,"
            "$(dir.fiddle)/index.html "
diff --git a/ext/wasm/util.make b/ext/wasm/util.make
deleted file mode 100644 (file)
index 3201024..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-#
-# Common vars and $(call)able utilities for the SQLite WASM build.
-#
-# The "b." prefix on some APIs is for "build". It was initially used
-# only for build-specific features. That's no longer the case, but the
-# naming convention has stuck.
-#
-
-#
-# Emoji for log messages.
-#
-emo.bug       = ๐Ÿž
-emo.compile   = โณ
-emo.roadblock = ๐Ÿšง
-emo.disk      = ๐Ÿ’พ
-emo.done      = ๐Ÿ†
-emo.fire      = ๐Ÿ”ฅ
-emo.folder    = ๐Ÿ“
-emo.garbage   = ๐Ÿ—‘
-emo.lock      = ๐Ÿ”’
-emo.magic     = ๐Ÿง™
-emo.megaphone = ๐Ÿ“ฃ
-emo.mute      = ๐Ÿ”‡
-emo.stop      = ๐Ÿ›‘
-emo.strip     = ๐Ÿ’ˆ
-emo.test      = ๐Ÿงช
-emo.tool      = ๐Ÿ”จ
-# ๐Ÿ‘ท๐Ÿช„๐Ÿงฎ๐Ÿงซ๐Ÿงฝ๐Ÿฟโ›ฝ๐Ÿšง๐ŸŽฑ๐Ÿชš
-
-loud ?= 0
-ifeq (1,$(loud))
-  $(info $(emo.megaphone) Emitting loud build info. Pass loud=0 to disable it.)
-  b.cmd@ =
-  loud.if = 1
-else
-  $(info $(emo.mute) Eliding loud build info. Pass loud=1 to enable it.)
-  b.cmd@ = @
-  loud.if =
-endif
-
-#
-# logtag.X value for log context labeling. longtag.OTHERX can be
-# assigned to customize it for a given X. This tag is used by the
-# b.call.X and b.eval.X for logging.
-#
-logtag.@ = [$@]
-logtag.filter = [$(emo.magic) $@]
-logtag.test = [$(emo.test) $@]
-
-#
-# $(call b.echo,LOGTAG,msg)
-#
-b.echo = echo $(logtag.$(1)) $(2)
-
-#
-# $(call b.call.mkdir@)
-#
-# $1 = optional LOGTAG
-#
-b.call.mkdir@ = if [ ! -d $(dir $@) ]; then \
-  echo '[$(emo.folder)+] $(if $(1),$(logtag.$(1)),[$(dir $@)])'; \
-  mkdir -p $(dir $@) || exit; fi
-
-#
-# $(call b.call.cp,@,src,dest)
-#
-# $1 = build name, $2 = src file(s). $3 = dest dir
-b.call.cp = $(call b.call.mkdir@); \
-  echo '$(logtag.$(1)) $(emo.disk) $(2) ==> $3'; \
-  cp -p $(2) $(3) || exit
-
-#
-# $(eval $(call b.eval.c-pp,@,src,dest,-Dx=y...))
-#
-# $1 = build name
-# $2 = Input file(s): cat $(2) | $(bin.c-pp) ...
-# $3 = Output file: $(bin.c-pp) -o $(3)
-# $4 = optional $(bin.c-pp) -D... flags */
-#
-define b.eval.c-pp
-$(3): $$(MAKEFILE_LIST) $$(bin.c-pp) $(2)
-       @$$(call b.call.mkdir@); \
-       $$(call b.echo,$(1),$$(emo.disk)$$(emo.lock) $$(bin.c-pp) $(4) $(if $(loud.if),$(2))); \
-       rm -f $(3); \
-       $$(bin.c-pp) -o $(3) $(4) $(2) $$(SQLITE.CALL.C-PP.FILTER.global) || exit; \
-       chmod -w $(3)
-CLEAN_FILES += $(3)
-endef
-
-#
-# $(call b.call.strip-emcc-js-cruft)
-#
-# Our JS code installs bindings of each sqlite3_...() WASM export. The
-# generated Emscripten JS file does the same using its own framework,
-# but we don't use those results and can speed up lib init, and reduce
-# memory cost a bit, by stripping them out. Emscripten-side changes
-# can "break" this, causing this to be a no-op, but the worst that can
-# happen in that case is that it doesn't actually strip anything,
-# leading to slightly larger JS files.
-#
-# This snippet is intended to be used in makefile targets which
-# generate an Emscripten module and where $@ is the module's .js/.mjs
-# file.
-#
-# $1 = an optional log message prefix
-b.call.strip-emcc-js-cruft = \
-  sed -i -e '/^.*= \(_sqlite3\|_fiddle\)[^=]*=.*createExportWrapper/d' \
-  -e '/^var \(_sqlite3\|_fiddle\)[^=]*=.*makeInvalidEarlyAccess/d' $@ || exit; \
-  echo '$(1) $(emo.garbage) (Probably) /createExportWrapper()/d and /makeInvalidEarlyAccess()/d'
index a514e7084a253746533f7739b326ac9b21876461..9c253be1839eee9bf3e96a199301a10e46da24e1 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Cosmetic\smakefile\stweaks.
-D 2025-09-24T20:53:19.837
+C Move\sthe\sstatic\smakefile\scode\sfrom\smkwamsbuilds.c\sinto\sthe\smakefile.\sMove\sutil.make\sback\sinto\sthe\smain\smakefile.\sRemove\sa\sbunch\sof\sdead\smakefile\scode\sand\sdocs.
+D 2025-09-24T23:07:45.647
 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 9042679ed2f5c3599478912ef27b084a952f1449e2ca5585f25cc8f81f015e51
+F ext/wasm/GNUmakefile 2ccc1a25b21dcbe2e758bf16228ecd4223196a4249249f38aa4e2aed15b4e5c9
 F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a
 F ext/wasm/README.md 66ace67ae98a45e4116f2ca5425b716887bcee4d64febee804ff6398e1ae9ec7
 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff
@@ -614,7 +614,7 @@ F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0
 F ext/wasm/batch-runner-sahpool.js 54a3ac228e6c4703fe72fb65c897e19156263a51fe9b7e21d2834a45e876aabd
 F ext/wasm/batch-runner.html 4deeed44fe41496dc6898d9fb17938ea3291f40f4bfb977e29d0cef96fbbe4c8
 F ext/wasm/batch-runner.js 05ec254f5dbfe605146d9640b3db17d6ef8c3fbef6aa8396051ca72bb5884e3f
-F ext/wasm/c-pp.c 8d7780f69ced4d29fffd88ff22613eace6c72fa9a1a6a5699a219070a45e7b21
+F ext/wasm/c-pp.c 7692739ac435120c37b9de993f152c90e5dbf6a340ca6331de81d7b8b06b5307
 F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51
 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15
 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f
@@ -636,10 +636,10 @@ F ext/wasm/fiddle/fiddle-worker.js 7798af02e672e088ff192716f80626c8895e19301a65b
 F ext/wasm/fiddle/fiddle.js 84fd75967e0af8b69d3dd849818342227d0f81d13db92e0dcbc63649b31a4893
 F ext/wasm/fiddle/index.html a27b8127ef9ecf19612da93b2a6a73bdb3777b5c56b5450bb7200a94bc108ff9
 F ext/wasm/index-dist.html 56132399702b15d70c474c3f1952541e25cb0922942868f70daf188f024b3730
-F ext/wasm/index.html cf1f8d15ab3168560610460eea8c7639284e05cd128dfb9fd003781917ce3763
+F ext/wasm/index.html 1b329fb63e057c02a17ce178308d6b06aac62d92af7dd6d821fb0e183e0f1557
 F ext/wasm/jaccwabyt/jaccwabyt.js bbac67bc7a79dca34afe6215fd16b27768d84e22273507206f888c117e2ede7d
 F ext/wasm/jaccwabyt/jaccwabyt.md 167fc0b624c9bc2c477846e336de9403842d81b1a24fc4d3b24317cb9eba734f
-F ext/wasm/mkwasmbuilds.c 7f0c4e9ae88647c2c5f2dd4e42a3eae412984c267fa7102d30efaef3c241e4fa
+F ext/wasm/mkwasmbuilds.c 1c52e949c1301f3bc8c66a7b9bd5f565d6c66ca6127267dbed6f666535e42985
 F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337
 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96
 F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd842231505895eff00dbd57c63
@@ -664,7 +664,6 @@ F ext/wasm/tests/opfs/sahpool/digest.html 206d08a34dc8bd570b2581d3d9ab3ecad3201b
 F ext/wasm/tests/opfs/sahpool/index.html be736567fd92d3ecb9754c145755037cbbd2bca01385e2732294b53f4c842328
 F ext/wasm/tests/opfs/sahpool/sahpool-pausing.js f264925cfc82155de38cecb3d204c36e0f6991460fff0cb7c15079454679a4e2
 F ext/wasm/tests/opfs/sahpool/sahpool-worker.js bd25a43fc2ab2d1bafd8f2854ad3943ef673f7c3be03e95ecf1612ff6e8e2a61
-F ext/wasm/util.make bdc3f8df394f80e405e8197fd8f5c0b081841c0621c0a72205f828606d08274e
 F ext/wasm/wasmfs.make 5de02751b3e9e79b81a52ab4fe0ed6aa6a23311a90db58fea98c1c4e2845e562
 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0
 F main.mk 20fe7a151708fc6b1f8cd0fdcc73622701cff5959131cfb73e1f75d33e687bf8
@@ -2176,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 6691a84872f823c95b0bdc3db8e12d21c9561aa1e1ce1d787a977f2c5ef8225a
-R 40efe4f205f4330b1c5bbe8b114e0e1d
+P 4ec7e6800e090f7e17469a77bc37b57d3e1777171a5b354dfc68345416de504f
+R 342a67038077e1175d39de0f455be049
 U stephan
-Z bd9504bee0168d0fc3d8a441c569ac50
+Z 2c80b2640c338bdfc3dd972e978d7a39
 # Remove this line to create a well-formed Fossil manifest.
index 81306e35665f3e89c0033a2310d0a6bc028087d2..d3d58b5dd9cf48f74e63330f3e777ab6477b7276 100644 (file)
@@ -1 +1 @@
-4ec7e6800e090f7e17469a77bc37b57d3e1777171a5b354dfc68345416de504f
+18beeb26bfa48f806866e0e330024535adabcf668071abc4b6251eb39de2701d