@@ -525,6 +525,7 @@ TESTSRC2 = \
525525 $(TOP ) /src/pcache1.c \
526526 $(TOP ) /src/select.c \
527527 $(TOP ) /src/tokenize.c \
528+ $(TOP ) /src/treeview.c \
528529 $(TOP ) /src/utf.c \
529530 $(TOP ) /src/util.c \
530531 $(TOP ) /src/vdbeapi.c \
@@ -652,7 +653,7 @@ FUZZCHECK_OPT += -DSQLITE_ENABLE_RTREE
652653FUZZCHECK_OPT += -DSQLITE_ENABLE_GEOPOLY
653654FUZZCHECK_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
654655FUZZCHECK_OPT += -DSQLITE_ENABLE_BYTECODE_VTAB
655- FUZZCHECK_SRC = $(TOP ) /test/fuzzcheck.c $(TOP ) /test/ossfuzz.c
656+ FUZZCHECK_SRC = $(TOP ) /test/fuzzcheck.c $(TOP ) /test/ossfuzz.c $( TOP ) /test/fuzzinvariants.c
656657DBFUZZ_OPT =
657658
658659# This is the default Makefile target. The objects listed here
@@ -911,7 +912,7 @@ hash.lo: $(TOP)/src/hash.c $(HDR)
911912insert.lo : $(TOP ) /src/insert.c $(HDR )
912913 $(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/insert.c
913914
914- json.lo : $(TOP ) /src/json.c
915+ json.lo : $(TOP ) /src/json.c $( HDR )
915916 $(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/json.c
916917
917918legacy.lo : $(TOP ) /src/legacy.c $(HDR )
@@ -1549,3 +1550,134 @@ sqlite3.def: $(REAL_LIBOBJ)
15491550sqlite3.dll : $(REAL_LIBOBJ ) sqlite3.def
15501551 $(TCC ) -shared -o $@ sqlite3.def \
15511552 -Wl," --strip-all" $(REAL_LIBOBJ )
1553+
1554+
1555+ #
1556+ # fiddle/wasm section
1557+ #
1558+ fiddle_dir = ext/fiddle
1559+ fiddle_dir_abs = $(TOP ) /$(fiddle_dir )
1560+ # ^^^ some emcc opts require absolute paths
1561+ fiddle_html = $(fiddle_dir ) /fiddle.html
1562+ fiddle_module_js = $(fiddle_dir ) /fiddle-module.js
1563+ sqlite3_wasm_js = $(fiddle_dir ) /sqlite3.js
1564+ sqlite3_wasm = $(fiddle_dir ) /sqlite3.wasm
1565+ # emcc_opt = -O0
1566+ # emcc_opt = -O1
1567+ # emcc_opt = -O2
1568+ # emcc_opt = -O3
1569+ emcc_opt = -Oz
1570+ emcc_flags = $(emcc_opt ) -sALLOW_TABLE_GROWTH -sSTRICT_JS \
1571+ -sENVIRONMENT=web -sMODULARIZE \
1572+ -sEXPORTED_RUNTIME_METHODS=@$(fiddle_dir_abs ) /EXPORTED_RUNTIME_METHODS \
1573+ -sDYNAMIC_EXECUTION=0 \
1574+ -I. $(SHELL_OPT )
1575+ $(fiddle_module_js ) : Makefile sqlite3.c shell.c \
1576+ $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
1577+ $(fiddle_dir)/EXPORTED_FUNCTIONS.fiddle
1578+ emcc -o $@ $(emcc_flags) \
1579+ -sEXPORT_NAME =initFiddleModule \
1580+ -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs ) /EXPORTED_FUNCTIONS.fiddle \
1581+ sqlite3.c shell.c
1582+ gzip < $@ > $@.gz
1583+ gzip < $(fiddle_dir)/fiddle-module.wasm > $(fiddle_dir)/fiddle-module.wasm.gz
1584+ $(sqlite3_wasm_js ) : Makefile sqlite3.c \
1585+ $(fiddle_dir)/sqlite3-api.js \
1586+ $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
1587+ $(fiddle_dir)/EXPORTED_FUNCTIONS.sqlite3-api
1588+ emcc -o $@ $(emcc_flags) \
1589+ -sEXPORT_NAME =initSqlite3Module \
1590+ -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs ) /EXPORTED_FUNCTIONS.sqlite3-api \
1591+ --post-js=$(fiddle_dir ) /sqlite3-api.js \
1592+ --no-entry \
1593+ sqlite3.c
1594+ gzip < $@ > $@.gz
1595+ gzip < $(sqlite3_wasm) > $(sqlite3_wasm).gz
1596+ gzip < $(fiddle_dir)/sqlite3-api.js > $(fiddle_dir)/sqlite3-api.js.gz
1597+ $(fiddle_dir ) /fiddle.js.gz : $(fiddle_dir ) /fiddle.js
1598+ gzip < $< > $@
1599+ $(fiddle_dir ) /sqlite3-api.js.gz : $(fiddle_dir ) /sqlite3-api.js
1600+ gzip < $< > $@
1601+
1602+ fiddle_generated = $(fiddle_module_js ) $(fiddle_module_js ) .gz \
1603+ $(fiddle_dir ) /fiddle-module.wasm \
1604+ $(fiddle_dir ) /fiddle-module.wasm.gz \
1605+ $(fiddle_dir ) /fiddle.js.gz
1606+ sqlite3_wasm_generated = \
1607+ $(sqlite3_wasm ) $(sqlite3_wasm ) .gz \
1608+ $(sqlite3_wasm_js ) $(sqlite3_wasm_js ) .gz \
1609+ $(fiddle_dir ) /sqlite3.js.gz \
1610+ $(fiddle_dir ) /sqlite3-api.js.gz
1611+
1612+ clean-wasm :
1613+ rm -f $(fiddle_generated ) $(sqlite3_wasm_generated )
1614+ clean : clean-wasm
1615+ fiddle : $(fiddle_module_js ) $(fiddle_dir ) /fiddle.js.gz
1616+ sqlite3-wasm : $(sqlite3_wasm_js )
1617+ wasm : fiddle sqlite3-wasm
1618+ # #######################################################################
1619+ # Explanation of the emcc build flags follows. Full docs for these can
1620+ # be found at:
1621+ #
1622+ # https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
1623+ #
1624+ # -sENVIRONMENT=web: elides bootstrap code related to non-web JS
1625+ # environments like node.js. Removing this makes the output a tiny
1626+ # tick larger but hypothetically makes it more portable to
1627+ # non-browser JS environments.
1628+ #
1629+ # -sMODULARIZE: changes how the generated code is structured to avoid
1630+ # declaring a global Module object and instead installing a function
1631+ # which loads and initialized the module. The function is named...
1632+ #
1633+ # -sEXPORT_NAME=jsFunctionName (see -sMODULARIZE)
1634+ #
1635+ # -sEXPORTED_RUNTIME_METHODS=@/absolute/path/to/file: a file
1636+ # containing a list of emscripten-supplied APIs, one per line, which
1637+ # must be exported into the generated JS. Must be an absolute path!
1638+ #
1639+ # -sEXPORTED_FUNCTIONS=@/absolute/path/to/file: a file containing a
1640+ # list of C functions, one per line, which must be exported via wasm
1641+ # so they're visible to JS. C symbols names in that file must all
1642+ # start with an underscore for reasons known only to the emcc
1643+ # developers. e.g., _sqlite3_open_v2 and _sqlite3_finalize. Must be
1644+ # an absolute path!
1645+ #
1646+ # -sSTRICT_JS ensures that the emitted JS code includes the 'use
1647+ # strict' option. Note that -sSTRICT is more broadly-scoped and
1648+ # results in build errors.
1649+ #
1650+ # -sALLOW_TABLE_GROWTH is required for (at a minimum) the UDF-binding
1651+ # feature.
1652+ #
1653+ # -sDYNAMIC_EXECUTION=0 disables eval() and the Function constructor.
1654+ # If the build runs without these, it's preferable to use this flag
1655+ # because certain execution environments disallow those constructs.
1656+ # This flag is not strictly necessary, however.
1657+ #
1658+ # -sWASM_BIGINT is UNTESTED but "should" allow the int64-using C APIs
1659+ # to work with JS/wasm, insofar as the JS environment supports the
1660+ # BigInt type. That support requires an extremely recent browser:
1661+ # Safari didn't get that support until late 2020.
1662+ #
1663+ # --no-entry: for compiling library code with no main(). If this is
1664+ # not supplied and the code has a main(), it is called as part of the
1665+ # module init process. Note that main() is #if'd out of shell.c
1666+ # (renamed) when building in wasm mode.
1667+ #
1668+ # --pre-js/--post-js=FILE relative or absolute paths to JS files to
1669+ # prepend/append to the emcc-generated bootstrapping JS. It's
1670+ # easier/faster to develop with separate JS files (reduces rebuilding
1671+ # requirements) but certain configurations, namely -sMODULARIZE, may
1672+ # require using at least a --pre-js file. They can be used
1673+ # individually and need not be paired.
1674+ #
1675+ # -O0..-O3 and -Oz: optimization levels affect not only C-style
1676+ # optimization but whether or not the resulting generated JS code
1677+ # gets minified. -O0 compiles _much_ more quickly than -O3 or -Oz,
1678+ # and doesn't minimize any JS code, so is recommended for
1679+ # development. -O3 or -Oz are recommended for deployment, but
1680+ # primarily because -Oz will shrink the wasm file notably. JS-side
1681+ # minification makes little difference in terms of overall
1682+ # distributable size.
1683+ # #######################################################################
0 commit comments