]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
WASM: various build cleanups and add initial infrastructure for a build which elides...
authorstephan <stephan@noemail.net>
Mon, 1 Jan 2024 05:58:47 +0000 (05:58 +0000)
committerstephan <stephan@noemail.net>
Mon, 1 Jan 2024 05:58:47 +0000 (05:58 +0000)
FossilOrigin-Name: 563d313163c02b398ae85b7c2ed231019a14e006726f09a7c1f294a58bf4363f

ext/wasm/GNUmakefile
ext/wasm/api/sqlite3-api-oo1.js
ext/wasm/api/sqlite3-api-worker1.js
ext/wasm/api/sqlite3-worker1-promiser.c-pp.js
ext/wasm/api/sqlite3-worker1.c-pp.js
manifest
manifest.uuid

index 0510af74abb8d48e68d181e8effabbc1ffc3dc5b..94eff4cc327825b4c48a62175ea8c72584cf34c3 100644 (file)
@@ -54,6 +54,9 @@ release: oz
 # JS_BUILD_MODES exists solely to reduce repetition in documentation
 # below.
 JS_BUILD_MODES := vanilla esm bunder-friendly node
+# JS_BUILD_NAMES exists solely to reduce repetition in documentation
+# below.
+JS_BUILD_NAMES := sqlite3 sqlite3-wasmfs
 # Emscripten SDK home dir and related binaries...
 EMSDK_HOME ?= $(word 1,$(wildcard $(HOME)/emsdk $(HOME)/src/emsdk))
 emcc.bin ?= $(word 1,$(wildcard $(EMSDK_HOME)/upstream/emscripten/emcc) $(shell which emcc))
@@ -287,6 +290,9 @@ DISTCLEAN_FILES += $(bin.stripccomments)
 # c-pp.c was written specifically for the sqlite project's JavaScript
 # 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.
 bin.c-pp := ./c-pp
 $(bin.c-pp): c-pp.c $(sqlite3.c) $(MAKEFILE)
        $(CC) -O0 -o $@ c-pp.c $(sqlite3.c) '-DCMPP_DEFAULT_DELIM="//#"' -I$(dir.top) \
@@ -518,13 +524,14 @@ emcc.jsflags += -sSTACK_SIZE=512KB
 # extern-post-js.js. However...  using a temporary symbol name here
 # and then adding sqlite3InitModule() ourselves results in 2 global
 # symbols: we cannot "delete" the Emscripten-defined
-# $(sqlite3.js.init-func) because it's declared with "var".
+# $(sqlite3.js.init-func) from vanilla builds (as opposed to ESM
+# builds) because it's declared with "var".
 sqlite3.js.init-func := sqlite3InitModule
 emcc.jsflags += -sEXPORT_NAME=$(sqlite3.js.init-func)
 emcc.jsflags += -sGLOBAL_BASE=4096 # HYPOTHETICALLY keep func table indexes from overlapping w/ heap addr.
 #emcc.jsflags += -sSTRICT # fails due to missing __syscall_...()
 #emcc.jsflags += -sALLOW_UNIMPLEMENTED_SYSCALLS
-#emcc.jsflags += -sFILESYSTEM=0 # only for experimentation. sqlite3 needs the FS API
+#emcc.jsflags += -sFILESYSTEM=0 # only for experimentation. fiddle needs the FS API
 #emcc.jsflags += -sABORTING_MALLOC # only for experimentation
 emcc.jsflags += -sALLOW_TABLE_GROWTH
 # ^^^^ -sALLOW_TABLE_GROWTH is required for installing new SQL UDFs
@@ -568,15 +575,20 @@ emcc.jsflags += -sLLD_REPORT_UNDEFINED
 # -g3 debugging info, _huge_.
 ########################################################################
 
+# $(sqlite3-api-build-version.js) injects the build version info into
+# the bundle.
 $(sqlite3-api-build-version.js): $(bin.version-info) $(MAKEFILE)
        @echo "Making $@..."
        @{ \
-  echo 'globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){'; \
-       echo -n '  sqlite3.version = '; \
-  $(bin.version-info) --json; \
-  echo ';'; \
-       echo '});'; \
+    echo 'globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){'; \
+    echo -n '  sqlite3.version = '; \
+    $(bin.version-info) --json; \
+    echo ';'; \
+    echo '});'; \
   } > $@
