]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Put pieces in place for fiddle to support opfs, but more cleanup is required in the...
authorstephan <stephan@noemail.net>
Wed, 21 Sep 2022 19:51:25 +0000 (19:51 +0000)
committerstephan <stephan@noemail.net>
Wed, 21 Sep 2022 19:51:25 +0000 (19:51 +0000)
FossilOrigin-Name: 7c7fb7535e86b3960eea7f29ab7e6d5197c166b4ee64ad4a9bc0749f2869badc

ext/wasm/EXPORTED_RUNTIME_METHODS.fiddle
ext/wasm/GNUmakefile
ext/wasm/api/sqlite3-api-prologue.js
ext/wasm/api/sqlite3-wasm.c
ext/wasm/fiddle.make
ext/wasm/fiddle/fiddle-worker.js
ext/wasm/fiddle/fiddle.html
ext/wasm/fiddle/fiddle.js
ext/wasm/wasmfs.make
manifest
manifest.uuid

index af2c48a3f4e68707163521db7cc455e2c48ed05b..5e80f703ae4dafcb039496817194087b409e53f2 100644 (file)
@@ -12,3 +12,4 @@ stackAlloc
 stackRestore
 stackSave
 stringToUTF8Array
+wasmMemory
index 79da723247061b0205253818c0cfd91d76cb74d8..83c9ec0ead5f6325b54767fda44ec635aeeea685 100644 (file)
@@ -47,6 +47,7 @@ dir.jacc := jaccwabyt
 dir.common := common
 dir.fiddle := fiddle
 CLEAN_FILES := *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~
+emcc_enable_bigint ?= 1
 sqlite3.c := $(dir.top)/sqlite3.c
 SQLITE_OPT = \
   -DSQLITE_ENABLE_FTS4 \
@@ -65,7 +66,8 @@ SQLITE_OPT = \
   -DSQLITE_THREADSAFE=0 \
   -DSQLITE_TEMP_STORE=3 \
   -DSQLITE_OS_KV_OPTIONAL=1 \
-  '-DSQLITE_DEFAULT_UNIX_VFS="unix-none"'
+  '-DSQLITE_DEFAULT_UNIX_VFS="unix-none"' \
+  -DSQLITE_USE_URI=1
 #SQLITE_OPT += -DSQLITE_ENABLE_MEMSYS5
 # ^^^ MEMSYS5 is hypothetically useful for non-Emscripten builds but
 # requires adding more infrastructure and fixing one spot in the
@@ -221,11 +223,7 @@ emcc.jsflags += --import-undefined
 #emcc.jsflags += --unresolved-symbols=import-dynamic --experimental-pic
 #emcc.jsflags += --experimental-pic --unresolved-symbols=ingore-all --import-undefined
 #emcc.jsflags += --unresolved-symbols=ignore-all
-enable_bigint ?= 1
-ifneq (0,$(enable_bigint))
-emcc.jsflags += -sWASM_BIGINT
-endif
-emcc.jsflags += -sMEMORY64=0
+emcc.jsflags += -sWASM_BIGINT=$(emcc_enable_bigint)
 # ^^^^ MEMORY64=1 fails to load, erroring with:
 #  invalid memory limits flags 0x5
 #    (enable via --experimental-wasm-memory64)
@@ -333,9 +331,7 @@ speedtest1-common.eflags += -sDYNAMIC_EXECUTION=0
 speedtest1-common.eflags += --minify 0
 speedtest1-common.eflags += -sEXPORT_NAME=sqlite3Speedtest1InitModule
 speedtest1-common.eflags += --post-js=$(post-js.js)
-ifneq (0,$(enable_bigint))
-speedtest1-common.eflags += -sWASM_BIGINT
-endif
+speedtest1-common.eflags += -sWASM_BIGINT=$(emcc_enable_bigint)
 speedtest1.exit-runtime0 := -sEXIT_RUNTIME=0
 speedtest1.exit-runtime1 := -sEXIT_RUNTIME=1
 # Re -sEXIT_RUNTIME=1 vs 0: if it's 1 and speedtest1 crashes, we get
index a671080052e0b2080a514279fa4a4c6f4f3cb6f7..1e2d387a15c2f3d611bea0568e8f57d023850bd7 100644 (file)
@@ -147,7 +147,10 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
       Module: undefined/*needed for some test code, not part of the public API*/,
       exports: undefined,
       memory: undefined,
