Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: third_party/sqlite/src/tool/mksqlite3h.tcl

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/tclsh 1 #!/usr/bin/tclsh
2 # 2 #
3 # This script constructs the "sqlite3.h" header file from the following 3 # This script constructs the "sqlite3.h" header file from the following
4 # sources: 4 # sources:
5 # 5 #
6 # 1) The src/sqlite.h.in source file. This is the template for sqlite3.h. 6 # 1) The src/sqlite.h.in source file. This is the template for sqlite3.h.
7 # 2) The VERSION file containing the current SQLite version number. 7 # 2) The VERSION file containing the current SQLite version number.
8 # 3) The manifest file from the fossil SCM. This gives use the date. 8 # 3) The manifest file from the fossil SCM. This gives use the date.
9 # 4) The manifest.uuid file from the fossil SCM. This gives the SHA1 hash. 9 # 4) The manifest.uuid file from the fossil SCM. This gives the SHA1 hash.
10 # 10 #
11 # Run this script by specifying the root directory of the source tree 11 # Run this script by specifying the root directory of the source tree
12 # on the command-line. 12 # on the command-line.
13 # 13 #
14 # This script performs processing on src/sqlite.h.in. It: 14 # This script performs processing on src/sqlite.h.in. It:
15 # 15 #
16 # 1) Adds SQLITE_EXTERN in front of the declaration of global variables, 16 # 1) Adds SQLITE_EXTERN in front of the declaration of global variables,
17 # 2) Adds SQLITE_API in front of the declaration of API functions, 17 # 2) Adds SQLITE_API in front of the declaration of API functions,
18 # 3) Replaces the string --VERS-- with the current library version, 18 # 3) Replaces the string --VERS-- with the current library version,
19 # formatted as a string (e.g. "3.6.17"), and 19 # formatted as a string (e.g. "3.6.17"), and
20 # 4) Replaces the string --VERSION-NUMBER-- with current library version, 20 # 4) Replaces the string --VERSION-NUMBER-- with current library version,
21 # formatted as an integer (e.g. "3006017"). 21 # formatted as an integer (e.g. "3006017").
22 # 5) Replaces the string --SOURCE-ID-- with the date and time and sha1 22 # 5) Replaces the string --SOURCE-ID-- with the date and time and sha1
23 # hash of the fossil-scm manifest for the source tree. 23 # hash of the fossil-scm manifest for the source tree.
24 # 6) Adds the SQLITE_CALLBACK calling convention macro in front of all
25 # callback declarations.
24 # 26 #
25 # This script outputs to stdout. 27 # This script outputs to stdout.
26 # 28 #
27 # Example usage: 29 # Example usage:
28 # 30 #
29 # tclsh mksqlite3h.tcl ../sqlite >sqlite3.h 31 # tclsh mksqlite3h.tcl ../sqlite >sqlite3.h
30 # 32 #
31 33
32 34
33 # Get the source tree root directory from the command-line 35 # Get the source tree root directory from the command-line
34 # 36 #
35 set TOP [lindex $argv 0] 37 set TOP [lindex $argv 0]
36 38
39 # Enable use of SQLITE_APICALL macros at the right points?
40 #
41 set useapicall 0
42
43 if {[lsearch -regexp [lrange $argv 1 end] {^-+useapicall}] != -1} {
44 set useapicall 1
45 }
46
37 # Get the SQLite version number (ex: 3.6.18) from the $TOP/VERSION file. 47 # Get the SQLite version number (ex: 3.6.18) from the $TOP/VERSION file.
38 # 48 #
39 set in [open $TOP/VERSION] 49 set in [open $TOP/VERSION]
40 set zVersion [string trim [read $in]] 50 set zVersion [string trim [read $in]]
41 close $in 51 close $in
42 set nVersion [eval format "%d%03d%03d" [split $zVersion .]] 52 set nVersion [eval format "%d%03d%03d" [split $zVersion .]]
43 53
44 # Get the fossil-scm version number from $TOP/manifest.uuid. 54 # Get the fossil-scm version number from $TOP/manifest.uuid.
45 # 55 #
46 set in [open $TOP/manifest.uuid] 56 set in [open $TOP/manifest.uuid]
47 set zUuid [string trim [read $in]] 57 set zUuid [string trim [read $in]]
48 close $in 58 close $in
49 59
50 # Get the fossil-scm check-in date from the "D" card of $TOP/manifest. 60 # Get the fossil-scm check-in date from the "D" card of $TOP/manifest.
51 # 61 #
52 set in [open $TOP/manifest] 62 set in [open $TOP/manifest]
53 set zDate {} 63 set zDate {}
54 while {![eof $in]} { 64 while {![eof $in]} {
55 set line [gets $in] 65 set line [gets $in]
56 if {[regexp {^D (2[-0-9T:]+)} $line all date]} { 66 if {[regexp {^D (2[-0-9T:]+)} $line all date]} {
57 set zDate [string map {T { }} $date] 67 set zDate [string map {T { }} $date]
58 break 68 break
59 } 69 }
60 } 70 }
61 close $in 71 close $in
62 72
63 # Set up patterns for recognizing API declarations. 73 # Set up patterns for recognizing API declarations.
64 # 74 #
65 set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+sqlite3_[_a-zA-Z0-9]+(\[|;| =)} 75 set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+sqlite3_[_a-zA-Z0-9]+(\[|;| =)}
66 set declpattern {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3_[_a-zA-Z0-9]+)(\(.*)$} 76 set declpattern1 {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3_[_a-zA-Z0-9]+)(\(.*)$}
77
78 set declpattern2 \
79 {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3session_[_a-zA-Z0-9]+)(\(.*)$}
80
81 set declpattern3 \
82 {^ *([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3changeset_[_a-zA-Z0-9]+)(\(.*)$}
67 83
68 # Force the output to use unix line endings, even on Windows. 84 # Force the output to use unix line endings, even on Windows.
69 fconfigure stdout -translation lf 85 fconfigure stdout -translation lf
70 86
71 set filelist [subst { 87 set filelist [subst {
72 $TOP/src/sqlite.h.in 88 $TOP/src/sqlite.h.in
73 $TOP/ext/rtree/sqlite3rtree.h 89 $TOP/ext/rtree/sqlite3rtree.h
90 $TOP/ext/session/sqlite3session.h
74 $TOP/ext/fts5/fts5.h 91 $TOP/ext/fts5/fts5.h
75 }] 92 }]
76 93
77 # These are the functions that accept a variable number of arguments. They 94 # These are the functions that accept a variable number of arguments. They
78 # always need to use the "cdecl" calling convention even when another calling 95 # always need to use the "cdecl" calling convention even when another calling
79 # convention (e.g. "stcall") is being used for the rest of the library. 96 # convention (e.g. "stcall") is being used for the rest of the library.
80 set cdecllist { 97 set cdecllist {
81 sqlite3_config 98 sqlite3_config
82 sqlite3_db_config 99 sqlite3_db_config
83 sqlite3_log 100 sqlite3_log
84 sqlite3_mprintf 101 sqlite3_mprintf
85 sqlite3_snprintf 102 sqlite3_snprintf
86 sqlite3_test_control 103 sqlite3_test_control
87 sqlite3_vtab_config 104 sqlite3_vtab_config
88 } 105 }
89 106
90 # Process the source files. 107 # Process the source files.
91 # 108 #
92 foreach file $filelist { 109 foreach file $filelist {
93 set in [open $file] 110 set in [open $file]
111 if {![regexp {sqlite\.h\.in} $file]} {
112 puts "/******** Begin file [file tail $file] *********/"
113 }
94 while {![eof $in]} { 114 while {![eof $in]} {
95 115
96 set line [gets $in] 116 set line [gets $in]
97 117
98 # File sqlite3rtree.h contains a line "#include <sqlite3.h>". Omit this 118 # File sqlite3rtree.h contains a line "#include <sqlite3.h>". Omit this
99 # line when copying sqlite3rtree.h into sqlite3.h. 119 # line when copying sqlite3rtree.h into sqlite3.h.
100 # 120 #
101 if {[string match {*#include*[<"]sqlite3.h[>"]*} $line]} continue 121 if {[string match {*#include*[<"]sqlite3.h[>"]*} $line]} continue
102 122
103 regsub -- --VERS-- $line $zVersion line 123 regsub -- --VERS-- $line $zVersion line
104 regsub -- --VERSION-NUMBER-- $line $nVersion line 124 regsub -- --VERSION-NUMBER-- $line $nVersion line
105 regsub -- --SOURCE-ID-- $line "$zDate $zUuid" line 125 regsub -- --SOURCE-ID-- $line "$zDate $zUuid" line
106 126
107 if {[regexp $varpattern $line] && ![regexp {^ *typedef} $line]} { 127 if {[regexp $varpattern $line] && ![regexp {^ *typedef} $line]} {
108 set line "SQLITE_API $line" 128 set line "SQLITE_API $line"
109 } else { 129 } else {
110 if {[regexp $declpattern $line all rettype funcname rest]} { 130 if {[regexp $declpattern1 $line all rettype funcname rest] || \
131 [regexp $declpattern2 $line all rettype funcname rest] || \
132 [regexp $declpattern3 $line all rettype funcname rest]} {
111 set line SQLITE_API 133 set line SQLITE_API
112 append line " " [string trim $rettype] 134 append line " " [string trim $rettype]
113 if {[string index $rettype end] ne "*"} { 135 if {[string index $rettype end] ne "*"} {
114 append line " " 136 append line " "
115 } 137 }
116 if {[lsearch -exact $cdecllist $funcname] >= 0} { 138 if {$useapicall} {
117 append line SQLITE_CDECL 139 if {[lsearch -exact $cdecllist $funcname] >= 0} {
118 } else { 140 append line SQLITE_CDECL " "
119 append line SQLITE_STDCALL 141 } else {
142 append line SQLITE_APICALL " "
143 }
120 } 144 }
121 append line " " $funcname $rest 145 append line $funcname $rest
122 } 146 }
123 } 147 }
148 if {$useapicall} {
149 set line [string map [list (*sqlite3_syscall_ptr) \
150 "(SQLITE_SYSAPI *sqlite3_syscall_ptr)"] $line]
151 regsub {\(\*} $line {(SQLITE_CALLBACK *} line
152 }
124 puts $line 153 puts $line
125 } 154 }
126 close $in 155 close $in
156 if {![regexp {sqlite\.h\.in} $file]} {
157 puts "/******** End of [file tail $file] *********/"
158 }
127 } 159 }
OLDNEW
« no previous file with comments | « third_party/sqlite/src/tool/mksqlite3c-noext.tcl ('k') | third_party/sqlite/src/tool/mkvsix.tcl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698