From 39bffbcd3217f7f1d684316def8c6d9bf5f4a0a3 Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 28 Sep 2025 12:47:09 +0000 Subject: [PATCH] Use new c-pp features to simplify generation of the tester1 family of files. FossilOrigin-Name: f7cab028c97b2c9ac9b561a4c33475aadd3f71cbd48ec4dd6e09c1bb19ec00cb --- ext/wasm/GNUmakefile | 50 ++++++++++++++++++++++++------- ext/wasm/tester1-worker.c-pp.html | 38 +++++------------------ ext/wasm/tester1.c-pp.html | 30 ++++--------------- ext/wasm/tester1.c-pp.js | 17 +++-------- manifest | 20 ++++++------- manifest.uuid | 2 +- 6 files changed, 68 insertions(+), 89 deletions(-) diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index dcf2ffec35..927481268f 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -1259,10 +1259,18 @@ tester1-$(1): tester1$(2) tester1: tester1$(2) endef -$(eval $(call gen-tester1.js,vanilla,.js,$(c-pp.D.vanilla))) -$(eval $(call gen-tester1.js,vanilla64,-64bit.js,$(c-pp.D.vanilla64))) -$(eval $(call gen-tester1.js,esm,.mjs,$(c-pp.D.esm))) -$(eval $(call gen-tester1.js,esm64,-64bit.mjs,$(c-pp.D.esm64))) +$(eval $(call gen-tester1.js,vanilla,.js, \ + $(c-pp.D.vanilla) \ + -Dsqlite3.js=$(dir.dout)/sqlite3.js)) +$(eval $(call gen-tester1.js,vanilla64,-64bit.js, \ + $(c-pp.D.vanilla64) \ + -Dsqlite3.js=$(dir.dout)/sqlite3-64bit.js)) +$(eval $(call gen-tester1.js,esm,.mjs, \ + $(c-pp.D.esm) \ + -Dsqlite3.js=$(dir.dout)/sqlite3.mjs)) +$(eval $(call gen-tester1.js,esm64,-64bit.mjs, \ + $(c-pp.D.esm64) \ + -Dsqlite3.js=$(dir.dout)/sqlite3-64bit.mjs)) # tester1.html variants: define gen-tester1.html @@ -1274,16 +1282,38 @@ tester1$(2).html: tester1-$(1) tester1: tester1$(2).html 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.esm))) -$(eval $(call gen-tester1.html,esm64,-esm-64bit,$(c-pp.D.esm64))) +$(eval $(call gen-tester1.html,vanilla,,\ + $(c-pp.D.vanilla) \ + -Dbitness=32 \ + -Dtitle="UI thread" \ + -Dtester1.js=tester1.js \ + -Dsqlite3.js=$(dir.dout)/sqlite3.js)) +$(eval $(call gen-tester1.html,vanilla64,-64bit,\ + $(c-pp.D.vanilla64) \ + -Dbitness=64 \ + -Dtitle="UI thread" \ + -Dtester1.js=tester1-64bit.js \ + -Dsqlite3.js=$(dir.dout)/sqlite3-64bit.js)) +$(eval $(call gen-tester1.html,esm,-esm,\ + $(c-pp.D.esm) \ + -Dbitness=32 \ + -Dtitle="ES6 Module in UI thread" \ + -Dtester1.js=tester1.mjs \ + -Dsqlite3.js=$(dir.dout)/sqlite3.mjs)) +$(eval $(call gen-tester1.html,esm64,-esm-64bit,\ + $(c-pp.D.esm64) \ + -Dbitness=64 \ + -Dtitle="ES6 Module in UI thread" \ + -Dtester1.js=tester1-64bit.mjs \ + -Dsqlite3.js=$(dir.dout)/sqlite3-64bit.mjs)) # tester1-worker.html variants: # There is no ESM variant of this file. Instead, that page accepts a # ?esm URL flag to switch to ESM mode. -$(eval $(call b.c-pp.target,test,tester1-worker.c-pp.html,tester1-worker.html)) -$(eval $(call b.c-pp.target,test,tester1-worker.c-pp.html,tester1-worker-64bit.html,$(c-pp.D.64bit))) +$(eval $(call b.c-pp.target,test,tester1-worker.c-pp.html,\ + tester1-worker.html,-Dbitness=32)) +$(eval $(call b.c-pp.target,test,tester1-worker.c-pp.html,\ + tester1-worker-64bit.html,$(c-pp.D.64bit) -Dbitness=64)) tester1: tester1-worker.html tester1-worker-64bit.html tester1-worker.html: tester1.mjs tester1-worker-64bit.html: tester1-64bit.mjs diff --git a/ext/wasm/tester1-worker.c-pp.html b/ext/wasm/tester1-worker.c-pp.html index dc84bc15e9..e461b6cbff 100644 --- a/ext/wasm/tester1-worker.c-pp.html +++ b/ext/wasm/tester1-worker.c-pp.html @@ -1,4 +1,5 @@ +//#@policy error @@ -6,23 +7,11 @@ - sqlite3 tester #1: Worker thread -//#if 64bit - (64-bit WASM) -//#else - (32-bit WASM) -//#endif - + sqlite3 tester #1: Worker thread (@bitness@-bit WASM) -