-      bigIntEnabled: !!self.BigInt64Array,
+      bigIntEnabled: (()=>{
+        if('undefined'!==typeof Module) return !!Module.HEAPU64;
+        return !!self.BigInt64Array;
+      })(),
       allocExportName: 'malloc',
       deallocExportName: 'free',
       persistentDirName: '/persistent'
index 5b127cb743f5db832c49e3dbfc5f198abc505419..e1e5be248357a355c5cb42ae29ff2dd0336c827e 100644 (file)
@@ -1,11 +1,44 @@
 /*
 ** This file requires access to sqlite3.c static state in order to
-** implement certain WASM-specific features. Unlike the rest of
-** sqlite3.c, this file requires compiling with -std=c99 (or
-** equivalent, or a later C version) because it makes use of features
-** not available in C89.
+** implement certain WASM-specific features, and thus directly
+** includes that file. Unlike the rest of sqlite3.c, this file
+** requires compiling with -std=c99 (or equivalent, or a later C
+** version) because it makes use of features not available in C89.
+**
+** At it's simplest, to build sqlite3.wasm either place this file
+** in the same directory as sqlite3.c/h before compilation or use the
+** -I/path flag to tell the compiler where to find both of those
+** files, then compile this file. For example:
+**
+** emcc -o sqlite3.wasm ... -I/path/to/sqlite3-c-and-h sqlite3-wasm.c
 */
-#include "sqlite3.c"
+
+#ifndef SQLITE_DEFAULT_UNIX_VFS
+# define SQLITE_DEFAULT_UNIX_VFS "unix-none"
+#endif
+#ifndef SQLITE_OMIT_DEPRECATED
+# define SQLITE_OMIT_DEPRECATED
+#endif
+#ifndef SQLITE_OMIT_LOAD_EXTENSION
+# define SQLITE_OMIT_LOAD_EXTENSION
+#endif
+#ifndef SQLITE_OMIT_SHARED_CACHE
+# define SQLITE_OMIT_SHARED_CACHE
+#endif
+#ifndef SQLITE_OMIT_UTF16
+# define SQLITE_OMIT_UTF16
+#endif
+#ifndef SQLITE_OS_KV_OPTIONAL
+# define SQLITE_OS_KV_OPTIONAL 1
+#endif
+#ifndef SQLITE_TEMP_STORE
+# define SQLITE_TEMP_STORE 3
+#endif
+#ifndef SQLITE_THREADSAFE
+# define SQLITE_THREADSAFE 0
+#endif
+
+#include "sqlite3.c" /* yes, .c instead of .h. */
 
 /*
 ** WASM_KEEP is identical to EMSCRIPTEN_KEEPALIVE but is not
index 63a665be5c4e570277e1040a2b202c55a3e9f8b2..87018047a4cad539cdaffa2b60a7d0980b435adc 100644 (file)
@@ -32,12 +32,12 @@ fiddle.emcc-flags = \
   -sENVIRONMENT=web,worker \
   -sMODULARIZE \
   -sDYNAMIC_EXECUTION=0 \
+  -sWASM_BIGINT=$(emcc_enable_bigint) \
   -sEXPORT_NAME=initFiddleModule \
   -sEXPORTED_RUNTIME_METHODS=@$(dir.wasm)/EXPORTED_RUNTIME_METHODS.fiddle \
   -sEXPORTED_FUNCTIONS=@$(dir.wasm)/EXPORTED_FUNCTIONS.fiddle \
   --post-js=$(post-js.js) \
   $(SQLITE_OPT) $(SHELL_OPT) \
-  -D_POSIX_SOURCE \
   -DSQLITE_SHELL_FIDDLE
 # -D_POSIX_C_SOURCE is needed for strdup() with emcc
 
@@ -52,9 +52,13 @@ fiddle-module.js := $(dir.fiddle)/fiddle-module.js
 fiddle-module.wasm := $(subst .js,.wasm,$(fiddle-module.js))
 fiddle.cs := $(dir.top)/shell.c $(sqlite3-wasm.c)
 
+SOAP.js := sqlite3-opfs-async-proxy.js
+$(dir.fiddle)/$(SOAP.js): $(SOAP.js)
+       cp $< $@
+
 $(fiddle-module.js): $(MAKEFILE) $(MAKEFILE.fiddle) \
     EXPORTED_FUNCTIONS.fiddle EXPORTED_RUNTIME_METHODS.fiddle \
-    $(fiddle.cs) $(post-js.js)
+    $(fiddle.cs) $(post-js.js) $(dir.fiddle)/$(SOAP.js)
        $(emcc.bin) -o $@ $(fiddle.emcc-flags) $(fiddle.cs)
        $(maybe-wasm-strip) $(fiddle-module.wasm)
        gzip < $@ > $@.gz
@@ -67,6 +71,7 @@ clean: clean-fiddle
 clean-fiddle:
        rm -f $(fiddle-module.js) $(fiddle-module.js).gz \
         $(fiddle-module.wasm) $(fiddle-module.wasm).gz \
+        $(dir.fiddle)/$(SOAP.js) \
         EXPORTED_FUNCTIONS.fiddle
 .PHONY: fiddle
 fiddle: $(fiddle-module.js) $(dir.fiddle)/fiddle.js.gz
index 5bc1391753adfac2c71cd0e6ed490f007b9270b4..b76dcf212eeca16e8d564fb47e92bb8c99cb59a9 100644 (file)
     });
   };
 
-  const stdout = function(){wMsg('stdout', Array.prototype.slice.call(arguments));};
-  const stderr = function(){wMsg('stderr', Array.prototype.slice.call(arguments));};
+  const stdout = (...args)=>wMsg('stdout', args);
+  const stderr = (...args)=>wMsg('stderr', args);
   
   self.onerror = function(/*message, source, lineno, colno, error*/) {
     const err = arguments[4];
     }
   };
 
