]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Overhaul ext/wasm/GNUmakefile to consolidate what amounts to much copy/paste/slightly...
authorstephan <stephan@noemail.net>
Sat, 28 Jan 2023 09:11:08 +0000 (09:11 +0000)
committerstephan <stephan@noemail.net>
Sat, 28 Jan 2023 09:11:08 +0000 (09:11 +0000)
FossilOrigin-Name: 168e5a93013d8650c180e19788e5f301b5d5ae8501d0ce728004fd750ca9e682

ext/wasm/GNUmakefile
manifest
manifest.uuid

index 78e34eb192ffb091193af8bddf6f0268869d4b8f..018d7edd531ba4d6523b4f936b88fc4e1a36a3db 100644 (file)
@@ -249,21 +249,9 @@ $(2): $(1) $$(MAKEFILE) $$(bin.c-pp)
        $$(bin.c-pp) -f $(1) -o $$@ $(3)
 CLEAN_FILES += $(2)
 endef
-c-pp.D.vanilla :=
-c-pp.D.esm := -Dtarget=es6-module
-c-pp.D.bundler-friendly := $(c-pp.D.esm) -Dtarget=es6-bundler-friendly
-# The various -D... values used by the sources include:
-#
-# -Dtarget=es6-module: intended for plain ESM module build.
-#
-# -Dtarget=es6-module -Dtarget=es6-bundler-friendly: intended for
-#    "bundler-friendly" ESM module build. These have some restrictions
-#    on how URL() objects are constructed in some contexts.
-#
 # /end C-PP.FILTER
 ########################################################################
 
-
 # cflags.common = C compiler flags for all builds
 cflags.common :=  -I. -I.. -I$(dir.top)
 # emcc.WASM_BIGINT = 1 for BigInt (C int64) support, else 0.  The API
