From: stephan Date: Wed, 19 Oct 2022 06:06:42 +0000 (+0000) Subject: Update the dist rules for this evening's js/wasm build changes and include an index... X-Git-Tag: version-3.40.0~138 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3117dc60e30dc65455f23c0e7e4230dc6c635ae1;p=thirdparty%2Fsqlite.git Update the dist rules for this evening's js/wasm build changes and include an index.html specifically for the subset of apps included in the dist archive. FossilOrigin-Name: a0ef0f32e96638b502b3951e524d590bdfb09dd39be453686b075102da67b7db --- diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index f364e446bc..fdf1332e5c 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -185,17 +185,17 @@ else $(info Development build. Use '$(MAKE) release' for a smaller release build.) endif -version-info := $(dir.wasm)/version-info +bin.version-info := $(dir.wasm)/bin.version-info # ^^^^ NOT in $(dir.tmp) because we need it to survive the cleanup # process for the dist build to work properly. -$(version-info): $(dir.wasm)/version-info.c $(sqlite3.h) $(MAKEFILE) +$(bin.version-info): $(dir.wasm)/version-info.c $(sqlite3.h) $(MAKEFILE) $(CC) -O0 -I$(dir.top) -o $@ $< -DISTCLEAN_FILES += $(version-info) +DISTCLEAN_FILES += $(bin.version-info) -stripccomments := $(dir.tool)/stripccomments -$(stripccomments): $(stripccomments).c $(MAKEFILE) +bin.stripccomments := $(dir.tool)/stripccomments +$(bin.stripccomments): $(bin.stripccomments).c $(MAKEFILE) $(CC) -o $@ $< -DISTCLEAN_FILES += $(stripccomments) +DISTCLEAN_FILES += $(bin.stripccomments) EXPORTED_FUNCTIONS.api.in := $(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-api) EXPORTED_FUNCTIONS.api := $(dir.tmp)/EXPORTED_FUNCTIONS.api @@ -241,12 +241,12 @@ $(sqlite3-api.js): $(sqlite3-api.jses) $(MAKEFILE) echo "/* END FILE: $$i */"; \ done > $@ -$(sqlite3-api-build-version.js): $(version-info) $(MAKEFILE) +$(sqlite3-api-build-version.js): $(bin.version-info) $(MAKEFILE) @echo "Making $@..." @{ \ echo 'self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){'; \ echo -n ' sqlite3.version = '; \ - $(version-info) --json; \ + $(bin.version-info) --json; \ echo ';'; \ echo '});'; \ } > $@ @@ -543,7 +543,7 @@ o-xtra := -flto # doubles the build time and seems to have negligible effect on # higher optimization levels. o0: clean - $(MAKE) -e "emcc_opt=-O0 $(o-xtra)" + $(MAKE) -e "emcc_opt=-O0" o1: clean $(MAKE) -e "emcc_opt=-O1 $(o-xtra)" o2: clean diff --git a/ext/wasm/README-dist.txt b/ext/wasm/README-dist.txt index 422f3f1e0c..c6fb2c5d1a 100644 --- a/ext/wasm/README-dist.txt +++ b/ext/wasm/README-dist.txt @@ -7,18 +7,17 @@ TODO: link to main WASM/JS docs, once they are online This archive contains the sqlite3.js and sqlite3.wasm file which make up the sqlite3 WASM/JS build. -The jswasm directory contains both the main deliverables and small -demonstration and test apps. Browsers will not serve WASM files from -file:// URLs, so the demo/test apps require a web server and that -server must include the following headers in its response when serving -the files: +The jswasm directory contains the core sqlite3 deliverables and the +top-level directory contains demonstration and test apps. Browsers +will not serve WASM files from file:// URLs, so the demo/test apps +require a web server and that server must include the following +headers in its response when serving the files: Cross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corp -The files named sqlite3*.js and sqlite3.wasm belong to the core -sqlite3 deliverables and the others are soley for demonstration and -may be discarded. They are not in separate directories from the main -deliverables because a quirk of URI resolution in JS code would then -require that sqlite3.js be duplicated and edited for Worker-loaded -operation. +One simple way to get the demo apps up and running on Unix-style +systems is to install althttpd (https://sqlite.org/althttpd) and run: + + althttpd --enable-sab --page index.html + diff --git a/ext/wasm/api/README.md b/ext/wasm/api/README.md index dfb13c569f..6440eba996 100644 --- a/ext/wasm/api/README.md +++ b/ext/wasm/api/README.md @@ -64,12 +64,12 @@ browser client: thread via the Worker message-passing interface. Like OO API #1, this is an optional component, offering one of any number of potential implementations for such an API. - - `../sqlite3-worker1.js`\ + - `sqlite3-worker1.js`\ Is not part of the amalgamated sources and is intended to be loaded by a client Worker thread. It loads the sqlite3 module and runs the Worker #1 API which is implemented in `sqlite3-api-worker1.js`. - - `../sqlite3-worker1-promiser.js`\ + - `sqlite3-worker1-promiser.js`\ Is likewise not part of the amalgamated sources and provides a Promise-based interface into the Worker #1 API. This is a far user-friendlier way to interface with databases running @@ -78,7 +78,7 @@ browser client: is an sqlite3 VFS implementation which supports Google Chrome's Origin-Private FileSystem (OPFS) as a storage layer to provide persistent storage for database files in a browser. It requires... - - `../sqlite3-opfs-async-proxy.js`\ + - `sqlite3-opfs-async-proxy.js`\ is the asynchronous backend part of the OPFS proxy. It speaks directly to the (async) OPFS API and channels those results back to its synchronous counterpart. This file, because it must be diff --git a/ext/wasm/dist.make b/ext/wasm/dist.make index e19b361b19..13cab87669 100644 --- a/ext/wasm/dist.make +++ b/ext/wasm/dist.make @@ -10,14 +10,11 @@ MAKEFILE.dist := $(lastword $(MAKEFILE_LIST)) ######################################################################## -# Chicken/egg situation: we need $(version-info) to get the version +# Chicken/egg situation: we need $(bin.version-info) to get the version # info for the archive name, but that binary may not yet be built, and # won't be built until we expand the dependencies. We have to use a # temporary name for the archive. dist-name = sqlite-wasm-TEMP -dist-archive = $(dist-name).zip -.PHONY: $(dist-archive) -CLEAN_FILES += $(wildcard sqlite-wasm-*.zip) #ifeq (0,1) # $(info WARNING *******************************************************************) # $(info ** Be sure to create the desired build configuration before creating the) @@ -40,52 +37,58 @@ CLEAN_FILES += $(wildcard sqlite-wasm-*.zip) # date. dist-build ?= oz -demo-123.html := $(dir.wasm)/demo-123.html -demo-123-worker.html := $(dir.wasm)/demo-123-worker.html -demo-123.js := $(dir.wasm)/demo-123.js -demo-files := $(demo-123.js) $(demo-123.html) $(demo-123-worker.html) \ - tester1.html tester1.js tester1-worker.html -README-dist := $(dir.wasm)/README-dist.txt -dist-dir-main := $(dist-name)/jswasm -dist.main.extras := \ - sqlite3-opfs-async-proxy.js \ - sqlite3-worker1.js \ - sqlite3-worker1-promiser.js +dist-dir.top := $(dist-name) +dist-dir.jswasm := $(dist-dir.top)/$(notdir $(dir.dout)) +dist-dir.common := $(dist-dir.top)/common +dist.top.extras := \ + demo-123.html demo-123-worker.html demo-123.js \ + tester1.html tester1-worker.html tester1.js +dist.jswasm.extras := $(sqlite3-api.ext.jses) $(sqlite3.wasm) +dist.common.extras := $(wildcard $(dir.common)/*.css) +.PHONY: dist ######################################################################## -# $(dist-archive): create the end-user deliverable archive. +# dist: create the end-user deliverable archive. # -# Maintenance reminder: because $(dist-archive) depends on -# $(dist-build), and $(dist-build) will depend on clean, having any deps -# on $(dist-archive) which themselves may be cleaned up by the clean +# Maintenance reminder: because dist depends on $(dist-build), and +# $(dist-build) will depend on clean, having any deps on +# $(dist-archive) which themselves may be cleaned up by the clean # target will lead to grief in parallel builds (-j #). Thus # $(dist-target)'s deps must be trimmed to non-generated files or # files which are _not_ cleaned up by the clean target. -$(dist-archive): \ - $(stripccomments) $(version-info) \ +# +# Note that we require $(bin.version-info) in order to figure out the +# dist file's name, so cannot (without a recursive make) have the +# target name equal to the archive name. +dist: \ + $(bin.stripccomments) $(bin.version-info) \ $(dist-build) \ $(MAKEFILE) $(MAKEFILE.dist) @echo "Making end-user deliverables..." - @rm -fr $(dist-name) - @mkdir -p $(dist-dir-main) - @cp -p $(README-dist) $(dist-name)/README.txt - @cp -p $(sqlite3.wasm) $(dist.main.extras) $(dist-dir-main) - @$(stripccomments) -k -k < $(sqlite3.js) \ - > $(dist-dir-main)/$(notdir $(sqlite3.js)) - @cp -p $(demo-files) $(dist-dir-main) - @vnum=$$($(version-info) --version-number); \ - vdir=sqlite-wasm-$$vnum; \ - arc=$$vdir.zip; \ - echo "Making $$arc ..."; \ - rm -f $$arc; \ - mv $(dist-name) $$vdir; \ - zip -qr $$arc $$vdir; \ - rm -fr $$vdir; \ - ls -la $$arc; \ - unzip -lv $$arc || echo "Missing unzip app? Not fatal." + @rm -fr $(dist-dir.top) + @mkdir -p $(dist-dir.jswasm) $(dist-dir.common) + @cp -p $(dist.top.extras) $(dist-dir.top) + @cp -p README-dist.txt $(dist-dir.top)/README.txt + @cp -p index-dist.html $(dist-dir.top)/index.html + @cp -p $(dist.jswasm.extras) $(dist-dir.jswasm) + @$(bin.stripccomments) -k -k < $(sqlite3.js) \ + > $(dist-dir.jswasm)/$(notdir $(sqlite3.js)) + @cp -p $(dist.common.extras) $(dist-dir.common) + @vnum=$$($(bin.version-info) --version-number); \ + vdir=sqlite-wasm-$$vnum; \ + arczip=$$vdir.zip; \ + echo "Making $$arczip ..."; \ + rm -f $$arczip; \ + mv $(dist-dir.top) $$vdir; \ + zip -qr $$arczip $$vdir; \ + rm -fr $$vdir; \ + ls -la $$arczip; \ + unzip -lv $$arczip || echo "Missing unzip app? Not fatal." -#$(shell $(version-info) --version-number) -dist: $(dist-archive) -clean-dist: - rm -f $(dist-archive) -clean: clean-dist +# We need a separate `clean` rule to account for weirdness in +# a sub-make, where we get a copy of the $(dist-name) dir +# copied into the new $(dist-name) dir. +.PHONY: dist-clean +clean: dist-clean +dist-clean: + rm -fr $(dist-name) $(wildcard sqlite-wasm-*.zip) diff --git a/ext/wasm/index-dist.html b/ext/wasm/index-dist.html new file mode 100644 index 0000000000..ffb3127761 --- /dev/null +++ b/ext/wasm/index-dist.html @@ -0,0 +1,82 @@ + + + + + + + sqlite3 WASM Demo Page Index + + + +
sqlite3 WASM demo pages
+
+
Below is the list of demo pages for the sqlite3 WASM + builds. The intent is that this page be run + using the functional equivalent of:
+
althttpd -enable-sab -page index.html
+
and the individual pages be started in their own tab. + Warnings and Caveats: + +
+
The tests and demos... + +
+ + + + diff --git a/ext/wasm/tester1.html b/ext/wasm/tester1.html index c163151278..0de679f34f 100644 --- a/ext/wasm/tester1.html +++ b/ext/wasm/tester1.html @@ -4,8 +4,8 @@ - - + + sqlite3 tester #1 (UI thread)