-  importScripts('fiddle-module.js');
+  importScripts('fiddle-module.js'+self.location.search);
   /**
      initFiddleModule() is installed via fiddle-module.js due to
      building with:
      emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initFiddleModule
   */
   initFiddleModule(fiddleModule).then(function(thisModule){
-    thisModule.fsUnlink = thisModule.cwrap('sqlite3_wasm_vfs_unlink','number',['string']);
-    wMsg('fiddle-ready');
+    const S = thisModule.sqlite3;
+    const atEnd = ()=>{
+      thisModule.fsUnlink = thisModule.cwrap('sqlite3_wasm_vfs_unlink','number',['string']);
+      wMsg('fiddle-ready');
+    };
+    if(0){
+      S.installOpfsVfs().finally(function(){
+        if(S.opfs){
+          stdout("OPFS is available.");
+        }
+        atEnd();
+      });
+    }else{
+      atEnd();
+    }
   });
 })();
index 3570b283e3a78744372e82ed1132af18aebd4377..272f1aca76cbeb5bd408e0874e90155fe0dc6f97 100644 (file)
         </fieldset>
       </div>
     </div> <!-- #view-split -->
-    <!-- Maintenance notes:
-
-        ... TODO... currently being refactored...
-
-    -->
     <script src="fiddle.js"></script>
   </body>
 </html>
index ec56dd59301310195f7a7763ede0f22ac71afa42..b971233ef9acb1ff09611e7768bb465f2ebb9110 100644 (file)
         }
     }
 
-    SF.worker = new Worker('fiddle-worker.js');
+    SF.worker = new Worker('fiddle-worker.js'+self.location.search);
     SF.worker.onmessage = (ev)=>SF.runMsgHandlers(ev.data);
     SF.addMsgHandler(['stdout', 'stderr'], (ev)=>SF.echo(ev.data));
 
index d65684b637a09b7222bb079c3a6fc5a4afe020be..ccfd9063b4cc8e9b7581b18696037d8c8754a9be 100644 (file)
@@ -76,9 +76,7 @@ speedtest1-common.eflags += -sEXPORTED_FUNCTIONS=@$(dir.wasm)/EXPORTED_FUNCTIONS
 #^^^ using ALLOW_MEMORY_GROWTH produces a warning from emcc:
 #   USE_PTHREADS + ALLOW_MEMORY_GROWTH may run non-wasm code slowly,
 #   see https://github.com/WebAssembly/design/issues/1271 [-Wpthreads-mem-growth]
-ifneq (0,$(enable_bigint))
-sqlite3-wasmfs.jsflags += -sWASM_BIGINT
-endif
+sqlite3-wasmfs.jsflags += -sWASM_BIGINT=$(emcc_enable_bigint)
 
 $(sqlite3-wasmfs.js): $(sqlite3-wasmfs.wasm.c) $(sqlite3-wasm.c) $(sqlite3-wasmfs.extra.c) \
     EXPORTED_FUNCTIONS.api $(sqlite3-wasm.js) $(MAKEFILE) $(MAKEFILE.wasmfs) \
