1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Rework the fiddle build to build separate debug and non-debug bundles, with the latter in ./fiddle-debug.

FossilOrigin-Name: a9f1758f1cbe7b7d0c87dfb060f52d03c6ea0e066c079891a8ff354073997f9e
This commit is contained in:
stephan
2024-06-18 21:50:30 +00:00
parent 98526f906e
commit e042988dc0
4 changed files with 50 additions and 32 deletions

View File

@ -139,8 +139,10 @@ dir.api := api
dir.jacc := jaccwabyt
dir.common := common
dir.fiddle := fiddle
dir.fiddle-debug := fiddle-debug
dir.tool := $(dir.top)/tool
CLEAN_FILES += *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~ $(dir.fiddle)/*~
CLEAN_FILES += *~ $(dir.jacc)/*~ $(dir.api)/*~ $(dir.common)/*~ $(dir.fiddle)/*~ \
$(dir.fiddle-debug)/*
########################################################################
# dir.dout = output dir for deliverables.

View File

@ -46,8 +46,10 @@ fiddle.emcc-flags = \
# -D_POSIX_C_SOURCE is needed for strdup() with emcc
# Flags specifically for debug builds of fiddle. Performance suffers
# greatly with these enabled.
fiddle.emcc-flags.debug := -DSQLITE_DEBUG \
# greatly in debug builds.
fiddle.emcc-flags.debug := $(fiddle.emcc-flags) \
-O0 -g \
-DSQLITE_DEBUG \
-DSQLITE_ENABLE_SELECTTRACE \
-DSQLITE_ENABLE_WHERETRACE
@ -58,27 +60,42 @@ fiddle.EXPORTED_FUNCTIONS.in := \
$(EXPORTED_FUNCTIONS.fiddle): $(fiddle.EXPORTED_FUNCTIONS.in) $(MAKEFILE.fiddle)
sort -u $(fiddle.EXPORTED_FUNCTIONS.in) > $@
fiddle-module.js := $(dir.fiddle)/fiddle-module.js
fiddle-module.wasm := $(subst .js,.wasm,$(fiddle-module.js))
fiddle.cses := $(dir.top)/shell.c $(sqlite3-wasm.c)
fiddle.SOAP.js := $(dir.fiddle)/$(notdir $(SOAP.js))
$(fiddle.SOAP.js): $(SOAP.js)
cp $< $@
$(eval $(call call-make-pre-post,fiddle-module,vanilla))
$(fiddle-module.js): $(MAKEFILE) $(MAKEFILE.fiddle) \
$(EXPORTED_FUNCTIONS.fiddle) \
$(fiddle.cses) $(pre-post-fiddle-module-vanilla.deps) $(fiddle.SOAP.js)
$(emcc.bin) -o $@ $(fiddle.emcc-flags) \
$(pre-post-fiddle-module-vanilla.flags) \
$(fiddle.cses)
$(maybe-wasm-strip) $(fiddle-module.wasm)
gzip < $@ > $@.gz
gzip < $(fiddle-module.wasm) > $(fiddle-module.wasm).gz
$(dir.fiddle)/fiddle.js.gz: $(dir.fiddle)/fiddle.js
gzip < $< > $@
########################################################################
# emit rules for one of the two fiddle builds. $1 must be
# either $(dir.fiddle) or $(dir.fiddle-debug). $2 must be empty
# in the former case and .debug in the latter.
define make-fiddle-rules
fiddle-module.js$(2) := $(1)/fiddle-module.js
fiddle-module.wasm$(2) := $$(subst .js,.wasm,$$(fiddle-module.js$(2)))
$(1):
@test -d "$$@" || mkdir -p "$$@"
@if [[ x.debug = x$(2) ]]; then \
cp -p $$(dir.fiddle)/index.html \
$$(dir.fiddle)/fiddle.js \
$$(dir.fiddle)/fiddle-worker.js \
$$@/.; \
fi
$$(fiddle-module.js$(2)): $(1) $$(MAKEFILE) $$(MAKEFILE.fiddle) \
$$(EXPORTED_FUNCTIONS.fiddle) \
$$(fiddle.cses) $$(pre-post-fiddle-module-vanilla.deps) $$(fiddle.SOAP.js$(2))
$$(emcc.bin) -o $$@ $$(fiddle.emcc-flags$(2)) \
$$(pre-post-fiddle-module-vanilla.flags) \
$$(fiddle.cses)
$$(maybe-wasm-strip) $$(fiddle-module.wasm$(2))
cp -p $$(SOAP.js) $$(dir $$@)
gzip < $$@ > $$@.gz
gzip < $$(fiddle-module.wasm$(2)) > $$(fiddle-module.wasm$(2)).gz
gzip < $(1)/fiddle.js > $(1)/fiddle.js.gz
fiddle$(2): $$(fiddle-module.js$(2)) $(1)/fiddle.js.gz
endef
$(eval $(call make-fiddle-rules,$(dir.fiddle)))
$(eval $(call make-fiddle-rules,$(dir.fiddle-debug),.debug))
fiddle: $(fiddle-module.js) $(fiddle-module.js.debug)
fiddle.debug: $(fiddle-module.js.debug)
clean: clean-fiddle
clean-fiddle:
@ -87,9 +104,8 @@ clean-fiddle:
$(dir.fiddle)/$(SOAP.js) \
$(dir.fiddle)/fiddle-module.worker.js \
EXPORTED_FUNCTIONS.fiddle
.PHONY: fiddle
fiddle-debug fiddle: $(fiddle-module.js) $(dir.fiddle)/fiddle.js.gz
fiddle-debug: fiddle.emcc-flags+=$(fiddle.emcc-flags.debug)
rm -fr $(dir.fiddle-debug)
.PHONY: fiddle fiddle.debug
all: fiddle
########################################################################