sqlite3 tester #1: Worker thread -//#if 64bit - (64-bit WASM) -//#else - (32-bit WASM) -//#endif -

+

sqlite3 tester #1: Worker thread (@bitness@-bit WASM)

Variants: conventional UI thread, conventional worker, @@ -59,27 +48,14 @@ cbReverseIt(); const urlParams = new URL(self.location.href).searchParams; const workerArgs = []; - const baseName = -//#if 64bit - 'tester1-64bit' -//#else - 'tester1' -//#endif - ; - if(urlParams.has('esm')){ + const baseName = "64"==="@bitness@" ? 'tester1-64bit' : 'tester1'; + if(urlParams.has('esm')){ logHtml('warning',"Attempting to run an ES6 Worker Module, "+ "which is not supported by all browsers!."); - workerArgs.push(baseName+'.mjs', {type:"module"}); - const bitness = -//#if 64bit - 64 -//#else - 32 -//#endif - ; + workerArgs.push(baseName+'.mjs', {type:"module"}); document.querySelectorAll('title,#color-target').forEach((e)=>{ e.innerText = - "sqlite3 tester #1: ES6 Worker Module ("+bitness+"-bit WASM)"; + "sqlite3 tester #1: ES6 Worker Module (@bitness@-bit WASM)"; }); }else{ workerArgs.push(baseName+'.js?sqlite3.dir=jswasm'); diff --git a/ext/wasm/tester1.c-pp.html b/ext/wasm/tester1.c-pp.html index 0fae73de2b..95fe52219e 100644 --- a/ext/wasm/tester1.c-pp.html +++ b/ext/wasm/tester1.c-pp.html @@ -1,4 +1,5 @@ +//#@policy error @@ -6,17 +7,7 @@ - sqlite3 tester #1: -//#if target=es6-module -ES6 Module in -//#endif - UI thread -//#if 64bit - (64-bit WASM) -//#else - (32-bit WASM) -//#endif - + sqlite3 tester #1: @title@ (@bitness@-bit WASM)

