@@ -36,7 +36,7 @@ TCC += -I${TOP}/ext/fts3 -I${TOP}/ext/async -I${TOP}/ext/session
3636TCC += -I${TOP}/ext/userauth
3737
3838# Define this for the autoconf-based build, so that the code knows it can
39- # include the generated config .h
39+ # include the generated sqlite_cfg .h
4040#
4141TCC += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
4242
@@ -205,7 +205,7 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \
205205 main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \
206206 memdb.lo memjournal.lo \
207207 mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
208- notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \
208+ notify.lo opcodes.lo os.lo os_kv.lo os_unix.lo os_win.lo \
209209 pager.lo parse.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \
210210 random.lo resolve.lo rowset.lo rtree.lo \
211211 sqlite3session.lo select.lo sqlite3rbu.lo status.lo stmt.lo \
@@ -279,6 +279,7 @@ SRC = \
279279 $(TOP ) /src/os.h \
280280 $(TOP ) /src/os_common.h \
281281 $(TOP ) /src/os_setup.h \
282+ $(TOP ) /src/os_kv.c \
282283 $(TOP ) /src/os_unix.c \
283284 $(TOP ) /src/os_win.c \
284285 $(TOP ) /src/os_win.h \
@@ -399,7 +400,7 @@ SRC += \
399400 opcodes.h \
400401 parse.c \
401402 parse.h \
402- config .h \
403+ sqlite_cfg .h \
403404 shell.c \
404405 sqlite3.h
405406
@@ -455,6 +456,9 @@ TESTSRC = \
455456 $(TOP ) /ext/fts3/fts3_term.c \
456457 $(TOP ) /ext/fts3/fts3_test.c \
457458 $(TOP ) /ext/session/test_session.c \
459+ $(TOP ) /ext/recover/sqlite3recover.c \
460+ $(TOP ) /ext/recover/dbdata.c \
461+ $(TOP ) /ext/recover/test_recover.c \
458462 $(TOP ) /ext/rbu/test_rbu.c
459463
460464# Statically linked extensions
@@ -514,6 +518,7 @@ TESTSRC2 = \
514518 $(TOP ) /src/main.c \
515519 $(TOP ) /src/mem5.c \
516520 $(TOP ) /src/os.c \
521+ $(TOP ) /src/os_kv.c \
517522 $(TOP ) /src/os_unix.c \
518523 $(TOP ) /src/os_win.c \
519524 $(TOP ) /src/pager.c \
@@ -577,7 +582,7 @@ HDR = \
577582 $(TOP ) /src/vdbeInt.h \
578583 $(TOP ) /src/vxworks.h \
579584 $(TOP ) /src/whereInt.h \
580- config .h
585+ sqlite_cfg .h
581586
582587# Header files used by extensions
583588#
@@ -643,7 +648,10 @@ SHELL_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
643648SHELL_OPT += -DSQLITE_ENABLE_BYTECODE_VTAB
644649SHELL_OPT += -DSQLITE_ENABLE_OFFSET_SQL_FUNC
645650FUZZERSHELL_OPT =
646- FUZZCHECK_OPT = -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
651+ FUZZCHECK_OPT += -I$(TOP ) /test
652+ FUZZCHECK_OPT += -I$(TOP ) /ext/recover
653+ FUZZCHECK_OPT += -DSQLITE_OMIT_LOAD_EXTENSION
654+ FUZZCHECK_OPT += -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
647655FUZZCHECK_OPT += -DSQLITE_MAX_MEMORY=50000000
648656FUZZCHECK_OPT += -DSQLITE_PRINTF_PRECISION_LIMIT=1000
649657FUZZCHECK_OPT += -DSQLITE_ENABLE_FTS4
@@ -653,8 +661,14 @@ FUZZCHECK_OPT += -DSQLITE_ENABLE_RTREE
653661FUZZCHECK_OPT += -DSQLITE_ENABLE_GEOPOLY
654662FUZZCHECK_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
655663FUZZCHECK_OPT += -DSQLITE_ENABLE_BYTECODE_VTAB
656- FUZZCHECK_SRC = $(TOP ) /test/fuzzcheck.c $(TOP ) /test/ossfuzz.c $(TOP ) /test/fuzzinvariants.c
664+ FUZZCHECK_SRC += $(TOP ) /test/fuzzcheck.c
665+ FUZZCHECK_SRC += $(TOP ) /test/ossfuzz.c
666+ FUZZCHECK_SRC += $(TOP ) /test/fuzzinvariants.c
667+ FUZZCHECK_SRC += $(TOP ) /ext/recover/dbdata.c
668+ FUZZCHECK_SRC += $(TOP ) /ext/recover/sqlite3recover.c
669+ FUZZCHECK_SRC += $(TOP ) /test/vt02.c
657670DBFUZZ_OPT =
671+ ST_OPT = -DSQLITE_OS_KV_OPTIONAL
658672
659673# This is the default Makefile target. The objects listed here
660674# are what get build when you type just "make" with no arguments.
@@ -703,7 +717,7 @@ fuzzershell$(TEXE): $(TOP)/tool/fuzzershell.c sqlite3.c sqlite3.h
703717 $(LTLINK ) -o $@ $(FUZZERSHELL_OPT ) \
704718 $(TOP ) /tool/fuzzershell.c sqlite3.c $(TLIBS )
705719
706- fuzzcheck$(TEXE ) : $(FUZZCHECK_SRC ) sqlite3.c sqlite3.h
720+ fuzzcheck$(TEXE ) : $(FUZZCHECK_SRC ) sqlite3.c sqlite3.h $( FUZZCHECK_DEP )
707721 $(LTLINK ) -o $@ $(FUZZCHECK_OPT ) $(FUZZCHECK_SRC ) sqlite3.c $(TLIBS )
708722
709723ossshell$(TEXE ) : $(TOP ) /test/ossfuzz.c $(TOP ) /test/ossshell.c sqlite3.c sqlite3.h
@@ -975,6 +989,9 @@ pcache1.lo: $(TOP)/src/pcache1.c $(HDR) $(TOP)/src/pcache.h
975989os.lo : $(TOP ) /src/os.c $(HDR )
976990 $(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/os.c
977991
992+ os_kv.lo : $(TOP ) /src/os_kv.c $(HDR )
993+ $(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/os_kv.c
994+
978995os_unix.lo : $(TOP ) /src/os_unix.c $(HDR )
979996 $(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/os_unix.c
980997
@@ -1139,6 +1156,9 @@ SHELL_SRC = \
11391156 $(TOP ) /ext/expert/sqlite3expert.h \
11401157 $(TOP ) /ext/misc/zipfile.c \
11411158 $(TOP ) /ext/misc/memtrace.c \
1159+ $(TOP ) /ext/recover/dbdata.c \
1160+ $(TOP ) /ext/recover/sqlite3recover.c \
1161+ $(TOP ) /ext/recover/sqlite3recover.h \
11421162 $(TOP ) /src/test_windirent.c
11431163
11441164shell.c : $(SHELL_SRC ) $(TOP ) /tool/mkshellc.tcl
@@ -1318,6 +1338,12 @@ valgrindfuzz: fuzzcheck$(TEXT) $(FUZZDATA) sessionfuzz$(TEXE) $(TOP)/test/sessio
13181338tcltest : ./testfixture$(TEXE )
13191339 ./testfixture$(TEXE ) $(TOP ) /test/veryquick.test $(TESTOPTS )
13201340
1341+ # Runs all the same tests cases as the "tcltest" target but uses
1342+ # the testrunner.tcl script to run them in multiple cores
1343+ # concurrently.
1344+ testrunner : testfixture$(TEXE )
1345+ ./testfixture$(TEXE ) $(TOP ) /test/testrunner.tcl
1346+
13211347# Minimal testing that runs in less than 3 minutes
13221348#
13231349quicktest : ./testfixture$(TEXE )
@@ -1418,7 +1444,7 @@ LogEst$(TEXE): $(TOP)/tool/logest.c sqlite3.h
14181444wordcount$(TEXE ) : $(TOP ) /test/wordcount.c sqlite3.lo
14191445 $(LTLINK ) -o $@ $(TOP ) /test/wordcount.c sqlite3.lo $(TLIBS )
14201446
1421- speedtest1$(TEXE ) : $(TOP ) /test/speedtest1.c sqlite3.c
1447+ speedtest1$(TEXE ) : $(TOP ) /test/speedtest1.c sqlite3.c Makefile
14221448 $(LTLINK ) $(ST_OPT ) -o $@ $(TOP ) /test/speedtest1.c sqlite3.c $(TLIBS )
14231449
14241450startup$(TEXE ) : $(TOP ) /test/startup.c sqlite3.c
@@ -1507,6 +1533,7 @@ clean:
15071533 rm -rf .libs .deps
15081534 rm -f lemon$(BEXE ) lempar.c parse.* sqlite* .tar.gz
15091535 rm -f mkkeywordhash$(BEXE ) keywordhash.h
1536+ rm -f mksourceid$(BEXE )
15101537 rm -f * .da * .bb * .bbg gmon.out
15111538 rm -rf tsrc .target_source
15121539 rm -f tclsqlcipher$(TEXE )
@@ -1531,7 +1558,7 @@ clean:
15311558 rm -f threadtest5
15321559
15331560distclean : clean
1534- rm -f config .h config.log config.status libtool Makefile sqlcipher.pc \
1561+ rm -f sqlite_cfg .h config.log config.status libtool Makefile sqlcipher.pc \
15351562 $(TESTPROGS )
15361563
15371564#
@@ -1552,133 +1579,8 @@ sqlite3.dll: $(REAL_LIBOBJ) sqlite3.def
15521579 $(TCC ) -shared -o $@ sqlite3.def \
15531580 -Wl," --strip-all" $(REAL_LIBOBJ )
15541581
1555-
15561582#
1557- # fiddle/wasm section
1558- #
1559- fiddle_dir = ext/fiddle
1560- fiddle_dir_abs = $(TOP ) /$(fiddle_dir )
1561- # ^^^ some emcc opts require absolute paths
1562- fiddle_html = $(fiddle_dir ) /fiddle.html
1563- fiddle_module_js = $(fiddle_dir ) /fiddle-module.js
1564- sqlite3_wasm_js = $(fiddle_dir ) /sqlite3.js
1565- sqlite3_wasm = $(fiddle_dir ) /sqlite3.wasm
1566- # emcc_opt = -O0
1567- # emcc_opt = -O1
1568- # emcc_opt = -O2
1569- # emcc_opt = -O3
1570- emcc_opt = -Oz
1571- emcc_flags = $(emcc_opt ) -sALLOW_TABLE_GROWTH -sSTRICT_JS \
1572- -sENVIRONMENT=web -sMODULARIZE \
1573- -sEXPORTED_RUNTIME_METHODS=@$(fiddle_dir_abs ) /EXPORTED_RUNTIME_METHODS \
1574- -sDYNAMIC_EXECUTION=0 \
1575- -I. $(SHELL_OPT )
1576- $(fiddle_module_js ) : Makefile sqlite3.c shell.c \
1577- $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
1578- $(fiddle_dir)/EXPORTED_FUNCTIONS.fiddle
1579- emcc -o $@ $(emcc_flags) \
1580- -sEXPORT_NAME =initFiddleModule \
1581- -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs ) /EXPORTED_FUNCTIONS.fiddle \
1582- sqlite3.c shell.c
1583- gzip < $@ > $@.gz
1584- gzip < $(fiddle_dir)/fiddle-module.wasm > $(fiddle_dir)/fiddle-module.wasm.gz
1585- $(sqlite3_wasm_js ) : Makefile sqlite3.c \
1586- $(fiddle_dir)/sqlite3-api.js \
1587- $(fiddle_dir)/EXPORTED_RUNTIME_METHODS \
1588- $(fiddle_dir)/EXPORTED_FUNCTIONS.sqlite3-api
1589- emcc -o $@ $(emcc_flags) \
1590- -sEXPORT_NAME =initSqlite3Module \
1591- -sEXPORTED_FUNCTIONS=@$(fiddle_dir_abs ) /EXPORTED_FUNCTIONS.sqlite3-api \
1592- --post-js=$(fiddle_dir ) /sqlite3-api.js \
1593- --no-entry \
1594- sqlite3.c
1595- gzip < $@ > $@.gz
1596- gzip < $(sqlite3_wasm) > $(sqlite3_wasm).gz
1597- gzip < $(fiddle_dir)/sqlite3-api.js > $(fiddle_dir)/sqlite3-api.js.gz
1598- $(fiddle_dir ) /fiddle.js.gz : $(fiddle_dir ) /fiddle.js
1599- gzip < $< > $@
1600- $(fiddle_dir ) /sqlite3-api.js.gz : $(fiddle_dir ) /sqlite3-api.js
1601- gzip < $< > $@
1602-
1603- fiddle_generated = $(fiddle_module_js ) $(fiddle_module_js ) .gz \
1604- $(fiddle_dir ) /fiddle-module.wasm \
1605- $(fiddle_dir ) /fiddle-module.wasm.gz \
1606- $(fiddle_dir ) /fiddle.js.gz
1607- sqlite3_wasm_generated = \
1608- $(sqlite3_wasm ) $(sqlite3_wasm ) .gz \
1609- $(sqlite3_wasm_js ) $(sqlite3_wasm_js ) .gz \
1610- $(fiddle_dir ) /sqlite3.js.gz \
1611- $(fiddle_dir ) /sqlite3-api.js.gz
1612-
1613- clean-wasm :
1614- rm -f $(fiddle_generated ) $(sqlite3_wasm_generated )
1615- clean : clean-wasm
1616- fiddle : $(fiddle_module_js ) $(fiddle_dir ) /fiddle.js.gz
1617- sqlite3-wasm : $(sqlite3_wasm_js )
1618- wasm : fiddle sqlite3-wasm
1619- # #######################################################################
1620- # Explanation of the emcc build flags follows. Full docs for these can
1621- # be found at:
1622- #
1623- # https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
1624- #
1625- # -sENVIRONMENT=web: elides bootstrap code related to non-web JS
1626- # environments like node.js. Removing this makes the output a tiny
1627- # tick larger but hypothetically makes it more portable to
1628- # non-browser JS environments.
1629- #
1630- # -sMODULARIZE: changes how the generated code is structured to avoid
1631- # declaring a global Module object and instead installing a function
1632- # which loads and initialized the module. The function is named...
1633- #
1634- # -sEXPORT_NAME=jsFunctionName (see -sMODULARIZE)
1635- #
1636- # -sEXPORTED_RUNTIME_METHODS=@/absolute/path/to/file: a file
1637- # containing a list of emscripten-supplied APIs, one per line, which
1638- # must be exported into the generated JS. Must be an absolute path!
1639- #
1640- # -sEXPORTED_FUNCTIONS=@/absolute/path/to/file: a file containing a
1641- # list of C functions, one per line, which must be exported via wasm
1642- # so they're visible to JS. C symbols names in that file must all
1643- # start with an underscore for reasons known only to the emcc
1644- # developers. e.g., _sqlite3_open_v2 and _sqlite3_finalize. Must be
1645- # an absolute path!
1646- #
1647- # -sSTRICT_JS ensures that the emitted JS code includes the 'use
1648- # strict' option. Note that -sSTRICT is more broadly-scoped and
1649- # results in build errors.
1650- #
1651- # -sALLOW_TABLE_GROWTH is required for (at a minimum) the UDF-binding
1652- # feature.
1653- #
1654- # -sDYNAMIC_EXECUTION=0 disables eval() and the Function constructor.
1655- # If the build runs without these, it's preferable to use this flag
1656- # because certain execution environments disallow those constructs.
1657- # This flag is not strictly necessary, however.
1658- #
1659- # -sWASM_BIGINT is UNTESTED but "should" allow the int64-using C APIs
1660- # to work with JS/wasm, insofar as the JS environment supports the
1661- # BigInt type. That support requires an extremely recent browser:
1662- # Safari didn't get that support until late 2020.
1663- #
1664- # --no-entry: for compiling library code with no main(). If this is
1665- # not supplied and the code has a main(), it is called as part of the
1666- # module init process. Note that main() is #if'd out of shell.c
1667- # (renamed) when building in wasm mode.
1668- #
1669- # --pre-js/--post-js=FILE relative or absolute paths to JS files to
1670- # prepend/append to the emcc-generated bootstrapping JS. It's
1671- # easier/faster to develop with separate JS files (reduces rebuilding
1672- # requirements) but certain configurations, namely -sMODULARIZE, may
1673- # require using at least a --pre-js file. They can be used
1674- # individually and need not be paired.
1675- #
1676- # -O0..-O3 and -Oz: optimization levels affect not only C-style
1677- # optimization but whether or not the resulting generated JS code
1678- # gets minified. -O0 compiles _much_ more quickly than -O3 or -Oz,
1679- # and doesn't minimize any JS code, so is recommended for
1680- # development. -O3 or -Oz are recommended for deployment, but
1681- # primarily because -Oz will shrink the wasm file notably. JS-side
1682- # minification makes little difference in terms of overall
1683- # distributable size.
1684- # #######################################################################
1583+ # Fiddle app
1584+ #
1585+ fiddle : sqlite3.c shell.c
1586+ make -C ext/wasm fiddle emcc_opt=-Os
0 commit comments