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

Side by Side Diff: third_party/sqlite/sqlite-src-3100200/tool/mksqlite3c-noext.tcl

Issue 1610543003: [sql] Import reference version of SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 # To build a single huge source file holding all of SQLite (or at 3 # To build a single huge source file holding all of SQLite (or at
4 # least the core components - the test harness, shell, and TCL 4 # least the core components - the test harness, shell, and TCL
5 # interface are omitted.) first do 5 # interface are omitted.) first do
6 # 6 #
7 # make target_source 7 # make target_source
8 # 8 #
9 # The make target above moves all of the source code files into 9 # The make target above moves all of the source code files into
10 # a subdirectory named "tsrc". (This script expects to find the files 10 # a subdirectory named "tsrc". (This script expects to find the files
11 # there and will not work if they are not found.) There are a few 11 # there and will not work if they are not found.) There are a few
12 # generated C code files that are also added to the tsrc directory. 12 # generated C code files that are also added to the tsrc directory.
13 # For example, the "parse.c" and "parse.h" files to implement the 13 # For example, the "parse.c" and "parse.h" files to implement the
14 # the parser are derived from "parse.y" using lemon. And the 14 # the parser are derived from "parse.y" using lemon. And the
15 # "keywordhash.h" files is generated by a program named "mkkeywordhash". 15 # "keywordhash.h" files is generated by a program named "mkkeywordhash".
16 # 16 #
17 # After the "tsrc" directory has been created and populated, run 17 # After the "tsrc" directory has been created and populated, run
18 # this script: 18 # this script:
19 # 19 #
20 # tclsh mksqlite3c.tcl 20 # tclsh mksqlite3c-noext.tcl
21 # 21 #
22 # The amalgamated SQLite code will be written into sqlite3.c 22 # The amalgamated SQLite code will be written into sqlite3.c
23 # 23 #
24 24
25 # Begin by reading the "sqlite3.h" header file. Extract the version number 25 # Begin by reading the "sqlite3.h" header file. Extract the version number
26 # from in this file. The version number is needed to generate the header 26 # from in this file. The version number is needed to generate the header
27 # comment of the amalgamation. 27 # comment of the amalgamation.
28 # 28 #
29 if {[lsearch $argv --nostatic]>=0} { 29 if {[lsearch $argv --nostatic]>=0} {
30 set addstatic 0 30 set addstatic 0
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 ** if you want a wrapper to interface SQLite with your choice of programming 73 ** if you want a wrapper to interface SQLite with your choice of programming
74 ** language. The code for the "sqlite3" command-line shell is also in a 74 ** language. The code for the "sqlite3" command-line shell is also in a
75 ** separate file. This file contains only code for the core SQLite library. 75 ** separate file. This file contains only code for the core SQLite library.
76 */ 76 */
77 #define SQLITE_CORE 1 77 #define SQLITE_CORE 1
78 #define SQLITE_AMALGAMATION 1}] 78 #define SQLITE_AMALGAMATION 1}]
79 if {$addstatic} { 79 if {$addstatic} {
80 puts $out \ 80 puts $out \
81 {#ifndef SQLITE_PRIVATE 81 {#ifndef SQLITE_PRIVATE
82 # define SQLITE_PRIVATE static 82 # define SQLITE_PRIVATE static
83 #endif
84 #ifndef SQLITE_API
85 # define SQLITE_API
86 #endif} 83 #endif}
87 } 84 }
88 85
89 # These are the header files used by SQLite. The first time any of these 86 # These are the header files used by SQLite. The first time any of these
90 # files are seen in a #include statement in the C code, include the complete 87 # files are seen in a #include statement in the C code, include the complete
91 # text of the file in-line. The file only needs to be included once. 88 # text of the file in-line. The file only needs to be included once.
92 # 89 #
93 foreach hdr { 90 foreach hdr {
94 btree.h 91 btree.h
95 btreeInt.h 92 btreeInt.h
96 fts3.h
97 fts3Int.h
98 fts3_hash.h
99 fts3_tokenizer.h
100 hash.h 93 hash.h
101 hwtime.h 94 hwtime.h
102 keywordhash.h 95 keywordhash.h
96 msvc.h
103 mutex.h 97 mutex.h
104 opcodes.h 98 opcodes.h
105 os_common.h 99 os_common.h
106 os_setup.h 100 os_setup.h
107 os_win.h 101 os_win.h
108 os.h 102 os.h
109 pager.h 103 pager.h
110 parse.h 104 parse.h
111 pcache.h 105 pcache.h
112 rtree.h 106 pragma.h
113 sqlite3ext.h 107 sqlite3ext.h
114 sqlite3.h 108 sqlite3.h
115 sqliteicu.h 109 sqliteicu.h
116 sqliteInt.h 110 sqliteInt.h
117 sqliteLimit.h 111 sqliteLimit.h
118 vdbe.h 112 vdbe.h
119 vdbeInt.h 113 vdbeInt.h
114 vxworks.h
120 wal.h 115 wal.h
121 whereInt.h 116 whereInt.h
122 } { 117 } {
123 set available_hdr($hdr) 1 118 set available_hdr($hdr) 1
124 } 119 }
125 set available_hdr(sqliteInt.h) 0 120 set available_hdr(sqliteInt.h) 0
126 121
122 # These headers should be copied into the amalgamation without modifying any
123 # of their function declarations or definitions.
124 set varonly_hdr(sqlite3.h) 1
125
126 # These are the functions that accept a variable number of arguments. They
127 # always need to use the "cdecl" calling convention even when another calling
128 # convention (e.g. "stcall") is being used for the rest of the library.
129 set cdecllist {
130 sqlite3_config
131 sqlite3_db_config
132 sqlite3_log
133 sqlite3_mprintf
134 sqlite3_snprintf
135 sqlite3_test_control
136 sqlite3_vtab_config
137 }
138
127 # 78 stars used for comment formatting. 139 # 78 stars used for comment formatting.
128 set s78 \ 140 set s78 \
129 {*****************************************************************************} 141 {*****************************************************************************}
130 142
131 # Insert a comment into the code 143 # Insert a comment into the code
132 # 144 #
133 proc section_comment {text} { 145 proc section_comment {text} {
134 global out s78 146 global out s78
135 set n [string length $text] 147 set n [string length $text]
136 set nstar [expr {60 - $n}] 148 set nstar [expr {60 - $n}]
137 set stars [string range $s78 0 $nstar] 149 set stars [string range $s78 0 $nstar]
138 puts $out "/************** $text $stars/" 150 puts $out "/************** $text $stars/"
139 } 151 }
140 152
141 # Read the source file named $filename and write it into the 153 # Read the source file named $filename and write it into the
142 # sqlite3.c output file. If any #include statements are seen, 154 # sqlite3.c output file. If any #include statements are seen,
143 # process them appropriately. 155 # process them appropriately.
144 # 156 #
145 proc copy_file {filename} { 157 proc copy_file {filename} {
146 global seen_hdr available_hdr out addstatic linemacros 158 global seen_hdr available_hdr varonly_hdr cdecllist out addstatic linemacros
147 set ln 0 159 set ln 0
148 set tail [file tail $filename] 160 set tail [file tail $filename]
149 section_comment "Begin file $tail" 161 section_comment "Begin file $tail"
150 if {$linemacros} {puts $out "#line 1 \"$filename\""} 162 if {$linemacros} {puts $out "#line 1 \"$filename\""}
151 set in [open $filename r] 163 set in [open $filename r]
152 set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)} 164 set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)}
153 set declpattern {[a-zA-Z][a-zA-Z_0-9 ]+ \**(sqlite3[_a-zA-Z0-9]+)\(} 165 set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)}
154 if {[file extension $filename]==".h"} { 166 if {[file extension $filename]==".h"} {
155 set declpattern " *$declpattern" 167 set declpattern " *$declpattern"
156 } 168 }
157 set declpattern ^$declpattern 169 set declpattern ^$declpattern\$
158 while {![eof $in]} { 170 while {![eof $in]} {
159 set line [gets $in] 171 set line [gets $in]
160 incr ln 172 incr ln
161 if {[regexp {^\s*#\s*include\s+["<]([^">]+)[">]} $line all hdr]} { 173 if {[regexp {^\s*#\s*include\s+["<]([^">]+)[">]} $line all hdr]} {
162 if {[info exists available_hdr($hdr)]} { 174 if {[info exists available_hdr($hdr)]} {
163 if {$available_hdr($hdr)} { 175 if {$available_hdr($hdr)} {
164 if {$hdr!="os_common.h" && $hdr!="hwtime.h"} { 176 if {$hdr!="os_common.h" && $hdr!="hwtime.h"} {
165 set available_hdr($hdr) 0 177 set available_hdr($hdr) 0
166 } 178 }
167 section_comment "Include $hdr in the middle of $tail" 179 section_comment "Include $hdr in the middle of $tail"
168 copy_file tsrc/$hdr 180 copy_file tsrc/$hdr
169 section_comment "Continuing where we left off in $tail" 181 section_comment "Continuing where we left off in $tail"
170 if {$linemacros} {puts $out "#line [expr {$ln+1}] \"$filename\""} 182 if {$linemacros} {puts $out "#line [expr {$ln+1}] \"$filename\""}
183 } else {
184 # Comment out the entire line, replacing any nested comment
185 # begin/end markers with the harmless substring "**".
186 puts $out "/* [string map [list /* ** */ **] $line] */"
171 } 187 }
172 } elseif {![info exists seen_hdr($hdr)]} { 188 } elseif {![info exists seen_hdr($hdr)]} {
173 if {![regexp {/\*\s+amalgamator:\s+dontcache\s+\*/} $line]} { 189 if {![regexp {/\*\s+amalgamator:\s+dontcache\s+\*/} $line]} {
174 set seen_hdr($hdr) 1 190 set seen_hdr($hdr) 1
175 } 191 }
176 puts $out $line 192 puts $out $line
177 } elseif {[regexp {/\*\s+amalgamator:\s+keep\s+\*/} $line]} { 193 } elseif {[regexp {/\*\s+amalgamator:\s+keep\s+\*/} $line]} {
178 # This include file must be kept because there was a "keep" 194 # This include file must be kept because there was a "keep"
179 # directive inside of a line comment. 195 # directive inside of a line comment.
180 puts $out $line 196 puts $out $line
181 } else { 197 } else {
182 # Comment out the entire line, replacing any nested comment 198 # Comment out the entire line, replacing any nested comment
183 # begin/end markers with the harmless substring "**". 199 # begin/end markers with the harmless substring "**".
184 puts $out "/* [string map [list /* ** */ **] $line] */" 200 puts $out "/* [string map [list /* ** */ **] $line] */"
185 } 201 }
186 } elseif {[regexp {^#ifdef __cplusplus} $line]} { 202 } elseif {[regexp {^#ifdef __cplusplus} $line]} {
187 puts $out "#if 0" 203 puts $out "#if 0"
188 } elseif {!$linemacros && [regexp {^#line} $line]} { 204 } elseif {!$linemacros && [regexp {^#line} $line]} {
189 # Skip #line directives. 205 # Skip #line directives.
190 } elseif {$addstatic && ![regexp {^(static|typedef)} $line]} { 206 } elseif {$addstatic && ![regexp {^(static|typedef)} $line]} {
191 regsub {^SQLITE_API } $line {} line 207 # Skip adding the SQLITE_PRIVATE or SQLITE_API keyword before
192 if {[regexp $declpattern $line all funcname]} { 208 # functions if this header file does not need it.
209 if {![info exists varonly_hdr($tail)]
210 && [regexp $declpattern $line all rettype funcname rest]} {
211 regsub {^SQLITE_API } $line {} line
193 # Add the SQLITE_PRIVATE or SQLITE_API keyword before functions. 212 # Add the SQLITE_PRIVATE or SQLITE_API keyword before functions.
194 # so that linkage can be modified at compile-time. 213 # so that linkage can be modified at compile-time.
195 if {[regexp {^sqlite3_} $funcname]} { 214 if {[regexp {^sqlite3_} $funcname]} {
196 puts $out "SQLITE_API $line" 215 set line SQLITE_API
216 append line " " [string trim $rettype]
217 if {[string index $rettype end] ne "*"} {
218 append line " "
219 }
220 if {[lsearch -exact $cdecllist $funcname] >= 0} {
221 append line SQLITE_CDECL
222 } else {
223 append line SQLITE_STDCALL
224 }
225 append line " " $funcname $rest
226 puts $out $line
197 } else { 227 } else {
198 puts $out "SQLITE_PRIVATE $line" 228 puts $out "SQLITE_PRIVATE $line"
199 } 229 }
200 } elseif {[regexp $varpattern $line all varname]} { 230 } elseif {[regexp $varpattern $line all varname]} {
201 # Add the SQLITE_PRIVATE before variable declarations or 231 # Add the SQLITE_PRIVATE before variable declarations or
202 # definitions for internal use 232 # definitions for internal use
203 if {![regexp {^sqlite3_} $varname]} { 233 regsub {^SQLITE_API } $line {} line
204 regsub {^extern } $line {} line 234 if {![regexp {^sqlite3_} $varname]} {
205 puts $out "SQLITE_PRIVATE $line" 235 regsub {^extern } $line {} line
206 } else { 236 puts $out "SQLITE_PRIVATE $line"
207 if {[regexp {const char sqlite3_version\[\];} $line]} { 237 } else {
208 set line {const char sqlite3_version[] = SQLITE_VERSION;} 238 if {[regexp {const char sqlite3_version\[\];} $line]} {
239 set line {const char sqlite3_version[] = SQLITE_VERSION;}
240 }
241 regsub {^SQLITE_EXTERN } $line {} line
242 puts $out "SQLITE_API $line"
209 } 243 }
210 regsub {^SQLITE_EXTERN } $line {} line
211 puts $out "SQLITE_API $line"
212 }
213 } elseif {[regexp {^(SQLITE_EXTERN )?void \(\*sqlite3IoTrace\)} $line]} { 244 } elseif {[regexp {^(SQLITE_EXTERN )?void \(\*sqlite3IoTrace\)} $line]} {
245 regsub {^SQLITE_API } $line {} line
214 regsub {^SQLITE_EXTERN } $line {} line 246 regsub {^SQLITE_EXTERN } $line {} line
215 puts $out "SQLITE_PRIVATE $line" 247 puts $out $line
216 } elseif {[regexp {^void \(\*sqlite3Os} $line]} { 248 } elseif {[regexp {^void \(\*sqlite3Os} $line]} {
249 regsub {^SQLITE_API } $line {} line
217 puts $out "SQLITE_PRIVATE $line" 250 puts $out "SQLITE_PRIVATE $line"
218 } else { 251 } else {
219 puts $out $line 252 puts $out $line
220 } 253 }
221 } else { 254 } else {
222 puts $out $line 255 puts $out $line
223 } 256 }
224 } 257 }
225 close $in 258 close $in
226 section_comment "End of $tail" 259 section_comment "End of $tail"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 vtab.c 341 vtab.c
309 where.c 342 where.c
310 343
311 parse.c 344 parse.c
312 345
313 tokenize.c 346 tokenize.c
314 complete.c 347 complete.c
315 348
316 main.c 349 main.c
317 notify.c 350 notify.c
318
319 recover.c
320
321 fts3.c
322 fts3_aux.c
323 fts3_expr.c
324 fts3_hash.c
325 fts3_porter.c
326 fts3_tokenizer.c
327 fts3_tokenizer1.c
328 fts3_tokenize_vtab.c
329 fts3_write.c
330 fts3_snippet.c
331 fts3_unicode.c
332 fts3_unicode2.c
333
334 rtree.c
335 icu.c
336 fts3_icu.c
337 } { 351 } {
338 copy_file tsrc/$file 352 copy_file tsrc/$file
339 } 353 }
340 354
341 close $out 355 close $out
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3100200/tool/mksqlite3c.tcl ('k') | third_party/sqlite/sqlite-src-3100200/tool/mksqlite3h.tcl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698