@@ -353,6 +341,27 @@ $(foreach X,$(SOAP.js) $(sqlite3-worker1.js) $(sqlite3-worker1-promiser.js),\
 all quick: $(sqlite3-api.ext.jses)
 q: quick
 
+########################################################################
+# $(sqlite3-api*.*js) contain the core library code but not the
+# Emscripten-related glue which deals with loading sqlite3.wasm. In
+# theory they can be used by arbitrary build environments and WASM
+# loaders, but in practice that breaks down because the WASM loader
+# has to be able to provide all of the necessary "imports" to
+# sqlite3.wasm, and that list of imports is unknown until sqlite3.wasm
+# is compiled, at which point Emscripten sets up the imports
+# appropriately. Abstractly speaking, it's impossible for other build
+# environments to know exactly which imports are needed and provide
+# them. Tools like wasm-objdump can be used to find the list of
+# imports but it's questionable whether a non-Emscripten tool could
+# realistically use that info to provide proper implementations.
+# Sidebar: some of the imports are used soley by the Emscripten glue,
+# which the sqlite3 JS code does not rely on.
+#
+# We build $(sqlite3-api*.*) "because we can" and because it might be
+# a useful point of experimentation for some clients, but the
+# above-described caveat may well make them unusable for real-life
+# clients.
+#
 # sqlite3-api.js.in = the generated sqlite3-api.js before it gets
 # preprocessed. It contains all of $(sqlite3-api.jses) but none of the
 # Emscripten-specific headers and footers.
@@ -365,150 +374,6 @@ $(sqlite3-api.js.in): $(sqlite3-api.jses) $(MAKEFILE)
                echo "/* END FILE: $$i */"; \
        done > $@
 
-########################################################################
-# $(sqlite3-api.js) and $(sqlite3-api.mjs) (ES6 module) contain the
-# core library code but not the Emscripten-related glue which deals
-# with loading sqlite3.wasm. In theory they can be used by arbitrary
-# build environments and WASM loaders, but in practice that breaks
-# down because the WASM loader has to be able to provide all of the
-# necessary "imports" to sqlite3.wasm, and that list of imports is
-# unknown until sqlite3.wasm is compiled, at which point Emscripten
-# sets up the imports appropriately. Abstractly speaking, it's
-# impossible for other build environments to know exactly which
-# imports are needed and provide them. Tools like wasm-objdump can be
-# used to find the list of imports but it's questionable whether a
-# non-Emscripten tool could realistically use that info to provide
-# proper implementations. Sidebar: some of the imports are used soley
-# by the Emscripten glue, which the sqlite3 JS code does not rely on.
-#
-# We build $(sqlite3-api.js) and $(sqlite3-api.mjs) "because we can"
-# and because it might be a useful point of experimentation for some
-# clients, but the above-described caveat may well make them unusable
-# for real-life clients.
-sqlite3-api.js := $(dir.dout)/sqlite3-api.js
-sqlite3-api.mjs := $(dir.dout)/sqlite3-api.mjs
-sqlite3-api-bundler-friendly.mjs := $(dir.dout)/sqlite3-api-bundler-friendly.mjs
-$(eval $(call C-PP.FILTER, $(sqlite3-api.js.in), $(sqlite3-api.js)))
-$(eval $(call C-PP.FILTER, $(sqlite3-api.js.in), $(sqlite3-api.mjs), $(c-pp.D.esm)))
-$(eval $(call C-PP.FILTER, $(sqlite3-api.js.in), $(sqlite3-api-bundler-friendly.mjs), $(c-pp.D.bundler-friendly)))
-all: $(sqlite3-api.js) $(sqlite3-api.mjs) $(sqlite3-api-bundler-friendly.mjs)
-
-$(sqlite3-api-build-version.js): $(bin.version-info) $(MAKEFILE)
-       @echo "Making $@..."
-       @{ \
-  echo 'self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){'; \
-       echo -n '  sqlite3.version = '; \
-  $(bin.version-info) --json; \
-  echo ';'; \
-       echo '});'; \
-  } > $@
-$(sqlite3-license-version.js): $(sqlite3.h) $(sqlite3-license-version-header.js) \
-  $(MAKEFILE)
-       @echo "Making $@..."; { \
-    cat $(sqlite3-license-version-header.js); \
-    echo '/*'; \
-    echo '** This code was built from sqlite3 version...'; \
-    echo "**"; \
-    awk -e '/define SQLITE_VERSION/{$$1=""; print "**" $$0}' \
-        -e '/define SQLITE_SOURCE_ID/{$$1=""; print "**" $$0}' $(sqlite3.h); \
-    echo '*/'; \
-   } > $@
-
-########################################################################
-# --post-js and --pre-js are emcc flags we use to append/prepend JS to
-# the generated emscripten module file. The following rules generate
-# various versions of those files for the vanilla and ESM builds.
-pre-js.js.in := $(dir.api)/pre-js.c-pp.js
-pre-js.js.vanilla := $(dir.tmp)/pre-js.vanilla.js
-pre-js.js.esm := $(dir.tmp)/pre-js.esm.js
-pre-js.js.bundler-friendly := $(dir.tmp)/pre-js.bundler-friendly.js
-$(eval $(call C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.vanilla),$(c-pp.D.vanilla)))
-$(eval $(call C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.esm),$(c-pp.D.esm)))
-$(eval $(call C-PP.FILTER,$(pre-js.js.in),$(pre-js.js.bundler-friendly),$(c-pp.D.bundler-friendly)))
-post-js.js.in := $(dir.tmp)/post-js.c-pp.js
-post-js.js.vanilla := $(dir.tmp)/post-js.vanilla.js
-post-js.js.esm := $(dir.tmp)/post-js.esm.js
-post-js.js.bundler-friendly := $(dir.tmp)/post-js.bundler-friendly.js
-post-jses.js := \
-  $(dir.api)/post-js-header.js \
-  $(sqlite3-api.js.in) \
-  $(dir.api)/post-js-footer.js
-$(post-js.js.in): $(post-jses.js) $(MAKEFILE)
-       @echo "Making $@..."
-       @for i in $(post-jses.js); do \
-               echo "/* BEGIN FILE: $$i */"; \
-               cat $$i; \
-               echo "/* END FILE: $$i */"; \
-       done > $@
-$(eval $(call C-PP.FILTER,$(post-js.js.in),$(post-js.js.vanilla),$(c-pp.D.vanilla)))
-$(eval $(call C-PP.FILTER,$(post-js.js.in),$(post-js.js.esm),$(c-pp.D.esm)))
-$(eval $(call C-PP.FILTER,$(post-js.js.in),$(post-js.js.bundler-friendly),$(c-pp.D.bundler-friendly)))
-
-# extern-post-js* and extern-pre-js* are files for use with
-# Emscripten's --extern-pre-js and --extern-post-js flags.  These
-# rules make different copies for the vanilla and ESM builds.
-extern-post-js.js.in := $(dir.api)/extern-post-js.c-pp.js
-extern-post-js.js.vanilla := $(dir.tmp)/extern-post-js.vanilla.js
-extern-post-js.js.esm := $(dir.tmp)/extern-post-js.esm.js
-extern-post-js.js.bundler-friendly := $(dir.tmp)/extern-post-js.bundler-friendly.js
-$(eval $(call C-PP.FILTER,$(extern-post-js.js.in),$(extern-post-js.js.vanilla),$(c-pp.D.vanilla)))
-$(eval $(call C-PP.FILTER,$(extern-post-js.js.in),$(extern-post-js.js.esm),$(c-pp.D.esm)))
-$(eval $(call C-PP.FILTER,$(extern-post-js.js.in),$(extern-post-js.js.bundler-friendly),$(c-pp.D.bundler-friendly)))
-extern-pre-js.js := $(dir.api)/extern-pre-js.js
-
-# Emscripten flags for --[extern-][pre|post]-js=... for the
-# various builds.
-pre-post-common.flags := \
-  --extern-pre-js=$(sqlite3-license-version.js)
-pre-post-common.flags.vanilla := \
-  $(pre-post-common.flags) \
-  --post-js=$(post-js.js.vanilla) \
-  --extern-post-js=$(extern-post-js.js.vanilla)
-pre-post-common.flags.esm := \
-  $(pre-post-common.flags) \
-  --post-js=$(post-js.js.esm) \
-  --extern-post-js=$(extern-post-js.js.esm)
-pre-post-common.flags.bundler-friendly := \
-  $(pre-post-common.flags) \
-  --post-js=$(post-js.js.bundler-friendly) \
-  --extern-post-js=$(extern-post-js.js.bundler-friendly)
-
-# pre-post-jses.deps.* = a list of dependencies for the
-# --[extern-][pre/post]-js files.
-pre-post-jses.deps.common := $(extern-pre-js.js) $(sqlite3-license-version.js)
-pre-post-jses.deps.vanilla := $(pre-post-jses.deps.common) \
-  $(post-js.js.vanilla) $(extern-post-js.js.vanilla)
-pre-post-jses.deps.esm := $(pre-post-jses.deps.common) \
-  $(post-js.js.esm) $(extern-post-js.js.esm)
-pre-post-jses.deps.bundler-friendly := $(pre-post-jses.deps.common) \
-  $(post-js.js.bundler-friendly) $(extern-post-js.js.bundler-friendly)
-
-########################################################################
-# call-make-pre-js is a $(call)able which creates rules for
-# pre-js-$(1).js. $1 = the base name of the JS file on whose behalf
-# this pre-js is for (one of: sqlite3, sqlite3-wasm). $2 is the build
-# mode: one of (vanilla, esm, bundler-friendly).  This sets up
-# --[extern-][pre/post]-js flags in $(pre-post-$(1).flags.$(2)) and
-# dependencies in $(pre-post-$(1).deps.$(2)).
-define call-make-pre-js
-pre-post-$(1).flags.$(2) ?=
-$$(dir.tmp)/pre-js-$(1)-$(2).js: $$(pre-js.js.$(2)) $$(MAKEFILE)
-       cp $$(pre-js.js.$(2)) $$@
-       @if [ sqlite3-wasmfs = $(1) ]; then \
-               echo "delete Module[xNameOfInstantiateWasm] /*for WASMFS build*/;"; \
-       elif [ sqlite3 != $(1) ]; then \
-               echo "Module[xNameOfInstantiateWasm].uri = '$(1).wasm';"; \
-       fi >> $$@
-pre-post-$(1).deps.$(2) := \
-  $$(pre-post-jses.deps.$(2)) \
-  $$(dir.tmp)/pre-js-$(1)-$(2).js
-pre-post-$(1).flags.$(2) += \
-  $$(pre-post-common.flags.$(2)) \
-  --pre-js=$$(dir.tmp)/pre-js-$(1)-$(2).js
-endef
-# /post-js and pre-js
-########################################################################
-
 ########################################################################
 # emcc flags for .c/.o/.wasm/.js.
 emcc.flags :=
