@@ -180,7 +180,7 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \
180
180
fts3_unicode.lo fts3_unicode2.lo fts3_write.lo \
181
181
fts5.lo \
182
182
func.lo global.lo hash.lo \
183
- icu.lo insert.lo json1 .lo legacy.lo loadext.lo \
183
+ icu.lo insert.lo json .lo legacy.lo loadext.lo \
184
184
main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \
185
185
memdb.lo memjournal.lo \
186
186
mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
@@ -234,6 +234,7 @@ SRC = \
234
234
$(TOP ) /src/hash.h \
235
235
$(TOP ) /src/hwtime.h \
236
236
$(TOP ) /src/insert.c \
237
+ $(TOP ) /src/json.c \
237
238
$(TOP ) /src/legacy.c \
238
239
$(TOP ) /src/loadext.c \
239
240
$(TOP ) /src/main.c \
@@ -366,7 +367,6 @@ SRC += \
366
367
$(TOP ) /ext/rbu/sqlite3rbu.h \
367
368
$(TOP ) /ext/rbu/sqlite3rbu.c
368
369
SRC += \
369
- $(TOP ) /ext/misc/json1.c \
370
370
$(TOP ) /ext/misc/stmt.c
371
371
372
372
# Generated source code files
@@ -460,6 +460,7 @@ TESTSRC += \
460
460
$(TOP ) /ext/misc/normalize.c \
461
461
$(TOP ) /ext/misc/percentile.c \
462
462
$(TOP ) /ext/misc/prefixes.c \
463
+ $(TOP ) /ext/misc/qpvtab.c \
463
464
$(TOP ) /ext/misc/regexp.c \
464
465
$(TOP ) /ext/misc/remember.c \
465
466
$(TOP ) /ext/misc/series.c \
@@ -502,6 +503,7 @@ TESTSRC2 = \
502
503
$(TOP ) /src/pcache1.c \
503
504
$(TOP ) /src/select.c \
504
505
$(TOP ) /src/tokenize.c \
506
+ $(TOP ) /src/treeview.c \
505
507
$(TOP ) /src/utf.c \
506
508
$(TOP ) /src/util.c \
507
509
$(TOP ) /src/vdbeapi.c \
@@ -608,7 +610,7 @@ TESTOPTS = --verbose=file --output=test-out.txt
608
610
609
611
# Extra compiler options for various shell tools
610
612
#
611
- SHELL_OPT = -DSQLITE_ENABLE_JSON1 - DSQLITE_ENABLE_FTS4
613
+ SHELL_OPT = -DSQLITE_ENABLE_FTS4
612
614
# SHELL_OPT += -DSQLITE_ENABLE_FTS5
613
615
SHELL_OPT += -DSQLITE_ENABLE_RTREE
614
616
SHELL_OPT += -DSQLITE_ENABLE_EXPLAIN_COMMENTS
@@ -618,8 +620,8 @@ SHELL_OPT += -DSQLITE_ENABLE_DBPAGE_VTAB
618
620
SHELL_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
619
621
SHELL_OPT += -DSQLITE_ENABLE_BYTECODE_VTAB
620
622
SHELL_OPT += -DSQLITE_ENABLE_OFFSET_SQL_FUNC
621
- FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1
622
- FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 - DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
623
+ FUZZERSHELL_OPT =
624
+ FUZZCHECK_OPT = -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
623
625
FUZZCHECK_OPT += -DSQLITE_MAX_MEMORY=50000000
624
626
FUZZCHECK_OPT += -DSQLITE_PRINTF_PRECISION_LIMIT=1000
625
627
FUZZCHECK_OPT += -DSQLITE_ENABLE_FTS4
@@ -629,7 +631,7 @@ FUZZCHECK_OPT += -DSQLITE_ENABLE_RTREE
629
631
FUZZCHECK_OPT += -DSQLITE_ENABLE_GEOPOLY
630
632
FUZZCHECK_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
631
633
FUZZCHECK_OPT += -DSQLITE_ENABLE_BYTECODE_VTAB
632
- 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
633
635
DBFUZZ_OPT =
634
636
635
637
# This is the default Makefile target. The objects listed here
@@ -873,6 +875,9 @@ hash.lo: $(TOP)/src/hash.c $(HDR)
873
875
insert.lo : $(TOP ) /src/insert.c $(HDR )
874
876
$(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/insert.c
875
877
878
+ json.lo : $(TOP ) /src/json.c $(HDR )
879
+ $(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/json.c
880
+
876
881
legacy.lo : $(TOP ) /src/legacy.c $(HDR )
877
882
$(LTCOMPILE ) $(TEMP_STORE ) -c $(TOP ) /src/legacy.c
878
883
@@ -1176,9 +1181,6 @@ userauth.lo: $(TOP)/ext/userauth/userauth.c $(HDR) $(EXTHDR)
1176
1181
sqlite3session.lo : $(TOP ) /ext/session/sqlite3session.c $(HDR ) $(EXTHDR )
1177
1182
$(LTCOMPILE ) -DSQLITE_CORE -c $(TOP ) /ext/session/sqlite3session.c
1178
1183
1179
- json1.lo : $(TOP ) /ext/misc/json1.c
1180
- $(LTCOMPILE ) -DSQLITE_CORE -c $(TOP ) /ext/misc/json1.c
1181
-
1182
1184
stmt.lo : $(TOP ) /ext/misc/stmt.c
1183
1185
$(LTCOMPILE ) -DSQLITE_CORE -c $(TOP ) /ext/misc/stmt.c
1184
1186
@@ -1511,3 +1513,134 @@ sqlite3.def: $(REAL_LIBOBJ)
1511
1513
sqlite3.dll : $(REAL_LIBOBJ ) sqlite3.def
1512
1514
$(TCC ) -shared -o $@ sqlite3.def \
1513
1515
-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
+
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
+
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