+
+# $(sqlite3-license-version.js) contains the license header and build
+# version info.
 $(sqlite3-license-version.js): $(sqlite3.h) $(sqlite3-license-version-header.js) \
   $(MAKEFILE)
        @echo "Making $@..."; { \
@@ -594,7 +606,11 @@ $(sqlite3-license-version.js): $(sqlite3.h) $(sqlite3-license-version-header.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/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 := \
@@ -612,18 +628,26 @@ $(post-js.js.in): $(post-jses.js) $(MAKEFILE)
 
 ########################################################################
 # call-make-pre-post is a $(call)able which creates rules for
-# pre-js-$(1)-$(2).js. $1 = the base name of the JS file on whose
-# behalf this pre-js is for (one of: sqlite3, sqlite3-wasmfs). $2 is
+# pre-js.$(1)-$(2).js. $1 = the base name of the JS file on whose
+# behalf this pre-js is for (one of: $(JS_BUILD_NAMES)). $2 is
 # the build mode: one of $(JS_BUILD_MODES).  This sets up
 # --[extern-][pre/post]-js flags in $(pre-post-$(1)-$(2).flags) and
 # dependencies in $(pre-post-$(1)-$(2).deps). The resulting files get
 # filtered using $(C-PP.FILTER). Any flags necessary for such
 # filtering need to be set in $(c-pp.D.$(1)-$(2)) before $(call)ing
 # this.
+#
+# Maintenance note: a shell script was written to generate these rules
+# with the hope that it would make them more legible and maintainable,
+# but embedding makefile code in another language makes it even less
+# legible than having the level of $(eval) indirection which we have
+# here.
 define call-make-pre-post
 pre-post-$(1)-$(2).flags ?=
-pre-js.js.$(1)-$(2) := $$(dir.tmp)/pre-js.$(1)-$(2).intermediary.js
-$$(eval $$(call C-PP.FILTER,$$(pre-js.js.in),$$(pre-js.js.$(1)-$(2)),$$(c-pp.D.$(1)-$(2))))
+pre-js.js.$(1)-$(2).intermediary := $$(dir.tmp)/pre-js.$(1)-$(2).intermediary.js
+pre-js.js.$(1)-$(2) := $$(dir.tmp)/pre-js.$(1)-$(2).js
+#$$(error $$(pre-js.js.$(1)-$(2).intermediary) $$(pre-js.js.$(1)-$(2)))
+$$(eval $$(call C-PP.FILTER,$$(pre-js.js.in),$$(pre-js.js.$(1)-$(2).intermediary),$$(c-pp.D.$(1)-$(2))))
 post-js.js.$(1)-$(2) := $$(dir.tmp)/post-js.$(1)-$(2).js
 $$(eval $$(call C-PP.FILTER,$$(post-js.js.in),$$(post-js.js.$(1)-$(2)),$$(c-pp.D.$(1)-$(2))))
 extern-post-js.js.$(1)-$(2) := $$(dir.tmp)/extern-post-js.$(1)-$(2).js
@@ -634,8 +658,8 @@ pre-post-common.flags.$(1)-$(2) := \
   --extern-post-js=$$(extern-post-js.js.$(1)-$(2))
 pre-post-jses.$(1)-$(2).deps := $$(pre-post-jses.deps.common) \
   $$(post-js.js.$(1)-$(2)) $$(extern-post-js.js.$(1)-$(2))
-$$(dir.tmp)/pre-js-$(1)-$(2).js: $$(pre-js.js.$(1)-$(2)) $$(MAKEFILE)
-       cp $$(pre-js.js.$(1)-$(2)) $$@
+$$(pre-js.js.$(1)-$(2)): $$(pre-js.js.$(1)-$(2).intermediary) $$(MAKEFILE)
+       cp $$(pre-js.js.$(1)-$(2).intermediary) $$@
        @if [ sqlite3-wasmfs = $(1) ]; then \
                echo "delete Module[xNameOfInstantiateWasm] /*for WASMFS build*/;"; \
        elif [ sqlite3 != $(1) ]; then \
@@ -643,10 +667,10 @@ $$(dir.tmp)/pre-js-$(1)-$(2).js: $$(pre-js.js.$(1)-$(2)) $$(MAKEFILE)
        fi >> $$@
 pre-post-$(1)-$(2).deps := \
   $$(pre-post-jses.$(1)-$(2).deps) \
-  $$(dir.tmp)/pre-js-$(1)-$(2).js
+  $$(dir.tmp)/pre-js.$(1)-$(2).js
 pre-post-$(1)-$(2).flags += \
   $$(pre-post-common.flags.$(1)-$(2)) \
-  --pre-js=$$(dir.tmp)/pre-js-$(1)-$(2).js
+  --pre-js=$$(dir.tmp)/pre-js.$(1)-$(2).js
 endef
 # /post-js and pre-js
 ########################################################################
@@ -715,7 +739,7 @@ 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.
 #
-# $1 = one of: sqlite3, sqlite3-wasmfs
+# $1 = one of: $(JS_BUILD_NAMES)
 # $2 = build mode name: one of $(JS_BUILD_MODES)
 # $3 = 1 for ESM build mode, else 0
 # $4 = resulting sqlite-api JS/MJS file
@@ -781,8 +805,7 @@ sqlite3-node.mjs := $(dir.dout)/sqlite3-node.mjs
 $(eval $(call SETUP_LIB_BUILD_MODE,sqlite3,vanilla,0,\
          $(sqlite3-api.js), $(sqlite3.js)))
 $(eval $(call SETUP_LIB_BUILD_MODE,sqlite3,esm,1,\
-         $(sqlite3-api.mjs), $(sqlite3.mjs), \
-       -Dtarget=es6-module, -sEXPORT_ES6 -sUSE_ES6_IMPORT_META))
+         $(sqlite3-api.mjs), $(sqlite3.mjs), -Dtarget=es6-module))
 $(eval $(call SETUP_LIB_BUILD_MODE,sqlite3,bundler-friendly,1,\
        $(sqlite3-api-bundler-friendly.mjs),$(sqlite3-bundler-friendly.mjs),\
        $(c-pp.D.sqlite3-esm) -Dtarget=es6-bundler-friendly))