@@ -632,7 +497,6 @@ emcc.jsflags += -sLLD_REPORT_UNDEFINED
 # such constructs are found all over the place in the source code.
 ########################################################################
 
-
 ########################################################################
 # -sSINGLE_FILE:
 # https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
@@ -644,9 +508,74 @@ emcc.jsflags += -sLLD_REPORT_UNDEFINED
 # -g3 debugging info, _huge_.
 ########################################################################
 
-sqlite3.js := $(dir.dout)/sqlite3.js
-sqlite3.mjs := $(dir.dout)/sqlite3.mjs
-sqlite3-bundler-friendly.mjs := $(dir.dout)/sqlite3-bundler-friendly.mjs
+$(sqlite3-api-build-version.js): $(bin.version-info) $(MAKEFILE)
+       @echo "Making $@..."
+       @{ \
+  echo 'self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){'; \
+       echo -n '  sqlite3.version = '; \
+  $(bin.version-info) --json; \
+  echo ';'; \
+       echo '});'; \
+  } > $@
+$(sqlite3-license-version.js): $(sqlite3.h) $(sqlite3-license-version-header.js) \
+  $(MAKEFILE)
+       @echo "Making $@..."; { \
+    cat $(sqlite3-license-version-header.js); \
+    echo '/*'; \
+    echo '** This code was built from sqlite3 version...'; \
+    echo "**"; \
+    awk -e '/define SQLITE_VERSION/{$$1=""; print "**" $$0}' \
+        -e '/define SQLITE_SOURCE_ID/{$$1=""; print "**" $$0}' $(sqlite3.h); \
+    echo "**"; \
+    echo "** Using the Emscripten SDK version $(emcc.version)."; \
+    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.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): $(post-jses.js) $(MAKEFILE)
+       @echo "Making $@..."
+       @for i in $(post-jses.js); do \
+               echo "/* BEGIN FILE: $$i */"; \
+               cat $$i; \
+               echo "/* END FILE: $$i */"; \
+       done > $@
+
+
+########################################################################
+# call-make-pre-post is a $(call)able which creates rules for
+# pre-js-$(1).js. $1 = the base name of the JS file on whose behalf
+# this pre-js is for (one of: sqlite3, sqlite3-wasmfs). $2 is the build
+# mode: one of (vanilla, esm, bundler-friendly).  This sets up
+# --[extern-][pre/post]-js flags in $(pre-post-$(1).flags.$(2)) and
+# dependencies in $(pre-post-$(1).deps.$(2)).
+define call-make-pre-post
+pre-post-$(1).flags.$(2) ?=
+$$(dir.tmp)/pre-js-$(1)-$(2).js: $$(pre-js.js.$(2)) $$(MAKEFILE)
+       cp $$(pre-js.js.$(2)) $$@
+       @if [ sqlite3-wasmfs = $(1) ]; then \
+               echo "delete Module[xNameOfInstantiateWasm] /*for WASMFS build*/;"; \
+       elif [ sqlite3 != $(1) ]; then \
+               echo "Module[xNameOfInstantiateWasm].uri = '$(1).wasm';"; \
+       fi >> $$@
+pre-post-$(1).deps.$(2) := \
+  $$(pre-post-jses.deps.$(2)) \
+  $$(dir.tmp)/pre-js-$(1)-$(2).js
+pre-post-$(1).flags.$(2) += \
+  $$(pre-post-common.flags.$(2)) \
+  --pre-js=$$(dir.tmp)/pre-js-$(1)-$(2).js
+endef
+# /post-js and pre-js
+########################################################################
+
 # Undocumented Emscripten feature: if the target file extension is
 # "mjs", it defaults to ES6 module builds:
 # https://github.com/emscripten-core/emscripten/issues/14383
