0
0
mirror of https://github.com/sqlite/sqlite.git synced 2024-12-01 01:01:28 +01:00
sqlite/ext/wasm
drh 010f9f8704 Remove a few more traces of long double from the code.
FossilOrigin-Name: 11d6a89e4a25c3f884ff617036d239dc42522859400cd1f4674634f6c7adbb02
2024-10-02 11:34:11 +00:00
..
api Remove a few more traces of long double from the code. 2024-10-02 11:34:11 +00:00
common
fiddle Fix fiddle build broken by recent build-level reworks. Remove a stale reference to an old CSS file. 2024-09-27 23:45:40 +00:00
jaccwabyt
sql
SQLTester
tests/opfs/concurrency Add several convenience links to the OPFS VFS concurrency tester app for launching it with various combinations of options. 2024-07-13 01:40:36 +00:00
batch-runner-sahpool.html
batch-runner-sahpool.js
batch-runner.html
batch-runner.js
c-pp.c Further wasm build cleanups and tweaks. No functional changes. 2024-09-24 00:31:08 +00:00
demo-123-worker.html
demo-123.html
demo-123.js
demo-jsstorage.html
demo-jsstorage.js
demo-worker1-promiser.c-pp.html
demo-worker1-promiser.c-pp.js
demo-worker1.html
demo-worker1.js
dist.make
example_extra_init.c
EXPORTED_FUNCTIONS.fiddle.in
fiddle.make wasm: move the makefile-eval-generated fiddle rules into mkwasmbuilds.c. Squelch some warnings from grep when running 'make clean' on a clean tree. 2024-09-28 12:01:10 +00:00
GNUmakefile Remove a few more traces of long double from the code. 2024-10-02 11:34:11 +00:00
index-dist.html
index.html Minor wasmfs speedtest1 build tweaks. Disable one wasmfs demo which was broken by Emscripten-side changes. 2024-09-24 21:54:37 +00:00
mkwasmbuilds.c wasm: move the makefile-eval-generated fiddle rules into mkwasmbuilds.c. Squelch some warnings from grep when running 'make clean' on a clean tree. 2024-09-28 12:01:10 +00:00
module-symbols.html
README-dist.txt
README.md
scratchpad-wasmfs.html
scratchpad-wasmfs.mjs
speedtest1-wasmfs.html
speedtest1-wasmfs.mjs wasm: replace much of the eval makefile spaghetti with equivalent code generated from a small C app. It turns out that's easier to read and write than doing the same thing from shell or tcl code, due entirely to C's lack of need for escaping dollar signs. 2024-09-23 21:22:09 +00:00
speedtest1-worker.html
speedtest1-worker.js
speedtest1.html
split-speedtest1-script.sh
test-opfs-vfs.html
test-opfs-vfs.js
tester1-worker.html
tester1.c-pp.html
tester1.c-pp.js Fix a non-bare-bones-mode test case broken by the previous checkin. 2024-07-25 16:28:55 +00:00
wasmfs.make Minor makefile doc fixes. No functional changes. 2024-09-28 00:39:19 +00:00

This directory houses the Web Assembly (WASM) parts of the sqlite3 build.

It requires emscripten and that the build environment be set up for emscripten. A mini-HOWTO for setting that up follows...

First, install the Emscripten SDK, as documented here and summarized below for Linux environments:

# Clone the emscripten repository:
$ sudo apt install git
$ git clone https://github.com/emscripten-core/emsdk.git
$ cd emsdk

# Download and install the latest SDK tools:
$ ./emsdk install latest

# Make the "latest" SDK "active" for the current user:
$ ./emsdk activate latest

Those parts only need to be run once, but the SDK can be updated using:

$ git pull
$ ./emsdk install latest
$ ./emsdk activate latest

The following needs to be run for each shell instance which needs the emcc compiler:

# Activate PATH and other environment variables in the current terminal:
$ source ./emsdk_env.sh

$ which emcc
/path/to/emsdk/upstream/emscripten/emcc

Optionally, add that to your login shell's resource file (~/.bashrc or equivalent).

That env script needs to be sourced for building this application from the top of the sqlite3 build tree:

$ make fiddle

Or:

$ cd ext/wasm
$ make

That will generate the a number of files required for a handful of test and demo applications which can be accessed via index.html. WASM content cannot, due to XMLHttpRequest security limitations, be loaded if the containing HTML file is opened directly in the browser (i.e. if it is opened using a file:// URL), so it needs to be served via an HTTP server. For example, using althttpd:

$ cd ext/wasm
$ althttpd --enable-sab --max-age 1 --page index.html

That will open the system's browser and run the index page, from which all of the test and demo applications can be accessed.

Note that when serving this app via althttpd, it must be a version from 2022-09-26 or newer so that it recognizes the --enable-sab flag, which causes althttpd to emit two HTTP response headers which are required to enable JavaScript's SharedArrayBuffer and Atomics APIs. Those APIs are required in order to enable the OPFS-related features in the apps which use them.

Testing on a remote machine that is accessed via SSH

NB: The following are developer notes, last validated on 2023-07-19

  • Remote: Install git, emsdk, and althttpd
  • Remote: Install the SQLite source tree. CD to ext/wasm
  • Remote: "make" to build WASM
  • Remote: althttpd --enable-sab --port 8080 --popup
  • Local: ssh -L 8180:localhost:8080 remote
  • Local: Point your web-browser at http://localhost:8180/index.html

In order to enable SharedArrayBuffer, the web-browser requires that the two extra Cross-Origin lines be present in HTTP reply headers and that the request must come from "localhost" (or over an SSL connection). Since the web-server is on a different machine from the web-broser, the localhost requirement means that the connection must be tunneled using SSH.