1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

More work on the wasmfs build. Resolve the inconsistent argument type passed to sqlite3InitModule() in such builds.

FossilOrigin-Name: 4850a9e2d2b41b91e91b9ef99a6d26ddf11a161b4c970fc00d2d095606729a04
This commit is contained in:
stephan
2023-07-13 10:41:41 +00:00
parent 0f0e5700ba
commit d41d454fc1
7 changed files with 30 additions and 59 deletions

View File

@ -381,18 +381,14 @@ sqlite3-api.jses += $(dir.api)/sqlite3-v-helper.js
sqlite3-api.jses += $(dir.api)/sqlite3-vfs-opfs.c-pp.js
sqlite3-api.jses += $(dir.api)/sqlite3-api-cleanup.js
# "External" API files which are part of our distribution
# SOAP.js is an external API file which is part of our distribution
# but not part of the sqlite3-api.js amalgamation.
SOAP.js := $(dir.api)/sqlite3-opfs-async-proxy.js
# COPY_XAPI = a $(call)able function to copy $1 to $(dir.dout), where
# $1 must be one of the "external" JS API files.
define COPY_XAPI
sqlite3-api.ext.jses += $$(dir.dout)/$$(notdir $(1))
$$(dir.dout)/$$(notdir $(1)): $(1) $$(MAKEFILE)
cp $$< $$@
endef
$(foreach X,$(SOAP.js),\
$(eval $(call COPY_XAPI,$(X))))
SOAP.js.bld := $(dir.dout)/$(notdir $(SOAP.js))
sqlite3-api.ext.jses += $(SOAP.js.bld)
$(SOAP.js.bld): $(SOAP.js)
cp $< $@
all quick: $(sqlite3-api.ext.jses)
q: quick

View File