@@ -657,14 +586,6 @@ sqlite3-wasm.c := $(dir.api)/sqlite3-wasm.c
 # enough to the target speed requirements that the 500ms makes a
 # difference. Thus we build all binaries against sqlite3-wasm.c
 # instead of building a shared copy of sqlite3-wasm.o.
-$(eval $(call call-make-pre-js,sqlite3,vanilla))
-$(eval $(call call-make-pre-js,sqlite3,esm))
-$(eval $(call call-make-pre-js,sqlite3,bundler-friendly))
-$(sqlite3.js) $(sqlite3.mjs) $(sqlite3-bundler-friendly.mjs): \
-    $(MAKEFILE) $(sqlite3-wasm.c) $(EXPORTED_FUNCTIONS.api)
-$(sqlite3.js):  $(pre-post-sqlite3.deps.vanilla)
-$(sqlite3.mjs): $(pre-post-sqlite3.deps.esm)
-$(sqlite3-bundler-friendly.mjs): $(pre-post-sqlite3.deps.bundler-friendly)
 ########################################################################
 # SQLITE3.xJS.RECIPE = the $(call)able recipe body for $(sqlite3.js)
 # and $(sqlite3.mjs). $1 = one of (vanilla, esm). $2 must be 1 for
@@ -697,31 +618,94 @@ if [ x1 = x$(1) ]; then \
                fi; \
 fi
 endef