index da44ff671fe541b199e5bf14bed6f83090735af5..6c44e891e82ec94f538f6d42295bba3c6944dc4c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C shell.c.in:\swhen\sbuilding\sin\sfiddle\smode,\sdefine\s_POSIX_SOURCE\s(ifndef)\sso\sthat\semcc's\sstring.h\sreveals\sstrdup().
-D 2022-09-21T16:21:21.314
+C Put\spieces\sin\splace\sfor\sfiddle\sto\ssupport\sopfs,\sbut\smore\scleanup\sis\srequired\sin\sthe\ssqlite3.js/fiddle\sconnection.\sbigIntEnabled\snow\sdefaults\sto\swhether\sthe\sEmscripten's\smodule\shas\sbigint\senabled.\sAdd\swasm-sensible\sdefaults\sfor\sseveral\sSQLITE_ENABLE/OMIT\sflags\sin\ssqlite3-wasm.c.
+D 2022-09-21T19:51:25.111
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -473,8 +473,8 @@ 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 7fb73f7150ab79d83bb45a67d257553c905c78cd3d693101699243f36c5ae6c3
-F ext/wasm/EXPORTED_RUNTIME_METHODS.fiddle a004bd5eeeda6d3b28d16779b7f1a80305bfe009dfc7f0721b042967f0d39d02
-F ext/wasm/GNUmakefile 45b2815443729ed7de33acb4a2716038f8a41005529cd96bac81f7f0d97d1ded
+F ext/wasm/EXPORTED_RUNTIME_METHODS.fiddle 0e88c8cfc3719e4b7e74980d9da664c709e68acf863e48386cda376edfd3bfb0
+F ext/wasm/GNUmakefile 592baa34fba8dc4e272b19c44e768fc1f66c36f96343bb581f02d2fc663192e0
 F ext/wasm/README.md e1ee1e7c321c6a250bf78a84ca6f5882890a237a450ba5a0649c7a8399194c52
 F ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-api 8a724a674bd2089eef9676b434c0ab709da00db33f73a94e4987e90169b1cd14
 F ext/wasm/api/EXPORTED_RUNTIME_METHODS.sqlite3-api 1ec3c73e7d66e95529c3c64ac3de2470b0e9e7fbf7a5b41261c367cf4f1b7287
@@ -485,10 +485,10 @@ F ext/wasm/api/sqlite3-api-cleanup.js 8564a6077cdcaea9a9f428a019af8a05887f0131e6
 F ext/wasm/api/sqlite3-api-glue.js 366d580c8e5bf7fcf4c6dee6f646c31f5549bd417ea03a59a0acca00e8ecce30
 F ext/wasm/api/sqlite3-api-oo1.js f974e79d9af8f26bf33928c5730b0988cc706d14f59a5fe36394739b92249841
 F ext/wasm/api/sqlite3-api-opfs.js d623ea3519cd81fe18e243adfdd07cd1fa4b07ff3b0fd0d2b269beb0e127acb3
-F ext/wasm/api/sqlite3-api-prologue.js 6f3a67c4db37e884d33a05e5cf6d9d9bc012226a18c09f33f662fefd99840a63
+F ext/wasm/api/sqlite3-api-prologue.js 76fcd56005717cf4ef6c57cee4d7679c9a5fa8c060110485c1318f5b548abac8
 F ext/wasm/api/sqlite3-api-worker1.js 2eeb2a24e1a90322d84a9b88a99919b806623de62792436446099c0988f2030b
 F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
-F ext/wasm/api/sqlite3-wasm.c 9401a3f9bd191a410b4f679b7957c6b7e168a68106f52ddeafa1c776d0364e49
+F ext/wasm/api/sqlite3-wasm.c d1c0724136480a459d9dda4b76a665691a172d5cba96729d26d26acf6480bc9b
 F ext/wasm/batch-runner.html 2857a6db7292ac83d1581af865d643fd34235db2df830d10b43b01388c599e04
 F ext/wasm/batch-runner.js 6f5b86e0b5519a9a941d9f17ee9c5ecdc63f452f157602fe7fdf87f6275a2b49
 F ext/wasm/common/SqliteTestUtil.js 529161a624265ba84271a52db58da022649832fa1c71309fb1e02cc037327a2b
