|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set out stdout |
|
|
|
|
|
|
|
|
|
|
|
set TOP [lindex $argv 0] |
|
|
|
|
|
|
|
|
|
|
|
set x [lsearch $argv -o] |
|
|
if {$x>0} { |
|
|
incr x |
|
|
set out [open [lindex $argv $x] wb] |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
set useapicall 0 |
|
|
|
|
|
|
|
|
|
|
|
set enable_recover 0 |
|
|
|
|
|
|
|
|
if {[lsearch -regexp [lrange $argv 1 end] {^-+useapicall}] != -1} { |
|
|
set useapicall 1 |
|
|
} |
|
|
if {[lsearch -regexp [lrange $argv 1 end] {^-+enable-recover}] != -1} { |
|
|
set enable_recover 1 |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
set in [open [file normalize $TOP/VERSION] rb] |
|
|
set zVersion [string trim [read $in]] |
|
|
close $in |
|
|
set nVersion [eval format "%d%03d%03d" [split $zVersion .]] |
|
|
|
|
|
|
|
|
|
|
|
proc file-content {fn} { |
|
|
set fd [open $fn rb] |
|
|
set rv [string trim [read $fd]] |
|
|
close $fd |
|
|
return $rv |
|
|
} |
|
|
|
|
|
set PWD [pwd] |
|
|
cd $TOP |
|
|
set tmpfile $PWD/tmp-[clock millisec]-[expr {int(rand()*100000000000)}].txt |
|
|
set mksourceid $PWD/mksourceid |
|
|
if {![file exists $mksourceid] && [file exists ${mksourceid}.exe]} { |
|
|
|
|
|
|
|
|
set mksourceid ${mksourceid}.exe |
|
|
} |
|
|
exec $mksourceid manifest > $tmpfile |
|
|
set zSourceId [file-content $tmpfile] |
|
|
file delete -force $tmpfile |
|
|
cd $PWD |
|
|
|
|
|
|
|
|
set zVerTime [lindex [lindex [split [file-content $TOP/manifest] "\n"] 1] 1]Z |
|
|
if {![file exists $TOP/manifest.tags]} { |
|
|
puts stderr "WARNING: building sqlite3.h without manifest.tags, which is generated by the SCM." |
|
|
puts stderr "This means that we cannot record the tag/branch info. We will continue with " |
|
|
puts stderr "a placeholder value. To remedy this, run the following command from a " |
|
|
puts stderr "check-out:\n" |
|
|
puts stderr " fossil set manifest urt\n" |
|
|
set zSourceId [string range $zSourceId 0 end-13]-experimental |
|
|
set zBranch "unknown" |
|
|
set zTags "unknown" |
|
|
} else { |
|
|
|
|
|
set content [file-content $TOP/manifest.tags]; |
|
|
set zTags {} |
|
|
foreach {x tag} [lassign $content - zBranch] { |
|
|
if {$tag eq $zBranch} continue |
|
|
lappend zTags $tag |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+sqlite3_[_a-zA-Z0-9]+(\[|;| =)} |
|
|
set declpattern1 {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3_[_a-zA-Z0-9]+)(\(.*)$} |
|
|
|
|
|
set declpattern2 \ |
|
|
{^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3session_[_a-zA-Z0-9]+)(\(.*)$} |
|
|
|
|
|
set declpattern3 \ |
|
|
{^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3changeset_[_a-zA-Z0-9]+)(\(.*)$} |
|
|
|
|
|
set declpattern4 \ |
|
|
{^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3changegroup_[_a-zA-Z0-9]+)(\(.*)$} |
|
|
|
|
|
set declpattern5 \ |
|
|
{^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3rebaser_[_a-zA-Z0-9]+)(\(.*)$} |
|
|
|
|
|
|
|
|
fconfigure stdout -translation binary |
|
|
|
|
|
set filelist [subst { |
|
|
$TOP/src/sqlite.h.in |
|
|
$TOP/ext/rtree/sqlite3rtree.h |
|
|
$TOP/ext/session/sqlite3session.h |
|
|
$TOP/ext/fts5/fts5.h |
|
|
}] |
|
|
if {$enable_recover} { |
|
|
lappend filelist "$TOP/ext/recover/sqlite3recover.h" |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set cdecllist { |
|
|
sqlite3_config |
|
|
sqlite3_db_config |
|
|
sqlite3_log |
|
|
sqlite3_mprintf |
|
|
sqlite3_snprintf |
|
|
sqlite3_test_control |
|
|
sqlite3_vtab_config |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach file $filelist { |
|
|
set in [open $file rb] |
|
|
if {![regexp {sqlite\.h\.in} $file]} { |
|
|
puts $out "/******** Begin file [file tail $file] *********/" |
|
|
} |
|
|
while {![eof $in]} { |
|
|
|
|
|
set line [string trimright [gets $in]] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if {[string match {*#include*[<"]sqlite3.h[>"]*} $line]} continue |
|
|
|
|
|
regsub -- --VERS-- $line $zVersion line |
|
|
regsub -- --VERSION-NUMBER-- $line $nVersion line |
|
|
regsub -- --SOURCE-ID-- $line "$zSourceId" line |
|
|
regsub -- --SCM-BRANCH-- $line "$zBranch" line |
|
|
regsub -- --SCM-TAGS-- $line "$zTags" line |
|
|
regsub -- --SCM-DATETIME-- $line "$zVerTime" line |
|
|
|
|
|
if {[regexp $varpattern $line] && ![regexp {^ *typedef} $line]} { |
|
|
set line "SQLITE_API $line" |
|
|
} else { |
|
|
if {[regexp $declpattern1 $line all rettype funcname rest] || \ |
|
|
[regexp $declpattern2 $line all rettype funcname rest] || \ |
|
|
[regexp $declpattern3 $line all rettype funcname rest] || \ |
|
|
[regexp $declpattern4 $line all rettype funcname rest] || \ |
|
|
[regexp $declpattern5 $line all rettype funcname rest]} { |
|
|
set line SQLITE_API |
|
|
append line " " [string trim $rettype] |
|
|
if {[string index $rettype end] ne "*"} { |
|
|
append line " " |
|
|
} |
|
|
if {$useapicall} { |
|
|
if {[lsearch -exact $cdecllist $funcname] >= 0} { |
|
|
append line SQLITE_CDECL " " |
|
|
} else { |
|
|
append line SQLITE_APICALL " " |
|
|
} |
|
|
} |
|
|
append line $funcname $rest |
|
|
} |
|
|
} |
|
|
if {$useapicall} { |
|
|
set line [string map [list (*sqlite3_syscall_ptr) \ |
|
|
"(SQLITE_SYSAPI *sqlite3_syscall_ptr)"] $line] |
|
|
regsub {\(\*} $line {(SQLITE_CALLBACK *} line |
|
|
} |
|
|
puts $out $line |
|
|
} |
|
|
close $in |
|
|
if {![regexp {sqlite\.h\.in} $file]} { |
|
|
puts $out "/******** End of [file tail $file] *********/" |
|
|
} |
|
|
} |
|
|
puts $out "#endif /* SQLITE3_H */" |
|
|
|