-define SQLITE3.xJS.RECIPE
-       @echo "Building $@ ..."
-       $(emcc.bin) -o $@ $(emcc_opt_full) $(emcc.flags) \
-    $(emcc.jsflags) \
-    $(pre-post-sqlite3.flags.$(1)) $(emcc.flags.sqlite3.$(1)) \
-    $(cflags.common) $(SQLITE_OPT) $(sqlite3-wasm.c)
-       @$(call SQLITE3.xJS.ESM-EXPORT-DEFAULT,$(2))
+
+# 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.js.in := $(dir.api)/extern-post-js.c-pp.js
+# Emscripten flags for --[extern-][pre|post]-js=... for the
+# various builds.
+pre-post-common.flags := \
+  --extern-pre-js=$(sqlite3-license-version.js)
+# pre-post-jses.deps.* = a list of dependencies for the
+# --[extern-][pre/post]-js files.
+pre-post-jses.deps.common := $(extern-pre-js.js) $(sqlite3-license-version.js)
+########################################################################
+# SETUP_LIB_BUILD_MODE is a $(call)'able which sets up numerous pieces
+# for one of the build modes (vanilla, esm, bundler-friendly).
+#
+# $1 = build mode name
+# $2 = 1 for ESM build mode, else 0
+# $3 = resulting sqlite-api JS/MJS file
+# $4 = resulting JS/MJS file
+# $5 = -D... flags for $(bin.c-pp)
+# $6 = emcc -sXYZ flags
+define SETUP_LIB_BUILD_MODE
+$(info Setting up build [$(1)]: $(4))
+c-pp.D.$(1) := $(5)
+pre-js.js.$(1) := $$(dir.api)/pre-js.$(1).js
+$$(eval $$(call C-PP.FILTER,$$(pre-js.js.in),$$(pre-js.js.$(1)),$$(c-pp.D.$(1))))
+post-js.js.$(1) := $$(dir.tmp)/post-js.$(1).js
+$$(eval $$(call C-PP.FILTER,$$(post-js.js.in),$$(post-js.js.$(1)),$$(c-pp.D.$(1))))
+extern-post-js.js.$(1) := $$(dir.tmp)/extern-post-js.$(1).js
+$$(eval $$(call C-PP.FILTER,$$(extern-post-js.js.in),$$(extern-post-js.js.$(1)),$$(c-pp.D.$(1))))
+pre-post-common.flags.$(1) := \
+  $$(pre-post-common.flags) \
+  --post-js=$$(post-js.js.$(1)) \
+  --extern-post-js=$$(extern-post-js.js.$(1))
+pre-post-jses.deps.$(1) := $$(pre-post-jses.deps.common) \
+  $$(post-js.js.$(1)) $$(extern-post-js.js.$(1))
+$$(eval $$(call call-make-pre-post,sqlite3,$(1)))
+emcc.flags.sqlite3.$(1) := $(6)
+$$(eval $$(call C-PP.FILTER, $$(sqlite3-api.js.in), $(3), $(5)))
+$(4): $(3)
+$(4): $(3) $$(MAKEFILE) $$(sqlite3-wasm.c) $$(EXPORTED_FUNCTIONS.api) $$(pre-post-sqlite3.deps.$(1))
+       @echo "Building $$@ ..."
+       $$(emcc.bin) -o $$@ $$(emcc_opt_full) $$(emcc.flags) \
+    $$(emcc.jsflags) \
+    $$(pre-post-sqlite3.flags.$(1)) $$(emcc.flags.sqlite3.$(1)) \
+    $$(cflags.common) $$(SQLITE_OPT) $$(sqlite3-wasm.c)
+       @$$(call SQLITE3.xJS.ESM-EXPORT-DEFAULT,$(2))
        @if [ bundler-friendly = $(1) ]; then \
