diff options
Diffstat (limited to 'ext/wasm')
-rw-r--r-- | ext/wasm/GNUmakefile | 21 | ||||
-rw-r--r-- | ext/wasm/api/extern-post-js.c-pp.js | 23 | ||||
-rw-r--r-- | ext/wasm/api/pre-js.c-pp.js | 4 | ||||
-rw-r--r-- | ext/wasm/api/sqlite3-vfs-opfs.c-pp.js | 21 | ||||
-rw-r--r-- | ext/wasm/tester1-worker.html | 8 | ||||
-rw-r--r-- | ext/wasm/tester1.c-pp.html | 8 | ||||
-rw-r--r-- | ext/wasm/tester1.c-pp.js | 8 |
7 files changed, 50 insertions, 43 deletions
diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 143ee8b9f..78e34eb19 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -66,6 +66,13 @@ ifeq (,$(emcc.version)) else $(info using emcc version [$(emcc.version)]) endif +emcc.version := $(shell "$(emcc.bin)" --version | sed -n 1p \ + | sed -e 's/^.* \([3-9][^ ]*\) .*$$/\1/;') +ifeq (,$(emcc.version)) + $(warning Cannot determine emcc version. This might unduly impact build flags.) +else + $(info using emcc version [$(emcc.version)]) +endif wasm-strip ?= $(shell which wasm-strip 2>/dev/null) ifeq (,$(filter clean,$(MAKECMDGOALS))) @@ -242,9 +249,17 @@ $(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 ?= -Dtarget=es6-module -Dtarget=es6-bundler-friendly +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 ######################################################################## diff --git a/ext/wasm/api/extern-post-js.c-pp.js b/ext/wasm/api/extern-post-js.c-pp.js index 691ad7685..a577a63e1 100644 --- a/ext/wasm/api/extern-post-js.c-pp.js +++ b/ext/wasm/api/extern-post-js.c-pp.js @@ -9,7 +9,7 @@ Emscripten-generated module init scope, in the current global scope. */ //#if target=es6-module -const toExportForES6 = +const toExportForESM = //#endif (function(){ /** @@ -45,23 +45,14 @@ const toExportForES6 = moduleScript: self?.document?.currentScript, isWorker: ('undefined' !== typeof WorkerGlobalScope), location: self.location, - urlParams: -//#if target=es6-bundler-friendly - undefined -//#else - new URL(self.location.href).searchParams -//#endif + urlParams: new URL(self.location.href).searchParams }); initModuleState.debugModule = -//#if target=es6-bundler-friendly - ()=>{} -//#else - (new URL(self.location.href).searchParams).has('sqlite3.debugModule') + initModuleState.urlParams.has('sqlite3.debugModule') ? (...args)=>console.warn('sqlite3.debugModule:',...args) : ()=>{}; -//#endif - if(initModuleState.urlParams && initModuleState.urlParams.has('sqlite3.dir')){ + if(initModuleState.urlParams.has('sqlite3.dir')){ initModuleState.sqlite3Dir = initModuleState.urlParams.get('sqlite3.dir') +'/'; }else if(initModuleState.moduleScript){ const li = initModuleState.moduleScript.src.split('/'); @@ -116,8 +107,8 @@ const toExportForES6 = } //#ifnot target=es6-module // Emscripten does not inject these module-loader bits in ES6 module -// build and including them here breaks JS bundlers, so elide them -// from ES6 builds. +// builds and including them here breaks JS bundlers, so elide them +// from ESM builds. /* Replace the various module exports performed by the Emscripten glue... */ if (typeof exports === 'object' && typeof module === 'object'){ @@ -131,5 +122,5 @@ const toExportForES6 = return self.sqlite3InitModule /* required for ESM */; })(); //#if target=es6-module -export default toExportForES6; +export default toExportForESM; //#endif diff --git a/ext/wasm/api/pre-js.c-pp.js b/ext/wasm/api/pre-js.c-pp.js index c27c2fe0d..a25c7ce77 100644 --- a/ext/wasm/api/pre-js.c-pp.js +++ b/ext/wasm/api/pre-js.c-pp.js @@ -55,9 +55,9 @@ Module['locateFile'] = function(path, prefix) { "result =", theFile ); return theFile; -//#endif //target=es6-module +//#endif target=es6-module }.bind(sqlite3InitModuleState); -//#endif //ifnot target=es6-bundler-friendly +//#endif ifnot target=es6-bundler-friendly /** Bug warning: a custom Module.instantiateWasm() does not work diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index aeda62aa2..451f0019c 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -100,20 +100,13 @@ const installOpfsVfs = function callee(options){ if(!options || 'object'!==typeof options){ options = Object.create(null); } - const urlParams = -//#if target=es6-bundler-friendly - undefined; -//#else - new URL(self.location.href).searchParams; -//#endif - if(urlParams){ - if(undefined===options.verbose){ - options.verbose = urlParams.has('opfs-verbose') - ? (+urlParams.get('opfs-verbose') || 2) : 1; - } - if(undefined===options.sanityChecks){ - options.sanityChecks = urlParams.has('opfs-sanity-check'); - } + const urlParams = new URL(self.location.href).searchParams; + if(undefined===options.verbose){ + options.verbose = urlParams.has('opfs-verbose') + ? (+urlParams.get('opfs-verbose') || 2) : 1; + } + if(undefined===options.sanityChecks){ + options.sanityChecks = urlParams.has('opfs-sanity-check'); } if(undefined===options.proxyUri){ options.proxyUri = callee.defaultProxyUri; diff --git a/ext/wasm/tester1-worker.html b/ext/wasm/tester1-worker.html index a9c12d72c..03e1f02b0 100644 --- a/ext/wasm/tester1-worker.html +++ b/ext/wasm/tester1-worker.html @@ -11,8 +11,12 @@ </head> <body> <h1 id='color-target'>sqlite3 tester #1: Worker thread</h1> - <div>See <a href='tester1.html' target='tester1.html'>tester1.html</a> - for the UI-thread variant.</div> + <div>Variants: + <a href='tester1.html' target='tester1.html'>conventional UI thread</a>, + <a href='tester1-worker.html' target='tester1-worker.html'>conventional worker</a>, + <a href='tester1-esm.html' target='tester1-esm.html'>ESM in UI thread</a>, + <a href='tester1-worker.html?esm' target='tester1-worker.html?esm'>ESM worker</a> + </div> <div class='input-wrapper'> <input type='checkbox' id='cb-log-reverse'> <label for='cb-log-reverse'>Reverse log order?</label> diff --git a/ext/wasm/tester1.c-pp.html b/ext/wasm/tester1.c-pp.html index 535e58962..bbdd8b223 100644 --- a/ext/wasm/tester1.c-pp.html +++ b/ext/wasm/tester1.c-pp.html @@ -16,8 +16,12 @@ UI thread <style></style> </head> <body><h1 id='color-target'></h1> - <div>See <a href='tester1-worker.html' target='tester1-worker.html'>tester1-worker.html</a> - for the Worker-thread variant.</div> + <div>Variants: + <a href='tester1.html' target='tester1.html'>conventional UI thread</a>, + <a href='tester1-worker.html' target='tester1-worker.html'>conventional worker</a>, + <a href='tester1-esm.html' target='tester1-esm.html'>ESM in UI thread</a>, + <a href='tester1-worker.html?esm' target='tester1-worker.html?esm'>ESM worker</a> + </div> <div class='input-wrapper'> <input type='checkbox' id='cb-log-reverse'> <label for='cb-log-reverse'>Reverse log order?</label> diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 7f5de5166..dca533137 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -1192,13 +1192,13 @@ self.sqlite3InitModule = sqlite3InitModule; rc = capi.sqlite3_db_status(this.db, capi.SQLITE_DBSTATUS_LOOKASIDE_USED, pCur, pHi, 0); T.assert(0===rc); - if(wasm.peek32(pCur)){ - warn("Cannot test db_config(SQLITE_DBCONFIG_LOOKASIDE)", - "while lookaside memory is in use."); - }else{ + if(!wasm.peek32(pCur)){ rc = capi.sqlite3_db_config(this.db, capi.SQLITE_DBCONFIG_LOOKASIDE, 0, 4096, 12); T.assert(0 === rc); + }else{ + console.debug("Cannot test db_config(SQLITE_DBCONFIG_LOOKASIDE)", + "while lookaside memory is in use."); } wasm.poke32([pCur, pHi], 0); let [vCur, vHi] = wasm.peek32(pCur, pHi); |