From 3e7fe489e216c3aaa67eb15760e93c4355947c57 Mon Sep 17 00:00:00 2001 From: stephan Date: Thu, 25 Sep 2025 17:29:12 +0000 Subject: [PATCH] Replace ext/wasm/dist.make with mkdist.sh and get dist working with the new build. Fix the preprocessing flags for tester1-esm.html. FossilOrigin-Name: ab6eb4d3b723107da488770b1849b9f1d1c491348f1eaa544e0e07356b8fac7d --- ext/wasm/GNUmakefile | 33 +++++++--- ext/wasm/dist.make | 152 ------------------------------------------- ext/wasm/mkdist.sh | 124 +++++++++++++++++++++++++++++++++++ manifest | 17 +++-- manifest.uuid | 2 +- 5 files changed, 156 insertions(+), 172 deletions(-) delete mode 100644 ext/wasm/dist.make create mode 100755 ext/wasm/mkdist.sh diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index d08e46bc35..e761b032d6 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -254,7 +254,7 @@ b.strip-js-emcc-bindings = \ 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 - +t-version-info: $(bin.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 @@ -264,6 +264,7 @@ $(bin.version-info): $(dir.tool)/version-info.c $(sqlite3.h) $(dir.top)/Makefile bin.stripccomments = $(dir.tool)/stripccomments $(bin.stripccomments): $(bin.stripccomments).c $(MAKEFILE) $(CC) -o $@ $< +t-stripccomments: $(bin.stripccomments) DISTCLEAN_FILES += $(bin.stripccomments) @@ -1239,8 +1240,8 @@ define gen-tester1.js # $3 = c-pp flags $(call b.eval.c-pp,test,tester1.c-pp.js,tester1$(2),$(3)) tester1$(2): $(sqlite3.ext.js) $(out.$(1).wasm) -tester1: tester1$(2) tester1-$(1): tester1$(2) +tester1: tester1$(2) endef $(eval $(call gen-tester1.js,vanilla,.js,$(c-pp.D.vanilla))) @@ -1260,7 +1261,7 @@ endef $(eval $(call gen-tester1.html,vanilla,,$(c-pp.D.vanilla))) $(eval $(call gen-tester1.html,vanilla64,-64bit,$(c-pp.D.vanilla64))) -$(eval $(call gen-tester1.html,esm,-esm,$(c-pp.D.esm64))) +$(eval $(call gen-tester1.html,esm,-esm,$(c-pp.D.esm))) $(eval $(call gen-tester1.html,esm64,-esm-64bit,$(c-pp.D.esm64))) # tester1-worker.html variants: @@ -1268,7 +1269,7 @@ $(eval $(call gen-tester1.html,esm64,-esm-64bit,$(c-pp.D.esm64))) # ?esm URL flag to switch to ESM mode. $(eval $(call b.eval.c-pp,test,tester1-worker.c-pp.html,tester1-worker.html)) $(eval $(call b.eval.c-pp,test,tester1-worker.c-pp.html,tester1-worker-64bit.html,$(c-pp.D.64bit))) -tester: tester1-worker.html tester1-worker-64bit.html +tester1: tester1-worker.html tester1-worker-64bit.html all: tester1 # end tester1 @@ -1371,12 +1372,6 @@ endif # end /wasm docs ######################################################################## -######################################################################## -# Create main client downloadable zip file: -ifneq (,$(filter dist snapshot,$(MAKECMDGOALS))) -include dist.make -endif - # Run local web server for the test/demo pages. httpd: althttpd -max-age 1 -enable-sab 1 -page index.html @@ -1412,6 +1407,24 @@ distclean: clean CLEAN_FILES += *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~ $(dir.fiddle)/*~ \ +######################################################################## +# Create main client downloadable zip file: +ifneq (,$(filter dist snapshot,$(MAKECMDGOALS))) +ifeq (1,$(SQLITE_C_IS_SEE)) +dist-name-extra = -see +else +dist-name-extra = +endif +dist-name-prefix = sqlite-wasm$(dist-name-extra) +.PHONY: dist +dist: + ./mkdist.sh $(dist-name-prefix) +snapshot: + ./mkdist.sh $(dist-name-prefix)-snapshot-$(shell /usr/bin/date +%Y%m%d) +endif +# ^^^ making dist/snapshot +CLEAN_FILES += $(wildcard sqlite-wasm-*.zip) + ######################################################################## # Explanation of, and some commentary on, various emcc build flags # follows. Full docs for these can be found at: diff --git a/ext/wasm/dist.make b/ext/wasm/dist.make deleted file mode 100644 index bce26342e6..0000000000 --- a/ext/wasm/dist.make +++ /dev/null @@ -1,152 +0,0 @@ -#!/do/not/make -#^^^ help emacs select edit mode -# -# Intended to include'd by ./GNUmakefile. -# -# 'make dist' rules for creating a distribution archive of the SQLite -# WASM/JS deliverables. -# -# Use 'make snapshot' to create "snapshot" releases. They use -# distinctly different zip file and top directory names to distinguish -# them from release builds. -####################################################################### -MAKEFILE.dist = $(lastword $(MAKEFILE_LIST)) - -######################################################################## -# 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. Thus we -# have to use a temporary name for the archive until we can get -# that binary built. -ifeq (1,$(SQLITE_C_IS_SEE)) -dist-name-extra = -see -else -dist-name-extra = -endif -ifeq (,$(filter snapshot,$(MAKECMDGOALS))) -dist-name-prefix = sqlite-wasm$(dist-name-extra) -else -dist-name-prefix = sqlite-wasm$(dist-name-extra)-snapshot-$(shell /usr/bin/date +%Y%m%d) -endif -dist-name = $(dist-name-prefix)-TEMP - -######################################################################## -# $(dist.build) must be the name of a target which triggers the build -# of the files to be packed into the dist archive. The intention is -# that it be one of (o0, o1, o2, o3, os, oz), each of which uses -# like-named -Ox optimization level flags. The o2 target provides the -# best overall runtime speeds. The oz target provides slightly slower -# speeds (roughly 10%) with significantly smaller WASM file sizes. -O2 -# (the o2 target) consistently results in faster binaries than both -# -O3 and -Os (the o3 and os targets) in all tests run to date. Our -# general policy is that we want the smallest binaries for dist zip -# files, so use the oz build unless there is a compelling reason not -# to. -dist.build ?= oz - -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-esm.html \ - tester1.js tester1.mjs \ - demo-jsstorage.html demo-jsstorage.js \ - demo-worker1.html demo-worker1.js \ - demo-worker1-promiser.html demo-worker1-promiser.js \ - demo-worker1-promiser-esm.html demo-worker1-promiser.mjs -dist.jswasm.extras = $(sqlite3.wasm) \ - $(sqlite3-api.ext.jses) -dist.common.extras = \ - $(wildcard $(dir.common)/*.css) \ - $(dir.common)/SqliteTestUtil.js - -.PHONY: dist snapshot -# DIST_STRIP_COMMENTS $(call)able to be used in stripping C-style -# from the dist copies of certain files. -# -# $1 = source js file -# $2 = flags for $(bin.stripcomments) -define DIST_STRIP_COMMENTS -$(bin.stripccomments) $(2) < $(1) > $(dist-dir.jswasm)/$(notdir $(1)) || exit; -endef -# STRIP_K1.js = list of JS files which need to be passed through -# $(bin.stripcomments) with a single -k flag. -STRIP_K1.js = $(sqlite3-worker1.js) $(sqlite3-worker1-promiser.js) \ - $(sqlite3-worker1-bundler-friendly.js) \ - $(sqlite3-api.ext.jses) -# STRIP_K2.js = list of JS files which need to be passed through -# $(bin.stripcomments) with two -k flags. -STRIP_K2.js = $(sqlite3.js) $(sqlite3.mjs) \ - $(sqlite3-bundler-friendly.mjs) $(sqlite3-node.mjs) -######################################################################## -# dist: create the end-user deliverable archive. -# -# 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's deps must be trimmed to non-generated files or -# files which are _not_ cleaned up by the clean target. -# -# 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. -# -# 2025-01-15: Emsdk 4.0.0 introduces, in its generated code, a regex -# which contains the pattern /*. That, of course, confuses any C-style -# comment-stripper which is not specifically JS-aware and smart enough -# to know that it's in a regex or string literal. Because of that, -# comment-stripping was briefly disabled, resulting in functionally -# identical but significantly larger JS files. That issue with the -# comment-stripper has been resolved, but $(apply_comment_stripper) -# can be set to false to disable it if a similar problem arises. -# -#apply_comment_stripper = false -apply_comment_stripper = true -# ^^^ shell command true or false -dist: \ - $(bin.stripccomments) $(bin.version-info) \ - $(dist.build) $(STRIP_K1.js) $(STRIP_K2.js) \ - $(dist.jswasm.extras) $(dist.common.extras) \ - $(MAKEFILE) $(MAKEFILE.dist) - @echo "Making end-user deliverables..." - @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) - @if $(apply_comment_stripper); then $(foreach JS,$(STRIP_K1.js),$(call DIST_STRIP_COMMENTS,$(JS),-k)) fi - @if $(apply_comment_stripper); then $(foreach JS,$(STRIP_K2.js),$(call DIST_STRIP_COMMENTS,$(JS),-k -k)) fi - @cp -p $(dist.common.extras) $(dist-dir.common) - @set -e; \ - vnum=$$($(bin.version-info) --download-version); \ - vdir=$(dist-name-prefix)-$$vnum; \ - arczip=$$vdir.zip; \ - echo "Making $$arczip ..."; \ - rm -fr $$arczip $$vdir; \ - mv $(dist-dir.top) $$vdir; \ - zip -qr $$arczip $$vdir; \ - rm -fr $$vdir; \ - ls -la $$arczip; \ - set +e; \ - unzip -lv $$arczip || echo "Missing unzip app? Not fatal." -ifeq (,$(wasm.docs.found)) -snapshot: dist - @echo "To upload the snapshot build to the wasm docs server:"; \ - echo "1) move $(dist-name-prefix)*.zip to the top of a wasm docs checkout."; \ - echo "2) From that checkout run 'make uv-sync'" -else -snapshot: dist - @echo "Moving snapshot to [$(wasm.docs.found)]..."; \ - mv $(dist-name-prefix)*.zip $(wasm.docs.found)/. - @echo "Run 'make uv-sync' from $(wasm.docs.found) to upload it." -endif -# 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: # not to be confused with distclean - rm -fr $(dist-name) $(wildcard sqlite-wasm-*.zip) diff --git a/ext/wasm/mkdist.sh b/ext/wasm/mkdist.sh new file mode 100755 index 0000000000..3171333235 --- /dev/null +++ b/ext/wasm/mkdist.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bash +# +# Creates the zip bundle for the sqlite3 wasm builds. +# $1 is a build name, defaulting to sqlite-wasm. + +function die(){ + local rc=$1 + shift + echo "Error: $@" 1>&2 + exit $rc +} + +buildName=${1-sqlite-wasm} + +make= +for i in gmake make; do + make=$(which $i 2>/dev/null) + [[ x != x$make ]] && break +done +[[ x = x$make ]] && die 127 "Cannot find make" + +dirTop=../.. + +echo "Creating the SQLite wasm dist bundle..." + +# +# Generates files which, when built, will also build all of the pieces +# neaded for the dist bundle. +# +tgtFiles=( + tester1.html + tester1-worker.html + tester1-esm.html + tester1.js tester1.mjs + demo-worker1-promiser.html + demo-worker1-promiser.js + demo-worker1-promiser-esm.html + demo-worker1-promiser.mjs +) + +if false; then + optFlag=-O0 +else + optFlag=-Oz + $make clean +fi +$make -j4 \ + t-version-info t-stripccomments \ + ${tgtFiles[@]} \ + "emcc_opt=${optFlag}" || die $? + +dirTmp=d.dist +rm -fr $dirTmp +mkdir -p $dirTmp/jswasm || die $? +mkdir -p $dirTmp/common || die $? + +# Files for the top-most dir: +fTop=( + demo-worker1.html + demo-worker1.js + demo-jsstorage.html + demo-jsstorage.js + demo-123.html + demo-123-worker.html demo-123.js +) + +# Files for the jswasm subdir sans jswasm prefix: +# +# fJ1 = JS files to stripccomments -k on +# fJ2 = JS files to stripccomments -k -k on +fJ1=( + sqlite3-opfs-async-proxy.js + sqlite3-worker1.js + sqlite3-worker1.mjs + sqlite3-worker1-bundler-friendly.mjs + sqlite3-worker1-promiser.js + sqlite3-worker1-promiser.mjs + sqlite3-worker1-promiser-bundler-friendly.mjs +) +fJ2=( + sqlite3.js + sqlite3.mjs +) + +function fcp() { + cp -p $@ || die $? +} + +function scc(){ + ${dirTop}/tool/stripccomments $@ || die $? +} + +jw=jswasm +fcp ${tgtFiles[@]} $dirTmp/. +fcp README-dist.txt $dirTmp/README.txt +fcp index-dist.html $dirTmp/index.html +fcp common/*.css common/SqliteTestUtil.js $dirTmp/common/. +fcp $jw/sqlite3.wasm $dirTmp/$jw/. + +for i in ${fTop[@]}; do + fcp $i $dirTmp/. +done + +for i in ${fJ1[@]}; do + scc -k < $jw/$i > $dirTmp/$jw/$i || die $? +done + +for i in ${fJ2[@]}; do + scc -k -k < $jw/$i > $dirTmp/$jw/$i || die $? +done + +# +# Done copying files. Now zip it up... +# + +svi=${dirTop}/version-info +vnum=$($svi --download-version) +vdir=${buildName}-${vnum} +fzip=${vdir}.zip +rm -fr ${vdir} ${fzip} +mv $dirTmp $vdir || die $? +zip -rq $fzip $(find $vdir -type f | sort) || die $? +ls -la $fzip +unzip -lv $fzip || die $? diff --git a/manifest b/manifest index 59053023f2..5ba0efb643 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Overhaul\sthe\swasm\sbuild\sto\s(A)\ssupport\smore\scoexisting\svariants,\se.g.\s32/64-bit\sof\sboth\svanilla\sand\sesm,\sand\s(B)\sbuild\seach\svariant\sto\sits\sown\ssubdir\sso\sthat\sthey\scan\sbuild\sin\sparallel.\sIt\scan,\swith\smake\s-j4,\snow\sbuild\sall\snew\svariants\sin\shalf\sthe\stime\sit\spreviously\stook\sfor\sjust\sthe\s32-bit\sbuilds.\sThe\snew\sbuild\slogging\soutput,\sthough\sunconventional,\sserves\stwo\spurposes:\s(A)\simprove\smy\sbuild-time\ssituational\sawareness\sand\s(B)\sit\shelp\sdemystify\ssome\sof\sthe\sbuild\ssteps\sand\soutput\sfiles. -D 2025-09-25T15:17:58.460 +C Replace\sext/wasm/dist.make\swith\smkdist.sh\sand\sget\sdist\sworking\swith\sthe\snew\sbuild.\sFix\sthe\spreprocessing\sflags\sfor\stester1-esm.html. +D 2025-09-25T17:29:12.649 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 b3de195ce668cace9b324599bf6255a70290cbfb5451e826e 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 473695f6c5d9fcfa4099ee1d447b3a965d387e44f213d34ed18f7abce84a7852 +F ext/wasm/GNUmakefile e478287749fcd55285072c4161cc6b9d6f448f14f9d84501de1a093734c9fd97 F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a F ext/wasm/README.md 66ace67ae98a45e4116f2ca5425b716887bcee4d64febee804ff6398e1ae9ec7 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -625,7 +625,6 @@ F ext/wasm/demo-worker1-promiser.c-pp.html 635cf90685805e21772a5f7a35d1ace80f98a F ext/wasm/demo-worker1-promiser.c-pp.js af168699d3cab1c27ad2364ebe06cd49db300bdbf404e23b00d5742ed52816ba F ext/wasm/demo-worker1.html 2c178c1890a2beb5a5fecb1453e796d067a4b8d3d2a04d65ca2eb1ab2c68ef5d F ext/wasm/demo-worker1.js 08720227e98fa5b44761cf6e219269cee3e9dd0421d8d91459535da776950314 -F ext/wasm/dist.make 57f5da2f0de5a297b5a0bc39ffec736380050578240ab24d864c2ff1b3634a3b F ext/wasm/example_extra_init.c 2347cd69d19d839ef4e5e77b7855103a7fe3ef2af86f2e8c95839afd8b05862f F ext/wasm/fiddle/fiddle-worker.js 7798af02e672e088ff192716f80626c8895e19301a65b8af6d5d12b2d13d2451 F ext/wasm/fiddle/fiddle.js 84fd75967e0af8b69d3dd849818342227d0f81d13db92e0dcbc63649b31a4893 @@ -634,6 +633,7 @@ F ext/wasm/index-dist.html 56132399702b15d70c474c3f1952541e25cb0922942868f70daf1 F ext/wasm/index.html 1b329fb63e057c02a17ce178308d6b06aac62d92af7dd6d821fb0e183e0f1557 F ext/wasm/jaccwabyt/jaccwabyt.js bbac67bc7a79dca34afe6215fd16b27768d84e22273507206f888c117e2ede7d F ext/wasm/jaccwabyt/jaccwabyt.md 167fc0b624c9bc2c477846e336de9403842d81b1a24fc4d3b24317cb9eba734f +F ext/wasm/mkdist.sh 94e12f6cfb6131b90a994e7eab5a4b734e8f277fe38cffc3b37e775eb8fe8611 x F ext/wasm/mkwasmbuilds.c 3f27681fd3b32a78560feb3bb54f0f46a68f75024f65d9c5d4247f6bd08a04ad F ext/wasm/module-symbols.html dc476b403369b26a1a23773e13b80f41b9a49f0825e81435fe3600a7cfbbe337 F ext/wasm/scratchpad-wasmfs.html a3d7388f3c4b263676b58b526846e9d02dfcb4014ff29d3a5040935286af5b96 @@ -648,7 +648,7 @@ F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d826 F ext/wasm/sql/001-sudoku.sql 35b7cb7239ba5d5f193bc05ec379bcf66891bce6f2a5b3879f2f78d0917299b5 F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555e685bce3da8c3f F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c -F ext/wasm/tester1-worker.c-pp.html b240b59cd313427434190d5795f57986b9add1a08df53921311fc0b8221b672a w ext/wasm/tester1-worker.html +F ext/wasm/tester1-worker.c-pp.html b240b59cd313427434190d5795f57986b9add1a08df53921311fc0b8221b672a F ext/wasm/tester1.c-pp.html 93fbedb6b15eaad9b03df0524c702a81896e358785655ae2c751e30ef8202e54 F ext/wasm/tester1.c-pp.js 2b2aea6d9938fcfad0e3fd8ae094bced45212b807812b60a0dbe970f7f143f82 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e @@ -2170,9 +2170,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 2914e8fc7b10e8b42c9a0fbd0e71f495714cee3cae67b8c238d37b1e7ec22359 75079401753778e3bc2f7fa307de9217e8d1ec395079fc1009060f707be32943 -R bf2a14e22103418be159da49f21a135f -T +closed 75079401753778e3bc2f7fa307de9217e8d1ec395079fc1009060f707be32943 Closed\sby\sintegrate-merge. +P 2f4be98614b49def2c2951887796c736269ef3bb7ba5b045cae5f748ae165a83 +R 2f32df5d7d259ad6860333afe5e70fec U stephan -Z c8ddfc47b782e73f61a2d31043443056 +Z 6108442ce190e421e8fe73707ba2c0fe # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4a4bec61d6..d5e1324c38 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f4be98614b49def2c2951887796c736269ef3bb7ba5b045cae5f748ae165a83 +ab6eb4d3b723107da488770b1849b9f1d1c491348f1eaa544e0e07356b8fac7d -- 2.47.3