diff options
author | stephan <stephan@noemail.net> | 2022-11-03 22:51:20 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-11-03 22:51:20 +0000 |
commit | 7d24ff29713e86730ffab173637fa022f24afca2 (patch) | |
tree | 917fe3e5152db3239609e26eb5ee52d80ba57e96 /ext/wasm | |
parent | 4df2ab575facacd8987b65078202cc638e0252ae (diff) | |
download | sqlite-7d24ff29713e86730ffab173637fa022f24afca2.tar.gz sqlite-7d24ff29713e86730ffab173637fa022f24afca2.zip |
Add experimental esm target to ext/wasm/GNUmakefile to tell emcc to generate sqlite3.mjs (ES6 module) instead of sqlite3.js. Related to discussion at [forum:ed4596cf8496a39b].
FossilOrigin-Name: e55d8eba83012492d85418dc0faedce5896027ecc70295a5ca1826f61a5edbaf
Diffstat (limited to 'ext/wasm')
-rw-r--r-- | ext/wasm/GNUmakefile | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/ext/wasm/GNUmakefile b/ext/wasm/GNUmakefile index 993c66869..039dff410 100644 --- a/ext/wasm/GNUmakefile +++ b/ext/wasm/GNUmakefile @@ -96,7 +96,7 @@ dir.dout := $(dir.wasm)/jswasm # dir.tmp = output dir for intermediary build files, as opposed to # end-user deliverables. dir.tmp := $(dir.wasm)/bld -#CLEAN_FILES += $(wildcard $(dir.dout)/*) $(wildcard $(dir.tmp)/*) +CLEAN_FILES += $(dir.tmp)/* $(dir.dout)/* ifeq (,$(wildcard $(dir.dout))) dir._tmp := $(shell mkdir -p $(dir.dout)) endif @@ -418,7 +418,20 @@ emcc.jsflags += -sWASM_BIGINT=$(emcc.WASM_BIGINT) # debugging info, _huge_. ######################################################################## -sqlite3.js := $(dir.dout)/sqlite3.js +######################################################################## +# AN EXPERIMENT: undocumented Emscripten feature: if the target file +# extension is "mjs", it defaults to ES6 module builds: +# https://github.com/emscripten-core/emscripten/issues/14383 +ifeq (,$(filter esm,$(MAKECMDGOALS))) +sqlite3.js.ext := js +else +esm.deps := $(filter-out esm,$(MAKECMDGOALS)) +esm: $(if $(esm.deps),$(esm.deps),all) +sqlite3.js.ext := mjs +endif +# /esm +######################################################################## +sqlite3.js := $(dir.dout)/sqlite3.$(sqlite3.js.ext) sqlite3.wasm := $(dir.dout)/sqlite3.wasm sqlite3-wasm.c := $(dir.api)/sqlite3-wasm.c # sqlite3-wasm.o vs sqlite3-wasm.c: building against the latter |