From: drh Date: Fri, 1 Apr 2011 18:12:58 +0000 (+0000) Subject: Add a script that will break the amalgamation source file up into 4 or 5 X-Git-Tag: version-3.7.6~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d21021f59ce16c4e4d10fc314c9fa3300fc04b2;p=thirdparty%2Fsqlite.git Add a script that will break the amalgamation source file up into 4 or 5 smaller source files, each 32K lines or fewer, and a single "sqlite3-all.c" source file that #includes the others. FossilOrigin-Name: 5d34e64d4d2398aa9a54fd0a4f1de37ced7ea5dd --- diff --git a/manifest b/manifest index 5404553284..28f120574c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sanalyze7.test\sso\sthat\sit\sworks\swithout\sSQLITE_ENABLE_STAT2\sdefined. -D 2011-04-01T17:53:20 +C Add\sa\sscript\sthat\swill\sbreak\sthe\samalgamation\ssource\sfile\sup\sinto\s4\sor\s5\nsmaller\ssource\sfiles,\seach\s32K\slines\sor\sfewer,\sand\sa\ssingle\s"sqlite3-all.c"\nsource\sfile\sthat\s#includes\sthe\sothers. +D 2011-04-01T18:12:58.662 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -896,9 +896,9 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 -F tool/mksqlite3c.tcl cf44512a48112b1ba09590548660a5a6877afdb3 +F tool/mksqlite3c.tcl 623e26cc8c83322e4151d3ad85ac69d41221bae8 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 F tool/omittest.tcl 4f4cc66bb7ca6a5b8f61ee37b6333f60fb8a746a @@ -920,8 +920,9 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e +F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 81ddbf43366c18ebdd46558d6a0fbee2ce6a4c4e -R 99f8eb376089a9fabbaf964c125c721f -U dan -Z bf935093daa7a73e12043061e537a56c +P 9415201c8a0b9b640f5997c5348c5df812e88230 +R c3ff07e6303499e88c2cf0a9abaa71e9 +U drh +Z 975ba0a508eed8e252cfd7014026f442 diff --git a/manifest.uuid b/manifest.uuid index bd021d3020..8128966455 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9415201c8a0b9b640f5997c5348c5df812e88230 \ No newline at end of file +5d34e64d4d2398aa9a54fd0a4f1de37ced7ea5dd \ No newline at end of file diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100755 new mode 100644 diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index d56b06dbc9..fa99f2df7b 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -51,7 +51,7 @@ puts $out [subst \ {/****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite ** version $VERSION. By combining all the individual C code files into this -** single large file, the entire code can be compiled as a one translation +** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements ** of 5% or more are commonly seen when SQLite is compiled as a single diff --git a/tool/split-sqlite3c.tcl b/tool/split-sqlite3c.tcl new file mode 100644 index 0000000000..287b752828 --- /dev/null +++ b/tool/split-sqlite3c.tcl @@ -0,0 +1,82 @@ +#!/usr/bin/tclsh +# +# This script splits the sqlite3.c amalgamated source code files into +# several smaller files such that no single files is more than a fixed +# number of lines in length (32k or 64k). Each of the split out files +# is #include-ed by the master file. +# +# Splitting files up this way allows them to be used with older compilers +# that cannot handle really long source files. +# +set MAX 32768 ;# Maximum number of lines per file. + +set BEGIN {^/\*+ Begin file ([a-zA-Z0-9_.]+) \*+/} +set END {^/\*+ End of %s \*+/} + +set in [open sqlite3.c] +set out1 [open sqlite3-all.c w] + +# Copy the header from sqlite3.c into sqlite3-all.c +# +while {[gets $in line]} { + if {[regexp $BEGIN $line]} break + puts $out1 $line +} + +# Gather the complete content of a file into memory. Store the +# content in $bufout. Store the number of lines is $nout +# +proc gather_one_file {firstline bufout nout} { + regexp $::BEGIN $firstline all filename + set end [format $::END $filename] + upvar $bufout buf $nout n + set buf $firstline\n + global in + set n 0 + while {[gets $in line]>=0} { + incr n + append buf $line\n + if {[regexp $end $line]} break + } +} + +# Write a big chunk of text in to an auxiliary file "sqlite3-NNN.c". +# Also add an appropriate #include to sqlite3-all.c +# +set filecnt 0 +proc write_one_file {content} { + global filecnt + incr filecnt + set out [open sqlite3-$filecnt.c w] + puts -nonewline $out $content + close $out + puts $::out1 "#include \"sqlite3-$filecnt.c\"" +} + +# Continue reading input. Store chunks in separate files and add +# the #includes to the main sqlite3-all.c file as necessary to reference +# the extra chunks. +# +set all {} +set N 0 +while {[regexp $BEGIN $line]} { + set buf {} + set n 0 + gather_one_file $line buf n + if {$n+$N>=$MAX} { + write_one_file $all + set all {} + set N 0 + } + append all $buf + incr N $n + while {[gets $in line]>=0} { + if {[regexp $BEGIN $line]} break + puts $out1 $line + } +} +if {$N>0} { + write_one_file $all +} +close $out1 +close $in