@ -63,18 +63,16 @@ const toExportForESM =
//console.warn("Using replaced sqlite3InitModule()",globalThis.location);
return originalInit(...args).then((EmscriptenModule)=>{
if('undefined'!==typeof WorkerGlobalScope &&
(EmscriptenModule['ENVIRONMENT_IS_PTHREAD']
|| EmscriptenModule['_pthread_self']
|| 'function'===typeof threadAlert
|| globalThis?.location?.pathname?.endsWith?.('.worker.js')
)){
EmscriptenModule['ENVIRONMENT_IS_PTHREAD']){
/** Workaround for wasmfs-generated worker, which calls this
routine from each individual thread and requires that its
argument be returned. All of the criteria above are fragile,
based solely on inspection of the offending code, not public
Emscripten details. */
argument be returned. The conditional criteria above are
fragile, based solely on inspection of the offending code,
not public Emscripten details. */
//console.warn("sqlite3InitModule() returning E-module.",EmscriptenModule);
return EmscriptenModule;
}
//console.warn("sqlite3InitModule() returning sqlite3 object.");
const s = EmscriptenModule.sqlite3;
s.scriptInfo = initModuleState;
//console.warn("sqlite3.scriptInfo =",s.scriptInfo);

View File

@ -10,20 +10,6 @@
</head>
<body>
<header id='titlebar'><span>sqlite3 WASMFS/OPFS Main-thread Scratchpad</span></header>
<!-- emscripten bits -->
<figure id="module-spinner">
<div class="spinner"></div>
<div class='center'><strong>Initializing app...</strong></div>
<div class='center'>
On a slow internet connection this may take a moment. If this
message displays for "a long time", intialization may have
failed and the JavaScript console may contain clues as to why.
</div>
</figure>
<div class="emscripten" id="module-status">Downloading...</div>
<div class="emscripten">
<progress value="0" max="100" id="module-progress" hidden='1'></progress>
</div><!-- /emscripten bits -->
<p>Scratchpad/test app for the WASMF/OPFS integration in the
main window thread. This page requires that the sqlite3 API have
been built with WASMFS support. If OPFS support is available then
@ -34,8 +20,8 @@
<hr>
<div id='test-output'></div>
<!--script src="jswasm/sqlite3-wasmfs.js"></script-->
<script src="common/SqliteTestUtil.js"></script>
<!---script src="scratchpad-wasmfs-main.js"></script-->
<!--script src="common/SqliteTestUtil.js"></script-->
<!--script src="scratchpad-wasmfs-main.js"></script-->
<!--script src="scratchpad-wasmfs-main.js" type="module"></script-->
<script>
(function(){

View File

@ -15,6 +15,7 @@
*/
'use strict';
//importScripts('jswasm/sqlite3-wasmfs.js');
//importScripts('common/SqliteTestUtil.js');
import sqlite3InitModule from './jswasm/sqlite3-wasmfs.mjs';
//console.log('sqlite3InitModule =',sqlite3InitModule);
(function(){
@ -70,15 +71,5 @@ import sqlite3InitModule from './jswasm/sqlite3-wasmfs.mjs';
stdout("Total test time:",(performance.now() - startTime),"ms");
};
sqlite3InitModule(globalThis.sqlite3TestModule).then((X)=>{
/*
2023-07-13: we're passed the Emscripten Module object here
instead of the sqlite3 object. This differs from the canonical
build and is a side effect of WASMFS's requirement
that the module init function (i.e. sqlite3InitModule())
return its initial arrgument (the Emscripten Module).
*/
stdout("then() got",X.sqlite3,X);
runTests(X.sqlite3 || X);
});
sqlite3InitModule().then(runTests);
})();

View File

@ -38,7 +38,7 @@ emcc.flags.sqlite3-wasmfs += -sDYNAMIC_EXECUTION=0
emcc.flags.sqlite3-wasmfs += -sNO_POLYFILL
emcc.flags.sqlite3-wasmfs += -sWASM_BIGINT=$(emcc.WASM_BIGINT)
emcc.flags.sqlite3-wasmfs += -sEXPORTED_FUNCTIONS=@$(abspath $(dir.api)/EXPORTED_FUNCTIONS.sqlite3-api)
emcc.flags.sqlite3-wasmfs += -sEXPORTED_RUNTIME_METHODS=FS,wasmMemory,allocateUTF8OnStack
emcc.flags.sqlite3-wasmfs += -sEXPORTED_RUNTIME_METHODS=wasmMemory,allocateUTF8OnStack
# wasmMemory ==> for -sIMPORTED_MEMORY
# allocateUTF8OnStack ==> wasmfs internals
emcc.flags.sqlite3-wasmfs += -sUSE_CLOSURE_COMPILER=0
@ -102,9 +102,9 @@ endef
# built/saved multiple times.
#
wasmfs.build.ext := mjs
$(sqlite3-wasmfs.js):
$(sqlite3-wasmfs.js): $(SOAP.js.bld)
$(call SQLITE3-WASMFS.xJS.RECIPE,vanilla)
$(sqlite3-wasmfs.mjs):
$(sqlite3-wasmfs.mjs): $(SOAP.js.bld)
$(call SQLITE3-WASMFS.xJS.RECIPE,esm)
ifeq (js,$(wasmfs.build.ext))
$(sqlite3-wasmfs.wasm): $(sqlite3-wasmfs.js)

View File

@ -1,5 +1,5 @@
C Minor\scleanups\sin\sthe\swasmfs\sbuild.
D 2023-07-13T04:54:18.496
C More\swork\son\sthe\swasmfs\sbuild.\sResolve\sthe\sinconsistent\sargument\stype\spassed\sto\ssqlite3InitModule()\sin\ssuch\sbuilds.
D 2023-07-13T10:41:41.226
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -482,14 +482,14 @@ 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 319505a36ceb8debffd5f0d3243e6396ee5f623a68529d205fb0c7155df832cf
F ext/wasm/GNUmakefile daedd26bdc97f705d72213733573630d38c3fbbec0ba722a93c5302a12e7685f
F ext/wasm/README-dist.txt 6382cb9548076fca472fb3330bbdba3a55c1ea0b180ff9253f084f07ff383576
F ext/wasm/README.md ef39861aa21632fdbca0bdd469f78f0096f6449a720f3f39642594af503030e9
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api d6a5078f48a5301ed17b9a30331075d9b2506e1360c1f0dee0c7816c10acd9ab
F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-see fb29e62082a658f0d81102488414d422c393c4b20cc2f685b216bc566237957b
F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287
F ext/wasm/api/README.md 77a2f1f2fc60a35def7455dffc8d3f2c56385d6ac5c6cecc60fa938252ea2c54
F ext/wasm/api/extern-post-js.c-pp.js a91c73765b8909d0fddad72328f9396fee1f5fb58435e73cff20ef713e67d014
F ext/wasm/api/extern-post-js.c-pp.js 116749b7e55b7519129de06d3d353e19df68cfb24b12204aa4dc30c9a83023fe
F ext/wasm/api/extern-pre-js.js cc61c09c7a24a07dbecb4c352453c3985170cec12b4e7e7e7a4d11d43c5c8f41
F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08902f15c34720ee4a1
F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b35ff3ed9cfd281a62
@ -534,8 +534,8 @@ F ext/wasm/index.html bba92ca0c173b579356533226a85a28797d1789e893c9b483fc0623842
F ext/wasm/jaccwabyt/jaccwabyt.js 1264710db3cfbcb6887d95665b7aeba60c1126eaef789ca4cf1a4a17d5bc7f54
F ext/wasm/jaccwabyt/jaccwabyt.md 37911f00db12cbcca73aa1ed72594430365f30aafae2fa9c886961de74e5e0eb
F ext/wasm/module-symbols.html 841de62fc198988b8330e238c260e70ec93028b096e1a1234db31b187a899d10
F ext/wasm/scratchpad-wasmfs-main.html a70452766ed8dd88f7c4b3603dbf8de34c76b734614fd67729f0961a82af19c3
F ext/wasm/scratchpad-wasmfs-main.js 59cbc259921f3ff521cdfafdbe278df885b5f92e0e279aacacf6fb12ff3be5eb
F ext/wasm/scratchpad-wasmfs-main.html bf23812d059da37399b34e27d6b4c5980e2e1fb2153e5d3318d39b41aa854c32
F ext/wasm/scratchpad-wasmfs-main.js 97f8eff738871030b98b75166b75555ce140605c791143dace93058643275137
F ext/wasm/speedtest1-wasmfs.html 3493c46b24bad00e9f6ebe14804143ae67a880f6c59c16ee13bf5f06e7dc4313
F ext/wasm/speedtest1-worker.html 97c2bf5f8534091ce718de05801090d5a80c3f13575996f095ba23638e1bdca0
F ext/wasm/speedtest1-worker.js 13b57c4a41729678a1194014afec2bd5b94435dcfc8d1039dfa9a533ac819ee1
@ -552,7 +552,7 @@ F ext/wasm/tests/opfs/concurrency/index.html 0802373d57034d51835ff6041cda438c7a9
F ext/wasm/tests/opfs/concurrency/test.js a98016113eaf71e81ddbf71655aa29b0fed9a8b79a3cdd3620d1658eb1cc9a5d
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
F ext/wasm/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd72273503ae7d5
F ext/wasm/wasmfs.make e7e1af321302e390b854a9940c16514c755070a2225a830d51e84eb9fea47222
F ext/wasm/wasmfs.make 95e5ee1d67db75561872dfab9b2ebc65084eb807808d863308c405bba3e1a4e1
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0
@ -2042,8 +2042,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 647761ed422f196f94facc88bbddd7219a2c1a6301a5f847b0a32d3e405233a7
R e7ab42412381a677950ba361ea3eaf82
P f64477f21040c265061ad9b7f601e74159fd6141e7e4b122c80bf244ab6ddb76
R 30150ab9b0833aa41ada6fa807ec2755
U stephan
Z 333900e3d11fac56a338fcc42eb12fb0
Z 8daba6a2f84ceed3306c658c6f269c02
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
f64477f21040c265061ad9b7f601e74159fd6141e7e4b122c80bf244ab6ddb76
4850a9e2d2b41b91e91b9ef99a6d26ddf11a161b4c970fc00d2d095606729a04