@@ -503,6 +503,7 @@ TESTSRC2 = \
503503 $(TOP ) /src/pcache1.c \
504504 $(TOP ) /src/select.c \
505505 $(TOP ) /src/tokenize.c \
506+ $(TOP ) /src/treeview.c \
506507 $(TOP ) /src/utf.c \
507508 $(TOP ) /src/util.c \
508509 $(TOP ) /src/vdbeapi.c \
@@ -630,7 +631,7 @@ FUZZCHECK_OPT += -DSQLITE_ENABLE_RTREE
630631FUZZCHECK_OPT += -DSQLITE_ENABLE_GEOPOLY
631632FUZZCHECK_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
632633FUZZCHECK_OPT += -DSQLITE_ENABLE_BYTECODE_VTAB
633- FUZZCHECK_SRC = $(TOP ) /test/fuzzcheck.c $(TOP ) /test/ossfuzz.c
634+ FUZZCHECK_SRC = $(TOP ) /test/fuzzcheck.c $(TOP ) /test/ossfuzz.c $( TOP ) /test/fuzzinvariants.c
634635DBFUZZ_OPT =
635636
636637# This is the default Makefile target. The objects listed here
@@ -874,7 +875,7 @@ hash.lo: $(TOP)/src/hash.c $(HDR)
874875insert.lo : $(TOP ) /src/insert.c $(HDR )
875876 $(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/insert.c
876877
877- json.lo : $(TOP ) /src/json.c
878+ json.lo : $(TOP ) /src/json.c $( HDR )
878879 $(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/json.c
879880
880881legacy.lo : $(TOP ) /src/legacy.c $(HDR )
@@ -1512,3 +1513,134 @@ sqlite3.def: $(REAL_LIBOBJ)
15121513sqlite3.dll : $(REAL_LIBOBJ ) sqlite3.def
15131514 $(TCC ) -shared -o $@ sqlite3.def \
15141515 -Wl," --strip-all" $(REAL_LIBOBJ )
1516+
1517+
1518+ #
1519+ # fiddle/wasm section
1520+ #
1521+ fiddle_dir = ext/fiddle
1522+ fiddle_dir_abs = $(TOP ) /$(fiddle_dir )
1523+ # ^^^ some emcc opts require absolute paths
1524+ fiddle_html = $(fiddle_dir ) /fiddle.html
1525+ fiddle_module_js = $(fiddle_dir ) /fiddle-module.js
1526+ sqlite3_wasm_js = $(fiddle_dir ) /sqlite3.js
1527+ sqlite3_wasm = $(fiddle_dir ) /sqlite3.wasm
1528+ # emcc_opt = -O0
1529+ # emcc_opt = -O1
1530+ # emcc_opt = -O2
1531+ # emcc_opt = -O3
1532+ emcc_opt = -Oz
1533+ emcc_flags = $(emcc_opt ) -sALLOW_TABLE_GROWTH -sSTRICT_JS \
1534+ -sENVIRONMENT=web -sMODULARIZE \
1535+ -sEXPORTED_RUNTIME_METHODS=@$(fiddle_dir_abs ) /EXPORTED_RUNTIME_METHODS \
1536+ -sDYNAMIC_EXECUTION=0 \
1537+ -I. $(SHELL_OPT )
1538+ $(fiddle_module_js ) : Makefile sqlite3.c shell.c \
1539+ $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
1540+ $(fiddle_dir)/EXPORTED_FUNCTIONS.fiddle
1541+ emcc -o $@ $(emcc_flags) \
1542+ -sEXPORT_NAME =initFiddleModule \
1543+ -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs ) /EXPORTED_FUNCTIONS.fiddle \
1544+ sqlite3.c shell.c
1545+ gzip < $@ > $@.gz
1546+ gzip < $(fiddle_dir)/fiddle-module.wasm > $(fiddle_dir)/fiddle-module.wasm.gz
1547+ $(sqlite3_wasm_js ) : Makefile sqlite3.c \
1548+ $(fiddle_dir)/sqlite3-api.js \
1549+ $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
1550+ $(fiddle_dir)/EXPORTED_FUNCTIONS.sqlite3-api
1551+ emcc -o $@ $(emcc_flags) \
1552+ -sEXPORT_NAME =initSqlite3Module \
1553+ -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs ) /EXPORTED_FUNCTIONS.sqlite3-api \
1554+ --post-js=$(fiddle_dir ) /sqlite3-api.js \
1555+ --no-entry \
1556+ sqlite3.c
1557+ gzip < $@ > $@.gz
1558+ gzip < $(sqlite3_wasm) > $(sqlite3_wasm).gz
1559+ gzip < $(fiddle_dir)/sqlite3-api.js > $(fiddle_dir)/sqlite3-api.js.gz
1560+ $(fiddle_dir ) /fiddle.js.gz : $(fiddle_dir ) /fiddle.js
1561+ gzip < $< > $@
1562+ $(fiddle_dir ) /sqlite3-api.js.gz : $(fiddle_dir ) /sqlite3-api.js
1563+ gzip < $< > $@
1564+
1565+ fiddle_generated = $(fiddle_module_js ) $(fiddle_module_js ) .gz \
1566+ $(fiddle_dir ) /fiddle-module.wasm \
1567+ $(fiddle_dir ) /fiddle-module.wasm.gz \
1568+ $(fiddle_dir ) /fiddle.js.gz
1569+ sqlite3_wasm_generated = \
1570+ $(sqlite3_wasm ) $(sqlite3_wasm ) .gz \
1571+ $(sqlite3_wasm_js ) $(sqlite3_wasm_js ) .gz \
1572+ $(fiddle_dir ) /sqlite3.js.gz \
1573+ $(fiddle_dir ) /sqlite3-api.js.gz
1574+
1575+ clean-wasm :
1576+ rm -f $(fiddle_generated ) $(sqlite3_wasm_generated )
1577+ clean : clean-wasm
1578+ fiddle : $(fiddle_module_js ) $(fiddle_dir ) /fiddle.js.gz
1579+ sqlite3-wasm : $(sqlite3_wasm_js )
1580+ wasm : fiddle sqlite3-wasm
1581+ # #######################################################################
1582+ # Explanation of the emcc build flags follows. Full docs for these can
1583+ # be found at:
1584+ #
1585+ # https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
1586+ #
1587+ # -sENVIRONMENT=web: elides bootstrap code related to non-web JS
1588+ # environments like node.js. Removing this makes the output a tiny
1589+ # tick larger but hypothetically makes it more portable to
1590+ # non-browser JS environments.
1591+ #
1592+ # -sMODULARIZE: changes how the generated code is structured to avoid
1593+ # declaring a global Module object and instead installing a function
1594+ # which loads and initialized the module. The function is named...
1595+ #
1596+ # -sEXPORT_NAME=jsFunctionName (see -sMODULARIZE)
1597+ #
1598+ # -sEXPORTED_RUNTIME_METHODS=@/absolute/path/to/file: a file
1599+ # containing a list of emscripten-supplied APIs, one per line, which
1600+ # must be exported into the generated JS. Must be an absolute path!
1601+ #
1602+ # -sEXPORTED_FUNCTIONS=@/absolute/path/to/file: a file containing a
1603+ # list of C functions, one per line, which must be exported via wasm
1604+ # so they're visible to JS. C symbols names in that file must all
1605+ # start with an underscore for reasons known only to the emcc
1606+ # developers. e.g., _sqlite3_open_v2 and _sqlite3_finalize. Must be
1607+ # an absolute path!
1608+ #
1609+ # -sSTRICT_JS ensures that the emitted JS code includes the 'use
1610+ # strict' option. Note that -sSTRICT is more broadly-scoped and
1611+ # results in build errors.
1612+ #
1613+ # -sALLOW_TABLE_GROWTH is required for (at a minimum) the UDF-binding
1614+ # feature.
1615+ #
1616+ # -sDYNAMIC_EXECUTION=0 disables eval() and the Function constructor.
1617+ # If the build runs without these, it's preferable to use this flag
1618+ # because certain execution environments disallow those constructs.
1619+ # This flag is not strictly necessary, however.
1620+ #
1621+ # -sWASM_BIGINT is UNTESTED but "should" allow the int64-using C APIs
1622+ # to work with JS/wasm, insofar as the JS environment supports the
1623+ # BigInt type. That support requires an extremely recent browser:
1624+ # Safari didn't get that support until late 2020.
1625+ #
1626+ # --no-entry: for compiling library code with no main(). If this is
1627+ # not supplied and the code has a main(), it is called as part of the
1628+ # module init process. Note that main() is #if'd out of shell.c
1629+ # (renamed) when building in wasm mode.
1630+ #
1631+ # --pre-js/--post-js=FILE relative or absolute paths to JS files to
1632+ # prepend/append to the emcc-generated bootstrapping JS. It's
1633+ # easier/faster to develop with separate JS files (reduces rebuilding
1634+ # requirements) but certain configurations, namely -sMODULARIZE, may
1635+ # require using at least a --pre-js file. They can be used
1636+ # individually and need not be paired.
1637+ #
1638+ # -O0..-O3 and -Oz: optimization levels affect not only C-style
1639+ # optimization but whether or not the resulting generated JS code
1640+ # gets minified. -O0 compiles _much_ more quickly than -O3 or -Oz,
1641+ # and doesn't minimize any JS code, so is recommended for
1642+ # development. -O3 or -Oz are recommended for deployment, but
1643+ # primarily because -Oz will shrink the wasm file notably. JS-side
1644+ # minification makes little difference in terms of overall
1645+ # distributable size.
1646+ # #######################################################################
0 commit comments