Index: third_party/sqlite/src/tool/mksqlite3c.tcl |
diff --git a/third_party/sqlite/src/tool/mksqlite3c.tcl b/third_party/sqlite/src/tool/mksqlite3c.tcl |
index 9e2b0fe517353dc00614fc012797a02e79413118..1113758e9ba997ff8a12db6246111802d3c37313 100644 |
--- a/third_party/sqlite/src/tool/mksqlite3c.tcl |
+++ b/third_party/sqlite/src/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 --srcdir $SRC |
# |
# The amalgamated SQLite code will be written into sqlite3.c |
# |
@@ -26,15 +26,17 @@ |
# from in this file. The version number is needed to generate the header |
# comment of the amalgamation. |
# |
-if {[lsearch $argv --nostatic]>=0} { |
- set addstatic 0 |
-} else { |
- set addstatic 1 |
-} |
-if {[lsearch $argv --linemacros]>=0} { |
- set linemacros 1 |
-} else { |
- set linemacros 0 |
+set addstatic 1 |
+set linemacros 0 |
+for {set i 0} {$i<[llength $argv]} {incr i} { |
+ set x [lindex $argv $i] |
+ if {[regexp {^-+nostatic$} $x]} { |
+ set addstatic 0 |
+ } elseif {[regexp {^-+linemacros} $x]} { |
+ set linemacros 1 |
+ } else { |
+ error "unknown command-line option: $x" |
+ } |
} |
set in [open tsrc/sqlite3.h] |
set cnt 0 |
@@ -80,9 +82,6 @@ if {$addstatic} { |
puts $out \ |
{#ifndef SQLITE_PRIVATE |
# define SQLITE_PRIVATE static |
-#endif |
-#ifndef SQLITE_API |
-# define SQLITE_API |
#endif} |
} |
@@ -100,6 +99,7 @@ foreach hdr { |
hash.h |
hwtime.h |
keywordhash.h |
+ msvc.h |
mutex.h |
opcodes.h |
os_common.h |
@@ -109,14 +109,17 @@ foreach hdr { |
pager.h |
parse.h |
pcache.h |
+ pragma.h |
rtree.h |
- sqlite3ext.h |
sqlite3.h |
+ sqlite3ext.h |
+ sqlite3rbu.h |
sqliteicu.h |
sqliteInt.h |
sqliteLimit.h |
vdbe.h |
vdbeInt.h |
+ vxworks.h |
wal.h |
whereInt.h |
} { |
@@ -124,6 +127,23 @@ foreach hdr { |
} |
set available_hdr(sqliteInt.h) 0 |
+# These headers should be copied into the amalgamation without modifying any |
+# of their function declarations or definitions. |
+set varonly_hdr(sqlite3.h) 1 |
+ |
+# These are the functions that accept a variable number of arguments. They |
+# always need to use the "cdecl" calling convention even when another calling |
+# convention (e.g. "stcall") is being used for the rest of the library. |
+set cdecllist { |
+ sqlite3_config |
+ sqlite3_db_config |
+ sqlite3_log |
+ sqlite3_mprintf |
+ sqlite3_snprintf |
+ sqlite3_test_control |
+ sqlite3_vtab_config |
+} |
+ |
# 78 stars used for comment formatting. |
set s78 \ |
{*****************************************************************************} |
@@ -143,18 +163,18 @@ proc section_comment {text} { |
# process them appropriately. |
# |
proc copy_file {filename} { |
- global seen_hdr available_hdr out addstatic linemacros |
+ global seen_hdr available_hdr varonly_hdr cdecllist out addstatic linemacros |
set ln 0 |
set tail [file tail $filename] |
section_comment "Begin file $tail" |
if {$linemacros} {puts $out "#line 1 \"$filename\""} |
set in [open $filename r] |
set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)} |
- set declpattern {[a-zA-Z][a-zA-Z_0-9 ]+ \**(sqlite3[_a-zA-Z0-9]+)\(} |
+ set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)} |
if {[file extension $filename]==".h"} { |
set declpattern " *$declpattern" |
} |
- set declpattern ^$declpattern |
+ set declpattern ^$declpattern\$ |
while {![eof $in]} { |
set line [gets $in] |
incr ln |
@@ -168,6 +188,10 @@ proc copy_file {filename} { |
copy_file tsrc/$hdr |
section_comment "Continuing where we left off in $tail" |
if {$linemacros} {puts $out "#line [expr {$ln+1}] \"$filename\""} |
+ } else { |
+ # Comment out the entire line, replacing any nested comment |
+ # begin/end markers with the harmless substring "**". |
+ puts $out "/* [string map [list /* ** */ **] $line] */" |
} |
} elseif {![info exists seen_hdr($hdr)]} { |
if {![regexp {/\*\s+amalgamator:\s+dontcache\s+\*/} $line]} { |
@@ -187,33 +211,51 @@ proc copy_file {filename} { |
puts $out "#if 0" |
} elseif {!$linemacros && [regexp {^#line} $line]} { |
# Skip #line directives. |
- } elseif {$addstatic && ![regexp {^(static|typedef)} $line]} { |
- regsub {^SQLITE_API } $line {} line |
- if {[regexp $declpattern $line all funcname]} { |
+ } elseif {$addstatic |
+ && ![regexp {^(static|typedef|SQLITE_PRIVATE)} $line]} { |
+ # Skip adding the SQLITE_PRIVATE or SQLITE_API keyword before |
+ # functions if this header file does not need it. |
+ if {![info exists varonly_hdr($tail)] |
+ && [regexp $declpattern $line all rettype funcname rest]} { |
+ regsub {^SQLITE_API } $line {} line |
# Add the SQLITE_PRIVATE or SQLITE_API keyword before functions. |
# so that linkage can be modified at compile-time. |
- if {[regexp {^sqlite3_} $funcname]} { |
- puts $out "SQLITE_API $line" |
+ if {[regexp {^sqlite3(_|rbu_)} $funcname]} { |
+ set line SQLITE_API |
+ append line " " [string trim $rettype] |
+ if {[string index $rettype end] ne "*"} { |
+ append line " " |
+ } |
+ if {[lsearch -exact $cdecllist $funcname] >= 0} { |
+ append line SQLITE_CDECL |
+ } else { |
+ append line SQLITE_STDCALL |
+ } |
+ append line " " $funcname $rest |
+ puts $out $line |
} else { |
puts $out "SQLITE_PRIVATE $line" |
} |
} elseif {[regexp $varpattern $line all varname]} { |
- # Add the SQLITE_PRIVATE before variable declarations or |
- # definitions for internal use |
- if {![regexp {^sqlite3_} $varname]} { |
- regsub {^extern } $line {} line |
- puts $out "SQLITE_PRIVATE $line" |
- } else { |
- if {[regexp {const char sqlite3_version\[\];} $line]} { |
- set line {const char sqlite3_version[] = SQLITE_VERSION;} |
+ # Add the SQLITE_PRIVATE before variable declarations or |
+ # definitions for internal use |
+ regsub {^SQLITE_API } $line {} line |
+ if {![regexp {^sqlite3_} $varname]} { |
+ regsub {^extern } $line {} line |
+ puts $out "SQLITE_PRIVATE $line" |
+ } else { |
+ if {[regexp {const char sqlite3_version\[\];} $line]} { |
+ set line {const char sqlite3_version[] = SQLITE_VERSION;} |
+ } |
+ regsub {^SQLITE_EXTERN } $line {} line |
+ puts $out "SQLITE_API $line" |
} |
- regsub {^SQLITE_EXTERN } $line {} line |
- puts $out "SQLITE_API $line" |
- } |
} elseif {[regexp {^(SQLITE_EXTERN )?void \(\*sqlite3IoTrace\)} $line]} { |
+ regsub {^SQLITE_API } $line {} line |
regsub {^SQLITE_EXTERN } $line {} line |
- puts $out "SQLITE_PRIVATE $line" |
+ puts $out $line |
} elseif {[regexp {^void \(\*sqlite3Os} $line]} { |
+ regsub {^SQLITE_API } $line {} line |
puts $out "SQLITE_PRIVATE $line" |
} else { |
puts $out $line |
@@ -252,6 +294,7 @@ foreach file { |
mutex_w32.c |
malloc.c |
printf.c |
+ treeview.c |
random.c |
threads.c |
utf.c |
@@ -306,6 +349,8 @@ foreach file { |
update.c |
vacuum.c |
vtab.c |
+ wherecode.c |
+ whereexpr.c |
where.c |
parse.c |
@@ -334,6 +379,10 @@ foreach file { |
rtree.c |
icu.c |
fts3_icu.c |
+ sqlite3rbu.c |
+ dbstat.c |
+ json1.c |
+ fts5.c |
} { |
copy_file tsrc/$file |
} |