-               echo "Patching sqlite3-bundler-friendly.js for sqlite3.wasm..."; \
-               rm -f $(dir.dout)/sqlite3-bundler-friendly.wasm; \
-               sed -i -e 's/sqlite3-bundler-friendly.wasm/sqlite3.wasm/g' $@ || exit $$?; \
+               echo "Patching $(3) for sqlite3.wasm..."; \
+               rm -f $$(dir.dout)/sqlite3-bundler-friendly.wasm; \
+               sed -i -e 's/sqlite3-bundler-friendly.wasm/sqlite3.wasm/g' $$@ || exit $$$$?; \
        fi
-       chmod -x $(sqlite3.wasm)
-       $(maybe-wasm-strip) $(sqlite3.wasm)
-       @ls -la $@ $(sqlite3.wasm)
+       chmod -x $$(sqlite3.wasm)
+       $$(maybe-wasm-strip) $$(sqlite3.wasm)
+       @ls -la $@ $$(sqlite3.wasm)
+all: $(4)
+quick: $(4)
+CLEAN_FILES += $(3) $(4)
 endef
-emcc.flags.sqlite3.vanilla :=
-emcc.flags.sqlite3.esm := -sEXPORT_ES6 -sUSE_ES6_IMPORT_META
-emcc.flags.sqlite3.bundler-friendly := $(emcc.flags.sqlite3.esm)
-$(sqlite3.js):
-       $(call SQLITE3.xJS.RECIPE,vanilla,0)
-$(sqlite3.mjs):
-       $(call SQLITE3.xJS.RECIPE,esm,1)
-$(sqlite3-bundler-friendly.mjs):
-       $(call SQLITE3.xJS.RECIPE,bundler-friendly,1)
+# ^^^ /SETUP_LIB_BUILD_MODE
+########################################################################
+sqlite3-api.js := $(dir.dout)/sqlite3-api.js
+sqlite3.js := $(dir.dout)/sqlite3.js
+sqlite3-api.mjs := $(dir.dout)/sqlite3-api.mjs
+sqlite3.mjs := $(dir.dout)/sqlite3.mjs
+sqlite3-api-bundler-friendly.mjs := $(dir.dout)/sqlite3-api-bundler-friendly.mjs
+sqlite3-bundler-friendly.mjs := $(dir.dout)/sqlite3-bundler-friendly.mjs
+# Maintenance reminder: careful not to introduce spaces around args $1, $2
+#$(info $(call SETUP_LIB_BUILD_MODE,vanilla,0, $(sqlite3-api.js), $(sqlite3.js)))
+$(eval $(call SETUP_LIB_BUILD_MODE,vanilla,0, $(sqlite3-api.js), $(sqlite3.js)))
+$(eval $(call SETUP_LIB_BUILD_MODE,esm,1, $(sqlite3-api.mjs), $(sqlite3.mjs), \
+       -Dtarget=es6-module, -sEXPORT_ES6 -sUSE_ES6_IMPORT_META))
+$(eval $(call SETUP_LIB_BUILD_MODE,bundler-friendly,1,\
+       $(sqlite3-api-bundler-friendly.mjs),$(sqlite3-bundler-friendly.mjs),\
+       $(c-pp.D.esm) -Dtarget=es6-bundler-friendly, $(emcc.flags.sqlite3.esm)))
+# The various -D... values used by *.c-pp.js include:
+#
+# -Dtarget=es6-module: for all ESM module builds
+#
+# -Dtarget=es6-module -Dtarget=es6-bundler-friendly: intended for
+#    "bundler-friendly" ESM module build. These have some restrictions
+#    on how URL() objects are constructed in some contexts: URLs which
+#    refer to files which are part of this project must be references
+#    as string literals so that bundlers' static-analysis tools can
+#    find those files and include them in their bundles.
+#
+########################################################################
 ########################################################################
 # We have to ensure that we do not build both $(sqlite3.js) and
 # $(sqlite3.mjs) in parallel because both result in the creation of