@@ -35,20 +26,11 @@ ES6 Module in document.querySelector('h1').innerHTML = document.querySelector('title').innerHTML; })(); -//#if target=es6-module -//#if 64bit - -//#else - -//#endif -//#else -//#if 64bit - - +//#if target:es6-module + //#else - - + + //#endif -//#endif target=es6-module diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 39440f3b34..e3a151a8e6 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -43,14 +43,9 @@ ./c-pp -f tester1.c-pp.js -o tester1-esm.mjs -Dtarget:es6-module */ +//#@policy error //#if target:es6-module -import {default as sqlite3InitModule} from -//#if 64bit -'./jswasm/sqlite3-64bit.mjs' -//#else -'./jswasm/sqlite3.mjs' -//#endif -; +import {default as sqlite3InitModule} from "@sqlite3.js@"; globalThis.sqlite3InitModule = sqlite3InitModule; //#else 'use strict'; @@ -3805,7 +3800,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; error: ()=>{} } } -//#ifnot target:es6-module +//#if not target:es6-module if(!globalThis.sqlite3InitModule && !isUIThread()){ /* Vanilla worker, as opposed to an ES6 module worker */ /* @@ -3822,11 +3817,7 @@ globalThis.sqlite3InitModule = sqlite3InitModule; are simply lost, and such scripts see the globalThis.location of _this_ script. */ -//#if 64bit - let sqlite3Js = 'sqlite3-64bit.js'; -//#else - let sqlite3Js = 'sqlite3.js'; -//#endif + let sqlite3Js = '@sqlite3.js@'.split('/').pop()/*build-injected name has a path part*/; const urlParams = new URL(globalThis.location.href).searchParams; if(urlParams.has('sqlite3.dir')){ sqlite3Js = urlParams.get('sqlite3.dir') + '/' + sqlite3Js; diff --git a/manifest b/manifest index 57c94e5dc8..ee755f371f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\stypo\sin\sa\scomment. -D 2025-09-28T08:59:16.147 +C Use\snew\sc-pp\sfeatures\sto\ssimplify\sgeneration\sof\sthe\stester1\sfamily\sof\sfiles. +D 2025-09-28T12:47:09.995 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 e06543750e8ed35baa8bba31ad3e357bb13f2dc8fe75cb491fe2d6f2167110a2 +F ext/wasm/GNUmakefile 41f3a91a48816a9825e4e42bbbd449f16d68c4e1ca1dcf4c8827497a743ec4e2 F ext/wasm/README-dist.txt f01081a850ce38a56706af6b481e3a7878e24e42b314cfcd4b129f0f8427066a F ext/wasm/README.md 66ace67ae98a45e4116f2ca5425b716887bcee4d64febee804ff6398e1ae9ec7 F ext/wasm/SQLTester/GNUmakefile e0794f676d55819951bbfae45cc5e8d7818dc460492dc317ce7f0d2eca15caff @@ -648,9 +648,9 @@ 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 -F ext/wasm/tester1.c-pp.html 93fbedb6b15eaad9b03df0524c702a81896e358785655ae2c751e30ef8202e54 -F ext/wasm/tester1.c-pp.js 79bd0476f5c27bf064e3ee996f4c68cf2f6e013f51e455480c66c5ce9812069a +F ext/wasm/tester1-worker.c-pp.html 883881eeac14eeeecc8ff22acf9fe0f18a97cacb48be08ebb0bae891ceded584 +F ext/wasm/tester1.c-pp.html 949920126dcf477925d8d540093d9cc374d3ab4c4ddee920c1dcadcf37917306 +F ext/wasm/tester1.c-pp.js 762682ad29de847aa353adac7f47e8615941b2afc50550fa8c90c14551bc4746 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2169,8 +2169,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 0d6ed44278a513b062539f32da49fa43952fcdf0bc1bba7b24ef3749bc4525a5 -R 122fe78829f8fbc951acb9fd5e10b15b -U drh -Z aef55af468fbb2a272262a36e7436bc2 +P 1f6deabfff2fc2fed5fbff48d2637b48245e5a946a442c4bcc9b9ecb7c4848b9 +R 61ab22384b67899649f53dae2a4d1679 +U stephan +Z 8b6f19bade66e7c98d4e04557c2db4bb # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 8344725dfc..cbeababddf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f6deabfff2fc2fed5fbff48d2637b48245e5a946a442c4bcc9b9ecb7c4848b9 +f7cab028c97b2c9ac9b561a4c33475aadd3f71cbd48ec4dd6e09c1bb19ec00cb -- 2.47.3