@@ -500,11 +500,11 @@ F ext/wasm/demo-123.html aa281d33b7eefa755f3122b7b5a18f39a42dc5fb69c8879171bf14b
 F ext/wasm/demo-123.js 234655683e35a4543a23de7b10800d76b0369947b33e089e5613171fa7795afb
 F ext/wasm/demo-kvvfs1.html 7d4f28873de67f51ac18c584b7d920825139866a96049a49c424d6f5a0ea5e7f
 F ext/wasm/demo-kvvfs1.js e884ea35022d772c0d1dd884b40011413696438394f605c6cd4808cfb1642a4a
-F ext/wasm/fiddle.make 8b1018e8d91b6d3add93813302a4acf2e5693dd9882499e38eccaec73afb1f79
+F ext/wasm/fiddle.make fd56fa21bada6ecbf860686a9a789ebda7cc3d9b60835927000fcb00246ea50f
 F ext/wasm/fiddle/emscripten.css 3d253a6fdb8983a2ac983855bfbdd4b6fa1ff267c28d69513dd6ef1f289ada3f
-F ext/wasm/fiddle/fiddle-worker.js bccf46045be8824752876f3eec01c223be0616ccac184bffd0024cfe7a3262b8
-F ext/wasm/fiddle/fiddle.html 550c5aafce40bd218de9bf26192749f69f9b10bc379423ecd2e162bcef885c08
-F ext/wasm/fiddle/fiddle.js 4ffcfc9a235beebaddec689a549e9e0dfad6dca5c1f0b41f03468d7e76480686
+F ext/wasm/fiddle/fiddle-worker.js 3a258f7c79f36958d8f63bceb3dd178bb2dfc6a802329e9349612ecb1d9fcd09
+F ext/wasm/fiddle/fiddle.html 5daf54e8f3d7777cbb1ca4f93affe28858dbfff25841cb4ab81d694efed28ec2
+F ext/wasm/fiddle/fiddle.js dae246414ebd56ecdc09cf95c43b2d50e1332a331832a27915782c7767f92f45
 F ext/wasm/index.html 8b4b7ea052d558262c8466f94326fb455c21049b2d1d3577ed0a5fce15101ba8
 F ext/wasm/jaccwabyt/jaccwabyt.js 0d7f32817456a0f3937fcfd934afeb32154ca33580ab264dab6c285e6dbbd215
 F ext/wasm/jaccwabyt/jaccwabyt.md 447cc02b598f7792edaa8ae6853a7847b8178a18ed356afacbdbf312b2588106
@@ -530,7 +530,7 @@ F ext/wasm/testing1.html 50575755e43232dbe4c2f97c9086b3118eb91ec2ee1fae931e6d766
 F ext/wasm/testing1.js 507001a970fe8a8eb67b6c8d783e1c1daa3db2719f727c4551af29349410e538
 F ext/wasm/testing2.html a66951c38137ff1d687df79466351f3c734fa9c6d9cce71d3cf97c291b2167e3
 F ext/wasm/testing2.js 25584bcc30f19673ce13a6f301f89f8820a59dfe044e0c4f2913941f4097fe3c
-F ext/wasm/wasmfs.make b24fa0199ddf9720ae8b0c7751a5dbdb2501c8d7c57ecf8c2e0a80ebf4b2d00b
+F ext/wasm/wasmfs.make 52f24bc9c10e404d26bd0b0ee28d450269808a78e359d6ddedc45d31e7b9c29c
 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
@@ -2026,8 +2026,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 86e2b55ec9483fa5add51a479c6509d73461f1ac6fca5d49e057b1c66f4314d2
-R e68dc13d6d9761750c3d366ba59d0406
+P fb85b269c43147f153977606dd8ede7b93744bf955e4c1a2b198907fd8a94620
+R 353052de95c54515940c8efa7fbb5d76
 U stephan
-Z b0eba7fb6b60a68e1a0205556e35b01a
+Z 6e975524f2561f74f6e19ffa720f7e6c
 # Remove this line to create a well-formed Fossil manifest.
index 398f42223619c0fd3230d4a6b1103c7217e59932..d64a3ada8cb8ab9d87c63e59bb62a085648577d1 100644 (file)
@@ -1 +1 @@
-fb85b269c43147f153977606dd8ede7b93744bf955e4c1a2b198907fd8a94620
\ No newline at end of file
+7c7fb7535e86b3960eea7f29ab7e6d5197c166b4ee64ad4a9bc0749f2869badc
\ No newline at end of file