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

Side by Side Diff: third_party/sqlite/src/tool/mksqlite3c.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 # 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 --srcdir $SRC 20 # tclsh mksqlite3c.tcl --srcdir $SRC
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 set addstatic 1 29 set addstatic 1
30 set linemacros 0 30 set linemacros 0
31 set useapicall 0
31 for {set i 0} {$i<[llength $argv]} {incr i} { 32 for {set i 0} {$i<[llength $argv]} {incr i} {
32 set x [lindex $argv $i] 33 set x [lindex $argv $i]
33 if {[regexp {^-+nostatic$} $x]} { 34 if {[regexp {^-+nostatic$} $x]} {
34 set addstatic 0 35 set addstatic 0
35 } elseif {[regexp {^-+linemacros} $x]} { 36 } elseif {[regexp {^-+linemacros} $x]} {
36 set linemacros 1 37 set linemacros 1
38 } elseif {[regexp {^-+useapicall} $x]} {
39 set useapicall 1
37 } else { 40 } else {
38 error "unknown command-line option: $x" 41 error "unknown command-line option: $x"
39 } 42 }
40 } 43 }
41 set in [open tsrc/sqlite3.h] 44 set in [open tsrc/sqlite3.h]
42 set cnt 0 45 set cnt 0
43 set VERSION ????? 46 set VERSION ?????
44 while {![eof $in]} { 47 while {![eof $in]} {
45 set line [gets $in] 48 set line [gets $in]
46 if {$line=="" && [eof $in]} break 49 if {$line=="" && [eof $in]} break
47 incr cnt 50 incr cnt
48 regexp {#define\s+SQLITE_VERSION\s+"(.*)"} $line all VERSION 51 regexp {#define\s+SQLITE_VERSION\s+"(.*)"} $line all VERSION
49 } 52 }
50 close $in 53 close $in
51 54
52 # Open the output file and write a header comment at the beginning 55 # Open the output file and write a header comment at the beginning
53 # of the file. 56 # of the file.
54 # 57 #
55 set out [open sqlite3.c w] 58 set out [open sqlite3.c w]
56 # Force the output to use unix line endings, even on Windows. 59 # Force the output to use unix line endings, even on Windows.
57 fconfigure $out -translation lf 60 fconfigure $out -translation lf
58 set today [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S UTC" -gmt 1] 61 set today [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S UTC" -gmt 1]
59 puts $out [subst \ 62 puts $out [subst \
60 {/****************************************************************************** 63 {/******************************************************************************
61 ** This file is an amalgamation of many separate C source files from SQLite 64 ** This file is an amalgamation of many separate C source files from SQLite
62 ** version $VERSION. By combining all the individual C code files into this 65 ** version $VERSION. By combining all the individual C code files into this
63 ** single large file, the entire code can be compiled as a single translation 66 ** single large file, the entire code can be compiled as a single translation
64 ** unit. This allows many compilers to do optimizations that would not be 67 ** unit. This allows many compilers to do optimizations that would not be
65 ** possible if the files were compiled separately. Performance improvements 68 ** possible if the files were compiled separately. Performance improvements
66 ** of 5% or more are commonly seen when SQLite is compiled as a single 69 ** of 5% or more are commonly seen when SQLite is compiled as a single
67 ** translation unit. 70 ** translation unit.
68 ** 71 **
69 ** This file is all you need to compile SQLite. To use SQLite in other 72 ** This file is all you need to compile SQLite. To use SQLite in other
70 ** programs, you need this file and the "sqlite3.h" header file that defines 73 ** programs, you need this file and the "sqlite3.h" header file that defines
71 ** the programming interface to the SQLite library. (If you do not have 74 ** the programming interface to the SQLite library. (If you do not have
72 ** the "sqlite3.h" header file at hand, you will find a copy embedded within 75 ** the "sqlite3.h" header file at hand, you will find a copy embedded within
73 ** the text of this file. Search for "Begin file sqlite3.h" to find the start 76 ** the text of this file. Search for "Begin file sqlite3.h" to find the start
74 ** of the embedded sqlite3.h header file.) Additional code files may be needed 77 ** of the embedded sqlite3.h header file.) Additional code files may be needed
75 ** if you want a wrapper to interface SQLite with your choice of programming 78 ** if you want a wrapper to interface SQLite with your choice of programming
76 ** language. The code for the "sqlite3" command-line shell is also in a 79 ** language. The code for the "sqlite3" command-line shell is also in a
77 ** separate file. This file contains only code for the core SQLite library. 80 ** separate file. This file contains only code for the core SQLite library.
78 */ 81 */
79 #define SQLITE_CORE 1 82 #define SQLITE_CORE 1
80 #define SQLITE_AMALGAMATION 1}] 83 #define SQLITE_AMALGAMATION 1}]
81 if {$addstatic} { 84 if {$addstatic} {
82 puts $out \ 85 puts $out \
83 {#ifndef SQLITE_PRIVATE 86 {#ifndef SQLITE_PRIVATE
84 # define SQLITE_PRIVATE static 87 # define SQLITE_PRIVATE static
85 #endif} 88 #endif}
86 } 89 }
87 90
88 # These are the header files used by SQLite. The first time any of these 91 # These are the header files used by SQLite. The first time any of these
89 # files are seen in a #include statement in the C code, include the complete 92 # files are seen in a #include statement in the C code, include the complete
90 # text of the file in-line. The file only needs to be included once. 93 # text of the file in-line. The file only needs to be included once.
91 # 94 #
92 foreach hdr { 95 foreach hdr {
93 btree.h 96 btree.h
94 btreeInt.h 97 btreeInt.h
95 fts3.h 98 fts3.h
96 fts3Int.h 99 fts3Int.h
97 fts3_hash.h 100 fts3_hash.h
98 fts3_tokenizer.h 101 fts3_tokenizer.h
99 hash.h 102 hash.h
100 hwtime.h 103 hwtime.h
101 keywordhash.h 104 keywordhash.h
102 msvc.h 105 msvc.h
103 mutex.h 106 mutex.h
104 opcodes.h 107 opcodes.h
105 os_common.h 108 os_common.h
106 os_setup.h 109 os_setup.h
107 os_win.h 110 os_win.h
108 os.h 111 os.h
109 pager.h 112 pager.h
110 parse.h 113 parse.h
111 pcache.h 114 pcache.h
112 pragma.h 115 pragma.h
113 rtree.h 116 rtree.h
117 sqlite3session.h
114 sqlite3.h 118 sqlite3.h
115 sqlite3ext.h 119 sqlite3ext.h
116 sqlite3rbu.h 120 sqlite3rbu.h
117 sqliteicu.h 121 sqliteicu.h
118 sqliteInt.h 122 sqliteInt.h
119 sqliteLimit.h 123 sqliteLimit.h
120 vdbe.h 124 vdbe.h
121 vdbeInt.h 125 vdbeInt.h
122 vxworks.h 126 vxworks.h
123 wal.h 127 wal.h
124 whereInt.h 128 whereInt.h
125 } { 129 } {
126 set available_hdr($hdr) 1 130 set available_hdr($hdr) 1
127 } 131 }
128 set available_hdr(sqliteInt.h) 0 132 set available_hdr(sqliteInt.h) 0
133 set available_hdr(sqlite3session.h) 0
129 134
130 # These headers should be copied into the amalgamation without modifying any 135 # These headers should be copied into the amalgamation without modifying any
131 # of their function declarations or definitions. 136 # of their function declarations or definitions.
132 set varonly_hdr(sqlite3.h) 1 137 set varonly_hdr(sqlite3.h) 1
133 138
134 # These are the functions that accept a variable number of arguments. They 139 # These are the functions that accept a variable number of arguments. They
135 # always need to use the "cdecl" calling convention even when another calling 140 # always need to use the "cdecl" calling convention even when another calling
136 # convention (e.g. "stcall") is being used for the rest of the library. 141 # convention (e.g. "stcall") is being used for the rest of the library.
137 set cdecllist { 142 set cdecllist {
138 sqlite3_config 143 sqlite3_config
(...skipping 17 matching lines...) Expand all
156 set nstar [expr {60 - $n}] 161 set nstar [expr {60 - $n}]
157 set stars [string range $s78 0 $nstar] 162 set stars [string range $s78 0 $nstar]
158 puts $out "/************** $text $stars/" 163 puts $out "/************** $text $stars/"
159 } 164 }
160 165
161 # Read the source file named $filename and write it into the 166 # Read the source file named $filename and write it into the
162 # sqlite3.c output file. If any #include statements are seen, 167 # sqlite3.c output file. If any #include statements are seen,
163 # process them appropriately. 168 # process them appropriately.
164 # 169 #
165 proc copy_file {filename} { 170 proc copy_file {filename} {
166 global seen_hdr available_hdr varonly_hdr cdecllist out addstatic linemacros 171 global seen_hdr available_hdr varonly_hdr cdecllist out
172 global addstatic linemacros useapicall
167 set ln 0 173 set ln 0
168 set tail [file tail $filename] 174 set tail [file tail $filename]
169 section_comment "Begin file $tail" 175 section_comment "Begin file $tail"
170 if {$linemacros} {puts $out "#line 1 \"$filename\""} 176 if {$linemacros} {puts $out "#line 1 \"$filename\""}
171 set in [open $filename r] 177 set in [open $filename r]
172 set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)} 178 set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)}
173 set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)} 179 set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)}
174 if {[file extension $filename]==".h"} { 180 if {[file extension $filename]==".h"} {
175 set declpattern " *$declpattern" 181 set declpattern " *$declpattern"
176 } 182 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 # Skip #line directives. 219 # Skip #line directives.
214 } elseif {$addstatic 220 } elseif {$addstatic
215 && ![regexp {^(static|typedef|SQLITE_PRIVATE)} $line]} { 221 && ![regexp {^(static|typedef|SQLITE_PRIVATE)} $line]} {
216 # Skip adding the SQLITE_PRIVATE or SQLITE_API keyword before 222 # Skip adding the SQLITE_PRIVATE or SQLITE_API keyword before
217 # functions if this header file does not need it. 223 # functions if this header file does not need it.
218 if {![info exists varonly_hdr($tail)] 224 if {![info exists varonly_hdr($tail)]
219 && [regexp $declpattern $line all rettype funcname rest]} { 225 && [regexp $declpattern $line all rettype funcname rest]} {
220 regsub {^SQLITE_API } $line {} line 226 regsub {^SQLITE_API } $line {} line
221 # Add the SQLITE_PRIVATE or SQLITE_API keyword before functions. 227 # Add the SQLITE_PRIVATE or SQLITE_API keyword before functions.
222 # so that linkage can be modified at compile-time. 228 # so that linkage can be modified at compile-time.
223 if {[regexp {^sqlite3(_|rbu_)} $funcname]} { 229 if {[regexp {^sqlite3[a-z]*_} $funcname]} {
224 set line SQLITE_API 230 set line SQLITE_API
225 append line " " [string trim $rettype] 231 append line " " [string trim $rettype]
226 if {[string index $rettype end] ne "*"} { 232 if {[string index $rettype end] ne "*"} {
227 append line " " 233 append line " "
228 } 234 }
229 if {[lsearch -exact $cdecllist $funcname] >= 0} { 235 if {$useapicall} {
230 append line SQLITE_CDECL 236 if {[lsearch -exact $cdecllist $funcname] >= 0} {
231 } else { 237 append line SQLITE_CDECL " "
232 append line SQLITE_STDCALL 238 } else {
239 append line SQLITE_APICALL " "
240 }
233 } 241 }
234 append line " " $funcname $rest 242 append line $funcname $rest
235 puts $out $line 243 puts $out $line
236 } else { 244 } else {
237 puts $out "SQLITE_PRIVATE $line" 245 puts $out "SQLITE_PRIVATE $line"
238 } 246 }
239 } elseif {[regexp $varpattern $line all varname]} { 247 } elseif {[regexp $varpattern $line all varname]} {
240 # Add the SQLITE_PRIVATE before variable declarations or 248 # Add the SQLITE_PRIVATE before variable declarations or
241 # definitions for internal use 249 # definitions for internal use
242 regsub {^SQLITE_API } $line {} line 250 regsub {^SQLITE_API } $line {} line
243 if {![regexp {^sqlite3_} $varname]} { 251 if {![regexp {^sqlite3_} $varname]} {
244 regsub {^extern } $line {} line 252 regsub {^extern } $line {} line
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 btree.c 324 btree.c
317 backup.c 325 backup.c
318 326
319 vdbemem.c 327 vdbemem.c
320 vdbeaux.c 328 vdbeaux.c
321 vdbeapi.c 329 vdbeapi.c
322 vdbetrace.c 330 vdbetrace.c
323 vdbe.c 331 vdbe.c
324 vdbeblob.c 332 vdbeblob.c
325 vdbesort.c 333 vdbesort.c
326 journal.c
327 memjournal.c 334 memjournal.c
328 335
329 walker.c 336 walker.c
330 resolve.c 337 resolve.c
331 expr.c 338 expr.c
332 alter.c 339 alter.c
333 analyze.c 340 analyze.c
334 attach.c 341 attach.c
335 auth.c 342 auth.c
336 build.c 343 build.c
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 fts3_write.c 379 fts3_write.c
373 fts3_snippet.c 380 fts3_snippet.c
374 fts3_unicode.c 381 fts3_unicode.c
375 fts3_unicode2.c 382 fts3_unicode2.c
376 383
377 rtree.c 384 rtree.c
378 icu.c 385 icu.c
379 fts3_icu.c 386 fts3_icu.c
380 sqlite3rbu.c 387 sqlite3rbu.c
381 dbstat.c 388 dbstat.c
389 sqlite3session.c
382 json1.c 390 json1.c
383 fts5.c 391 fts5.c
384 } { 392 } {
385 copy_file tsrc/$file 393 copy_file tsrc/$file
386 } 394 }
387 395
388 close $out 396 close $out
OLDNEW
« no previous file with comments | « third_party/sqlite/src/tool/mkpragmatab.tcl ('k') | third_party/sqlite/src/tool/mksqlite3c-noext.tcl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698