@@ -734,14 +718,7 @@ $(sqlite3.mjs): $(sqlite3.js)
 $(sqlite3-bundler-friendly.mjs): $(sqlite3.mjs)
 # maintenance reminder: the deps on ^^^ must all be such that they are
 # never built in parallel.
-CLEAN_FILES += $(sqlite3.js) $(sqlite3.mjs) $(sqlite3-bundler-friendly.mjs) \
-    $(sqlite3.wasm)
-all: $(sqlite3.js) $(sqlite3.mjs) $(sqlite3-bundler-friendly.mjs)
-quick: $(sqlite3.js)
-quick: $(sqlite3.mjs) # for the sake of the snapshot build
-quick: $(sqlite3-bundler-friendly.mjs) # for the sake of the snapshot build
-# End main $(sqlite3.js) build
-########################################################################
+CLEAN_FILES += $(sqlite3.wasm)
 
 ########################################################################
 # batch-runner.js is part of one of the test apps which reads in SQL
@@ -818,7 +795,7 @@ speedtest1.js := $(dir.dout)/speedtest1.js
 speedtest1.wasm := $(dir.dout)/speedtest1.wasm
 cflags.speedtest1 := $(cflags.common) -DSQLITE_SPEEDTEST1_WASM
 speedtest1.cses := $(speedtest1.c) $(sqlite3-wasm.c)
-$(eval $(call call-make-pre-js,speedtest1,vanilla))
+$(eval $(call call-make-pre-post,speedtest1,vanilla))
 $(speedtest1.js): $(MAKEFILE) $(speedtest1.cses) \
     $(pre-post-speedtest1.deps.vanilla) \
     $(EXPORTED_FUNCTIONS.speedtest1)
index dba0c8dd5806beb846365bdbe467ba61692434f3..723b0f765de73f87c2e006145b3331a0ef5e80d8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enhance\soo1.DB.exec()\sto\ssimplify\sreturning\swhole\sresult\ssets.
-D 2023-01-28T05:09:26.765
+C Overhaul\sext/wasm/GNUmakefile\sto\sconsolidate\swhat\samounts\sto\smuch\scopy/paste/slightly-edit\sduplication\sinto\sa\ssingle\sfunction,\scalled\sonce\sper\sdistinctive\sbuild\smode\s(vanilla,\sESM,\sbundler-friendly).
+D 2023-01-28T09:11:08.421
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -466,7 +466,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3
 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04
 F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb
 F ext/wasm/EXPORTED_FUNCTIONS.fiddle.in 27450c8b8c70875a260aca55435ec927068b34cef801a96205adb81bdcefc65c
-F ext/wasm/GNUmakefile 8d82b51a23f9c84c770abd72f18d95a95044a03a216e0246ebd1b3668619c77e
+F ext/wasm/GNUmakefile a32c527fb162489266c11cfbb3f0d02e9140c3e88ce884cdc1a8a79477b3cf06
 F ext/wasm/README-dist.txt 4a1db3677d0341a12434d1fd6c97aae2f96785d734641407a201b719f5d94f44
 F ext/wasm/README.md ef39861aa21632fdbca0bdd469f78f0096f6449a720f3f39642594af503030e9
 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api d6a5078f48a5301ed17b9a30331075d9b2506e1360c1f0dee0c7816c10acd9ab
@@ -2044,8 +2044,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 24d3a53dea5e596230558e233cbbd9d0288b4c394cd5ea7b650fd99bff4cde2e
-R 32ae67991ccd2fab1735177a69f90f3b
+P 7b168ee2af09f04b41a6ef4c14ccaddc0c9b0bfe9dc1e6a86d8f5317606bd78d
+R 89098a85baa5f167018e750de6e19924
 U stephan
-Z eea3cf1aefbfbb83af8cc08b772c2cf0
+Z 698b42e1629b67c07c9d270103d0775e
 # Remove this line to create a well-formed Fossil manifest.
index ccd158bf8605be49920efd9a5c9abf4ac169c43c..a7acc799ab8d5cd6a1abfbe2fa34abccf6e070a2 100644 (file)
@@ -1 +1 @@
-7b168ee2af09f04b41a6ef4c14ccaddc0c9b0bfe9dc1e6a86d8f5317606bd78d
\ No newline at end of file
+168e5a93013d8650c180e19788e5f301b5d5ae8501d0ce728004fd750ca9e682
\ No newline at end of file