From 87ac2b043a663720c84d0b7d923b7d9dca5391c1 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 2 Sep 2023 05:37:58 +0000 Subject: [PATCH 1/3] Add EXTRA_SRC build var. If set, it is treated like a list of files, each of which gets appended verbatim to sqlite3.c. The intent is to enable easily extending the amalgamation. Requested in/around [forum:3fcc655f0ac0efe8|forum post 3fcc655f0ac0efe8]. FossilOrigin-Name: 934b84339860fa84a6faa3507bdd3cc58199e2636a394fc93176c80da0ba6f1c --- Makefile.in | 6 ++++-- main.mk | 5 ++--- manifest | 19 +++++++++++-------- manifest.uuid | 2 +- tool/mksqlite3c.tcl | 12 +++++++++--- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Makefile.in b/Makefile.in index e3bf1c0e7a..16ebf098c6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -782,7 +782,8 @@ mptest: mptester$(TEXE) touch .target_source sqlite3.c: .target_source $(TOP)/tool/mksqlite3c.tcl src-verify - $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl $(AMALGAMATION_LINE_MACROS) + $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl $(AMALGAMATION_LINE_MACROS) \ + $(EXTRA_SRC) cp tsrc/sqlite3ext.h . cp $(TOP)/ext/session/sqlite3session.h . @@ -793,7 +794,8 @@ sqlite3r.c: sqlite3.c sqlite3r.h cp $(TOP)/ext/recover/sqlite3recover.c tsrc/ cp $(TOP)/ext/recover/sqlite3recover.h tsrc/ cp $(TOP)/ext/recover/dbdata.c tsrc/ - $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl --enable-recover $(AMALGAMATION_LINE_MACROS) + $(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl --enable-recover \ + $(AMALGAMATION_LINE_MACROS) $(EXTRA_SRC) sqlite3ext.h: .target_source cp tsrc/sqlite3ext.h . diff --git a/main.mk b/main.mk index d8c372430e..0efdec309c 100644 --- a/main.mk +++ b/main.mk @@ -230,7 +230,6 @@ SRC += \ SRC += \ $(TOP)/ext/misc/stmt.c - # FTS5 things # FTS5_HDR = \ @@ -645,7 +644,7 @@ target_source: $(SRC) $(TOP)/tool/vdbe-compress.tcl fts5.c touch target_source sqlite3.c: target_source $(TOP)/tool/mksqlite3c.tcl src-verify - tclsh $(TOP)/tool/mksqlite3c.tcl + tclsh $(TOP)/tool/mksqlite3c.tcl $(EXTRA_SRC) cp tsrc/sqlite3ext.h . cp $(TOP)/ext/session/sqlite3session.h . echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c @@ -657,7 +656,7 @@ sqlite3ext.h: target_source cp tsrc/sqlite3ext.h . sqlite3.c-debug: target_source $(TOP)/tool/mksqlite3c.tcl src-verify - tclsh $(TOP)/tool/mksqlite3c.tcl --linemacros=1 + tclsh $(TOP)/tool/mksqlite3c.tcl --linemacros=1 $(EXTRA_SRC) echo '#ifndef USE_SYSTEM_SQLITE' >tclsqlite3.c cat sqlite3.c >>tclsqlite3.c echo '#endif /* USE_SYSTEM_SQLITE */' >>tclsqlite3.c diff --git a/manifest b/manifest index 09646366ed..902e4aba7d 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Second\shalf\sof\s[1c532e80]. -D 2023-09-01T11:10:09.238 +C Add\sEXTRA_SRC\sbuild\svar.\sIf\sset,\sit\sis\streated\slike\sa\slist\sof\sfiles,\seach\sof\swhich\sgets\sappended\sverbatim\sto\ssqlite3.c.\sThe\sintent\sis\sto\senable\seasily\sextending\sthe\samalgamation.\sRequested\sin/around\s[forum:3fcc655f0ac0efe8|forum\spost\s3fcc655f0ac0efe8]. +D 2023-09-02T05:37:58.754 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in 345a8599cf8ff015db534cedad7af70a1a6c36e295b85d720966c18af836ed30 +F Makefile.in c0ee78a772a33c1b377eb8f8b6f456ca10ad4aee86de4c9fcd16490e7432bcdb F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 F Makefile.msc 26c2d196391a285c279adb10fd6001774d9b243af94b700b681e4a49cd476684 F README.md 963d30019abf0cc06b263cd2824bce022893f3f93a531758f6f04ff2194a16a8 @@ -625,7 +625,7 @@ F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk 5536159f62058714c972b5bd325c8d5ecd5c9b00b385dd2e1cbc17da70a711b2 +F main.mk 48632ee12ecb9157c8f662794051260933518b52c5b430c30c3852b6743a48bc F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -2048,7 +2048,7 @@ F tool/mkshellc.tcl b7adf08b82de60811d2cb6af05ff59fc17e5cd6f3e98743c14eaaa3f8971 F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f -F tool/mksqlite3c.tcl 49e39b1e616abc92fd8c24445f2b0a38881825f764541e0026f72371f0d84b65 +F tool/mksqlite3c.tcl 4f366e3d1ddb28996a6763c847fa62e1452bb11ca702841485df77823ec94ea4 F tool/mksqlite3h.tcl d391cff7cad0a372ee1406faee9ccc7dad9cb80a0c95cae0f73d10dd26e06762 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5 @@ -2115,8 +2115,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1c532e807bf8466b67d9600ab9630a6736de77259e9a71ac435641715ee0e04b -R ea796b2653d720202144fba261cf7ada +P 8ca1d815a57be1fade59fb8ea5705c27b10294e4959c8a9c624f1623df6a5f63 +R 26961792cf57fe21537a8837bc1686c0 +T *branch * extra-src +T *sym-extra-src * +T -sym-trunk * Cancelled\sby\sbranch. U stephan -Z 3f0f478ea9581db06db30ac4b45877cc +Z 89876b5c6405dcc4d6d608637f43ad0e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 2cefe103b6..f5b052c057 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8ca1d815a57be1fade59fb8ea5705c27b10294e4959c8a9c624f1623df6a5f63 \ No newline at end of file +934b84339860fa84a6faa3507bdd3cc58199e2636a394fc93176c80da0ba6f1c \ No newline at end of file diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index 6def8fa447..bdbc01e496 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -17,7 +17,7 @@ # After the "tsrc" directory has been created and populated, run # this script: # -# tclsh mksqlite3c.tcl +# tclsh mksqlite3c.tcl [flags] [extra source files] # # The amalgamated SQLite code will be written into sqlite3.c # @@ -42,6 +42,7 @@ set linemacros 0 set useapicall 0 set enable_recover 0 set srcdir tsrc +set extrasrc [list] for {set i 0} {$i<[llength $argv]} {incr i} { set x [lindex $argv $i] @@ -63,8 +64,10 @@ for {set i 0} {$i<[llength $argv]} {incr i} { } elseif {[regexp {^-?-((help)|\?)$} $x]} { puts $help exit 0 - } else { + } elseif {[regexp {^-?-} $x]} { error "unknown command-line option: $x" + } else { + lappend extrasrc $x } } set in [open $srcdir/sqlite3.h] @@ -470,13 +473,16 @@ set flist { sqlite3session.c fts5.c stmt.c -} +} if {$enable_recover} { lappend flist sqlite3recover.c dbdata.c } foreach file $flist { copy_file $srcdir/$file } +foreach file $extrasrc { + copy_file $file +} puts $out \ "/* Return the source-id for this library */ From 2065a9b7305e43bb84e003242431d7f859511dad Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 2 Sep 2023 21:55:10 +0000 Subject: [PATCH 2/3] Also add support for EXTRA_SRC in the Makefile for MSVC. FossilOrigin-Name: bfc18ef4323cd73fc63cb93f18bdd9c3add41bea83c1cbc1c20de5c1e4296a60 --- Makefile.msc | 6 +++++- manifest | 17 +++++++---------- manifest.uuid | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 3179e301ce..9b0f8c412f 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -16,6 +16,10 @@ TOP = . !IFNDEF USE_AMALGAMATION USE_AMALGAMATION = 1 !ENDIF + +!IFNDEF EXTRA_SRC +EXTRA_SRC = +!ENDIF # <> # Set this non-0 to enable full warnings (-W4, etc) when compiling. @@ -1904,7 +1908,7 @@ mptest: mptester.exe echo > .target_source sqlite3.c: .target_source sqlite3ext.h sqlite3session.h $(MKSQLITE3C_TOOL) src-verify.exe - $(TCLSH_CMD) $(MKSQLITE3C_TOOL) $(MKSQLITE3C_ARGS) + $(TCLSH_CMD) $(MKSQLITE3C_TOOL) $(MKSQLITE3C_ARGS) $(EXTRA_SRC) sqlite3-all.c: sqlite3.c $(TOP)\tool\split-sqlite3c.tcl $(TCLSH_CMD) $(TOP)\tool\split-sqlite3c.tcl diff --git a/manifest b/manifest index 902e4aba7d..f2e0fcdcfc 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Add\sEXTRA_SRC\sbuild\svar.\sIf\sset,\sit\sis\streated\slike\sa\slist\sof\sfiles,\seach\sof\swhich\sgets\sappended\sverbatim\sto\ssqlite3.c.\sThe\sintent\sis\sto\senable\seasily\sextending\sthe\samalgamation.\sRequested\sin/around\s[forum:3fcc655f0ac0efe8|forum\spost\s3fcc655f0ac0efe8]. -D 2023-09-02T05:37:58.754 +C Also\sadd\ssupport\sfor\sEXTRA_SRC\sin\sthe\sMakefile\sfor\sMSVC. +D 2023-09-02T21:55:10.922 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F Makefile.in c0ee78a772a33c1b377eb8f8b6f456ca10ad4aee86de4c9fcd16490e7432bcdb F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 26c2d196391a285c279adb10fd6001774d9b243af94b700b681e4a49cd476684 +F Makefile.msc 4d7da1cd760e595cf751f8b3220c0b20657b20969713803ea538f66950453828 F README.md 963d30019abf0cc06b263cd2824bce022893f3f93a531758f6f04ff2194a16a8 F VERSION 4c09b629c03b8ae32317cb336a32f3aa3252841d6dcd51184cecc4278d08f21e F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -2115,11 +2115,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8ca1d815a57be1fade59fb8ea5705c27b10294e4959c8a9c624f1623df6a5f63 -R 26961792cf57fe21537a8837bc1686c0 -T *branch * extra-src -T *sym-extra-src * -T -sym-trunk * Cancelled\sby\sbranch. -U stephan -Z 89876b5c6405dcc4d6d608637f43ad0e +P 934b84339860fa84a6faa3507bdd3cc58199e2636a394fc93176c80da0ba6f1c +R c273c661c255a780f4edcaa61a31a00b +U mistachkin +Z 47e1eabb65e7f37ad8c0f6188be76f6d # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f5b052c057..9687ff42b9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -934b84339860fa84a6faa3507bdd3cc58199e2636a394fc93176c80da0ba6f1c \ No newline at end of file +bfc18ef4323cd73fc63cb93f18bdd9c3add41bea83c1cbc1c20de5c1e4296a60 \ No newline at end of file From 45cf8ad02a30f76212f7b1c00fa45b00e8626eb6 Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 3 Sep 2023 15:01:11 +0000 Subject: [PATCH 3/3] In mksqlite3c.tcl, pass EXTRA_SRC files through verbatim instead of applying the post-processing needed for sqlite's own source files. FossilOrigin-Name: 44f3d7d054055fab4cca0ba753e75e237ca159ae868ffd1d13ed45a874a772f2 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/mksqlite3c.tcl | 17 ++++++++++++++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index f2e0fcdcfc..2d41793356 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Also\sadd\ssupport\sfor\sEXTRA_SRC\sin\sthe\sMakefile\sfor\sMSVC. -D 2023-09-02T21:55:10.922 +C In\smksqlite3c.tcl,\spass\sEXTRA_SRC\sfiles\sthrough\sverbatim\sinstead\sof\sapplying\sthe\spost-processing\sneeded\sfor\ssqlite's\sown\ssource\sfiles. +D 2023-09-03T15:01:11.477 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -2048,7 +2048,7 @@ F tool/mkshellc.tcl b7adf08b82de60811d2cb6af05ff59fc17e5cd6f3e98743c14eaaa3f8971 F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f -F tool/mksqlite3c.tcl 4f366e3d1ddb28996a6763c847fa62e1452bb11ca702841485df77823ec94ea4 +F tool/mksqlite3c.tcl 6d95b3317a7c51e76458c1d4b056b1791b4d9022570e2e23efbaf6a272b47de2 F tool/mksqlite3h.tcl d391cff7cad0a372ee1406faee9ccc7dad9cb80a0c95cae0f73d10dd26e06762 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5 @@ -2115,8 +2115,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 934b84339860fa84a6faa3507bdd3cc58199e2636a394fc93176c80da0ba6f1c -R c273c661c255a780f4edcaa61a31a00b -U mistachkin -Z 47e1eabb65e7f37ad8c0f6188be76f6d +P bfc18ef4323cd73fc63cb93f18bdd9c3add41bea83c1cbc1c20de5c1e4296a60 +R 7d78e3217d362137366a609d99cdc8a6 +U stephan +Z c9456c989544e03851e269725c9f500c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9687ff42b9..ed0de42d69 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bfc18ef4323cd73fc63cb93f18bdd9c3add41bea83c1cbc1c20de5c1e4296a60 \ No newline at end of file +44f3d7d054055fab4cca0ba753e75e237ca159ae868ffd1d13ed45a874a772f2 \ No newline at end of file diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index bdbc01e496..0ed96d2032 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -352,6 +352,21 @@ proc copy_file {filename} { section_comment "End of $tail" } +# Read the source file named $filename and write it into the +# sqlite3.c output file. The only transformation is the trimming +# of EOL whitespace. +# +proc copy_file_verbatim {filename} { + global out + set in [open $filename r] + set tail [file tail $filename] + section_comment "Begin EXTRA_SRC file $tail" + while {![eof $in]} { + set line [string trimright [gets $in]] + puts $out $line + } + section_comment "End of EXTRA_SRC $tail" +} # Process the source files. Process files containing commonly # used subroutines first in order to help the compiler find @@ -481,7 +496,7 @@ foreach file $flist { copy_file $srcdir/$file } foreach file $extrasrc { - copy_file $file + copy_file_verbatim $file } puts $out \