index 4677b897620a7106447b6c404f437b5875676d22..160d59db5ae527e30286a2c5e374f8821300c939 100644 (file)
@@ -1,3 +1,4 @@
+//#ifnot omit-oo1
 /*
   2022-07-22
 
@@ -1940,4 +1941,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
   }/*main-window-only bits*/
 
 });
-
+//#else
+/* Built with the omit-oo1 flag. */
+//#endif ifnot omit-oo1
index 7c65dd1d3e8695061317d447d4dfb4cb054c9383..3099c19ec47fea389bfe6689d5aa4a273eba85d6 100644 (file)
@@ -1,3 +1,4 @@
+//#ifnot omit-oo1
 /**
   2022-07-22
 
@@ -689,3 +690,6 @@ sqlite3.initWorker1API = function(){
   globalThis.postMessage({type:'sqlite3-api',result:'worker1-ready'});
 }.bind({sqlite3});
 });
+//#else
+/* Built with the omit-oo1 flag. */
+//#endif ifnot omit-oo1
index d4445cdcdf2e742a445728a60a8cd1338ff44656..cd78ed4bcf39854b709ec410a06779c7684fad46 100644 (file)
@@ -1,3 +1,4 @@
+//#ifnot omit-oo1
 /*
   2022-08-24
 
@@ -276,3 +277,6 @@ globalThis.sqlite3Worker1Promiser.defaultConfig = {
   ,
   onerror: (...args)=>console.error('worker1 promiser error',...args)
 };
+//#else
+/* Built with the omit-oo1 flag. */
+//#endif ifnot omit-oo1
index 220722ffe13a413742a52eda75d890b371c738ea..74de9ec7ef19df9b0b62505db19801d460f20f62 100644 (file)
@@ -1,3 +1,4 @@
+//#ifnot omit-oo1
 /*
   2022-05-23
 
@@ -48,3 +49,6 @@ import {default as sqlite3InitModule} from './sqlite3-bundler-friendly.mjs';
 }
 //#endif
 sqlite3InitModule().then(sqlite3 => sqlite3.initWorker1API());
+//#else
+/* Built with the omit-oo1 flag. */
+//#endif ifnot omit-oo1
index cdba3da23184c13f1aed82fd4deb99cadcf6479f..579bc6df6d464cbb7b4879793aaab22d55d304e8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Use\sSQLITE_ENABLE_STAT4\sin\sboth\sthe\sWASM\sand\sJNI\sbuilds.
-D 2023-12-31T04:01:36.325
+C WASM:\svarious\sbuild\scleanups\sand\sadd\sinitial\sinfrastructure\sfor\sa\sbuild\swhich\selides\sthe\soo1\sAPI\sand\sits\sdependents\s(worker1\sand\spromiser).\sSidebar:\san\sattempt\swas\smade\sto\smove\sgeneration\sof\sthe\sbuild\srules\sto\san\sexternal\sscript,\sbut\sthe\smixed-mode\smake/script\swas\seven\sless\slegible\sthan\sthe\s$(eval)\sindirection\sgoing\son\sin\sthe\smakefile.
+D 2024-01-01T05:58:47.485
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -575,7 +575,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 62403519b233dbe23e1cac30969714c4043a96c5bc2614e551a07a81c543c493
+F ext/wasm/GNUmakefile a8a171af359b9acee604bb01229f59052b8b38c43f6020a6d009e42c76f910af
 F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576
 F ext/wasm/README.md a8a2962c3aebdf8d2104a9102e336c5554e78fc6072746e5daf9c61514e7d193
 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff
@@ -594,17 +594,17 @@ F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b
 F ext/wasm/api/pre-js.c-pp.js ad906703f7429590f2fbf5e6498513bf727a1a4f0ebfa057afb08161d7511219
 F ext/wasm/api/sqlite3-api-cleanup.js d235ad237df6954145404305040991c72ef8b1881715d2a650dda7b3c2576d0e
 F ext/wasm/api/sqlite3-api-glue.js 119b91c8a7ce6648679eb66fcdd1ed07ef7fd892eb501d658fbfefcc962012d9
-F ext/wasm/api/sqlite3-api-oo1.js 9678dc4d9a5d39632b6ffe6ea94a023119260815bf32f265bf5f6c36c9516db8
+F ext/wasm/api/sqlite3-api-oo1.js 7f3bcf0549ac44cde4b9da0b642d771916738d3f6781fb8a1757c50a91e506c0
 F ext/wasm/api/sqlite3-api-prologue.js 9aeba7b45cf41b3a26d34d7fb2525633cd1adfc544888c1ea8dbb077496f4ce9
-F ext/wasm/api/sqlite3-api-worker1.js 88770ac01fc756f89a3e060eec17111d6c1688e89ebfd34cb9d9e54d25affbb9
+F ext/wasm/api/sqlite3-api-worker1.js fd46628ef147dd5856c88f63a9a279a40f744f1fdfddd55251ad8fbc3d8200ae
 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89
 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379
 F ext/wasm/api/sqlite3-v-helper.js 7daa0eab0a513a25b05e9abae7b5beaaa39209b3ed12f86aeae9ef8d2719ed25
 F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 595953994aa3ae2287c889c4da39ab3d6f17b6461ecf4bec334b7a3faafddb02
 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 46c4afa6c50d7369252c104f274ad977a97e91ccfafc38b400fe36e90bdda88e
 F ext/wasm/api/sqlite3-wasm.c dbaefda7981050bf9eb413f5b24df648ead09d9a3e796f9ba84d87cb49b5ab80
-F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js a94e3f0ca25a777bb73779368f97be0e103e02d067ad3ee3e9c4cc5bcefbd01c
-F ext/wasm/api/sqlite3-worker1.c-pp.js a541112aa51e16705f13a99bb943c64efe178aa28c86704a955f8fd9afe4ba37
+F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js f234191fe6bf41a5a1e59c9f43ed816e74a522b3d60d3f556f66c3085c448503
+F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5
 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7
 F ext/wasm/batch-runner-sahpool.js 54a3ac228e6c4703fe72fb65c897e19156263a51fe9b7e21d2834a45e876aabd
 F ext/wasm/batch-runner.html 4deeed44fe41496dc6898d9fb17938ea3291f40f4bfb977e29d0cef96fbbe4c8
@@ -2156,8 +2156,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 8d2120c35425081e2158d6a8a6b083c4adf8d694046b2d98f5fd235520920432
-R 0fc8decc05e314121b9845282e3b044a
+P 99d11e6d0ae687ff6bac5119027f7b04d5e7185214e79cf8c56289cfa809b0f9
+R f12f6c5bbcd045460cf7bd0ad6d9cb62
 U stephan
-Z c3f0712f8c19c3c3ba1e6e96354954de
+Z 65fba1a0552f62ac5813e31c03da0bea
 # Remove this line to create a well-formed Fossil manifest.
index 3cf768fb4e5840088175f361a0975f85f3ac3f43..99bdacd567378050676a285fc222e7133f845f9e 100644 (file)
@@ -1 +1 @@
-99d11e6d0ae687ff6bac5119027f7b04d5e7185214e79cf8c56289cfa809b0f9
\ No newline at end of file
+563d313163c02b398ae85b7c2ed231019a14e006726f09a7c1f294a58bf4363f
\ No newline at end of file