OLD | NEW |
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-noext.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 set addstatic 1 |
30 set addstatic 0 | 30 set linemacros 0 |
31 } else { | 31 set useapicall 0 |
32 set addstatic 1 | 32 for {set i 0} {$i<[llength $argv]} {incr i} { |
33 } | 33 set x [lindex $argv $i] |
34 if {[lsearch $argv --linemacros]>=0} { | 34 if {[regexp {^-+nostatic$} $x]} { |
35 set linemacros 1 | 35 set addstatic 0 |
36 } else { | 36 } elseif {[regexp {^-+linemacros} $x]} { |
37 set linemacros 0 | 37 set linemacros 1 |
| 38 } elseif {[regexp {^-+useapicall} $x]} { |
| 39 set useapicall 1 |
| 40 } else { |
| 41 error "unknown command-line option: $x" |
| 42 } |
38 } | 43 } |
39 set in [open tsrc/sqlite3.h] | 44 set in [open tsrc/sqlite3.h] |
40 set cnt 0 | 45 set cnt 0 |
41 set VERSION ????? | 46 set VERSION ????? |
42 while {![eof $in]} { | 47 while {![eof $in]} { |
43 set line [gets $in] | 48 set line [gets $in] |
44 if {$line=="" && [eof $in]} break | 49 if {$line=="" && [eof $in]} break |
45 incr cnt | 50 incr cnt |
46 regexp {#define\s+SQLITE_VERSION\s+"(.*)"} $line all VERSION | 51 regexp {#define\s+SQLITE_VERSION\s+"(.*)"} $line all VERSION |
47 } | 52 } |
48 close $in | 53 close $in |
49 | 54 |
50 # 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 |
51 # of the file. | 56 # of the file. |
52 # | 57 # |
53 set out [open sqlite3.c w] | 58 set out [open sqlite3.c w] |
54 # Force the output to use unix line endings, even on Windows. | 59 # Force the output to use unix line endings, even on Windows. |
55 fconfigure $out -translation lf | 60 fconfigure $out -translation lf |
56 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] |
57 puts $out [subst \ | 62 puts $out [subst \ |
58 {/****************************************************************************** | 63 {/****************************************************************************** |
59 ** 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 |
60 ** 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 |
61 ** 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 |
62 ** 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 |
63 ** possible if the files were compiled separately. Performance improvements | 68 ** possible if the files were compiled separately. Performance improvements |
64 ** 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 |
65 ** translation unit. | 70 ** translation unit. |
66 ** | 71 ** |
67 ** 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 |
68 ** 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 |
69 ** 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 |
70 ** 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 |
71 ** 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 |
72 ** 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 |
73 ** 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 |
74 ** 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 |
75 ** 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. |
76 */ | 81 */ |
77 #define SQLITE_CORE 1 | 82 #define SQLITE_CORE 1 |
78 #define SQLITE_AMALGAMATION 1}] | 83 #define SQLITE_AMALGAMATION 1}] |
79 if {$addstatic} { | 84 if {$addstatic} { |
80 puts $out \ | 85 puts $out \ |
81 {#ifndef SQLITE_PRIVATE | 86 {#ifndef SQLITE_PRIVATE |
82 # define SQLITE_PRIVATE static | 87 # define SQLITE_PRIVATE static |
83 #endif} | 88 #endif} |
84 } | 89 } |
85 | 90 |
86 # 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 |
87 # 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 |
88 # 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. |
89 # | 94 # |
90 foreach hdr { | 95 foreach hdr { |
91 btree.h | 96 btree.h |
92 btreeInt.h | 97 btreeInt.h |
93 hash.h | 98 hash.h |
94 hwtime.h | 99 hwtime.h |
95 keywordhash.h | 100 keywordhash.h |
96 msvc.h | 101 msvc.h |
97 mutex.h | 102 mutex.h |
98 opcodes.h | 103 opcodes.h |
99 os_common.h | 104 os_common.h |
100 os_setup.h | 105 os_setup.h |
101 os_win.h | 106 os_win.h |
102 os.h | 107 os.h |
103 pager.h | 108 pager.h |
104 parse.h | 109 parse.h |
105 pcache.h | 110 pcache.h |
106 pragma.h | 111 pragma.h |
| 112 sqlite3.h |
107 sqlite3ext.h | 113 sqlite3ext.h |
108 sqlite3.h | |
109 sqliteicu.h | 114 sqliteicu.h |
110 sqliteInt.h | 115 sqliteInt.h |
111 sqliteLimit.h | 116 sqliteLimit.h |
112 vdbe.h | 117 vdbe.h |
113 vdbeInt.h | 118 vdbeInt.h |
114 vxworks.h | 119 vxworks.h |
115 wal.h | 120 wal.h |
116 whereInt.h | 121 whereInt.h |
117 } { | 122 } { |
118 set available_hdr($hdr) 1 | 123 set available_hdr($hdr) 1 |
(...skipping 29 matching lines...) Expand all Loading... |
148 set nstar [expr {60 - $n}] | 153 set nstar [expr {60 - $n}] |
149 set stars [string range $s78 0 $nstar] | 154 set stars [string range $s78 0 $nstar] |
150 puts $out "/************** $text $stars/" | 155 puts $out "/************** $text $stars/" |
151 } | 156 } |
152 | 157 |
153 # Read the source file named $filename and write it into the | 158 # Read the source file named $filename and write it into the |
154 # sqlite3.c output file. If any #include statements are seen, | 159 # sqlite3.c output file. If any #include statements are seen, |
155 # process them appropriately. | 160 # process them appropriately. |
156 # | 161 # |
157 proc copy_file {filename} { | 162 proc copy_file {filename} { |
158 global seen_hdr available_hdr varonly_hdr cdecllist out addstatic linemacros | 163 global seen_hdr available_hdr varonly_hdr cdecllist out |
| 164 global addstatic linemacros useapicall |
159 set ln 0 | 165 set ln 0 |
160 set tail [file tail $filename] | 166 set tail [file tail $filename] |
161 section_comment "Begin file $tail" | 167 section_comment "Begin file $tail" |
162 if {$linemacros} {puts $out "#line 1 \"$filename\""} | 168 if {$linemacros} {puts $out "#line 1 \"$filename\""} |
163 set in [open $filename r] | 169 set in [open $filename r] |
164 set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)} | 170 set varpattern {^[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]+)(\(.*)} | 171 set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)} |
166 if {[file extension $filename]==".h"} { | 172 if {[file extension $filename]==".h"} { |
167 set declpattern " *$declpattern" | 173 set declpattern " *$declpattern" |
168 } | 174 } |
(...skipping 27 matching lines...) Expand all Loading... |
196 puts $out $line | 202 puts $out $line |
197 } else { | 203 } else { |
198 # Comment out the entire line, replacing any nested comment | 204 # Comment out the entire line, replacing any nested comment |
199 # begin/end markers with the harmless substring "**". | 205 # begin/end markers with the harmless substring "**". |
200 puts $out "/* [string map [list /* ** */ **] $line] */" | 206 puts $out "/* [string map [list /* ** */ **] $line] */" |
201 } | 207 } |
202 } elseif {[regexp {^#ifdef __cplusplus} $line]} { | 208 } elseif {[regexp {^#ifdef __cplusplus} $line]} { |
203 puts $out "#if 0" | 209 puts $out "#if 0" |
204 } elseif {!$linemacros && [regexp {^#line} $line]} { | 210 } elseif {!$linemacros && [regexp {^#line} $line]} { |
205 # Skip #line directives. | 211 # Skip #line directives. |
206 } elseif {$addstatic && ![regexp {^(static|typedef)} $line]} { | 212 } elseif {$addstatic |
| 213 && ![regexp {^(static|typedef|SQLITE_PRIVATE)} $line]} { |
207 # Skip adding the SQLITE_PRIVATE or SQLITE_API keyword before | 214 # Skip adding the SQLITE_PRIVATE or SQLITE_API keyword before |
208 # functions if this header file does not need it. | 215 # functions if this header file does not need it. |
209 if {![info exists varonly_hdr($tail)] | 216 if {![info exists varonly_hdr($tail)] |
210 && [regexp $declpattern $line all rettype funcname rest]} { | 217 && [regexp $declpattern $line all rettype funcname rest]} { |
211 regsub {^SQLITE_API } $line {} line | 218 regsub {^SQLITE_API } $line {} line |
212 # Add the SQLITE_PRIVATE or SQLITE_API keyword before functions. | 219 # Add the SQLITE_PRIVATE or SQLITE_API keyword before functions. |
213 # so that linkage can be modified at compile-time. | 220 # so that linkage can be modified at compile-time. |
214 if {[regexp {^sqlite3_} $funcname]} { | 221 if {[regexp {^sqlite3[a-z]*_} $funcname]} { |
215 set line SQLITE_API | 222 set line SQLITE_API |
216 append line " " [string trim $rettype] | 223 append line " " [string trim $rettype] |
217 if {[string index $rettype end] ne "*"} { | 224 if {[string index $rettype end] ne "*"} { |
218 append line " " | 225 append line " " |
219 } | 226 } |
220 if {[lsearch -exact $cdecllist $funcname] >= 0} { | 227 if {$useapicall} { |
221 append line SQLITE_CDECL | 228 if {[lsearch -exact $cdecllist $funcname] >= 0} { |
222 } else { | 229 append line SQLITE_CDECL " " |
223 append line SQLITE_STDCALL | 230 } else { |
| 231 append line SQLITE_APICALL " " |
| 232 } |
224 } | 233 } |
225 append line " " $funcname $rest | 234 append line $funcname $rest |
226 puts $out $line | 235 puts $out $line |
227 } else { | 236 } else { |
228 puts $out "SQLITE_PRIVATE $line" | 237 puts $out "SQLITE_PRIVATE $line" |
229 } | 238 } |
230 } elseif {[regexp $varpattern $line all varname]} { | 239 } elseif {[regexp $varpattern $line all varname]} { |
231 # Add the SQLITE_PRIVATE before variable declarations or | 240 # Add the SQLITE_PRIVATE before variable declarations or |
232 # definitions for internal use | 241 # definitions for internal use |
233 regsub {^SQLITE_API } $line {} line | 242 regsub {^SQLITE_API } $line {} line |
234 if {![regexp {^sqlite3_} $varname]} { | 243 if {![regexp {^sqlite3_} $varname]} { |
235 regsub {^extern } $line {} line | 244 regsub {^extern } $line {} line |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 mem1.c | 287 mem1.c |
279 mem2.c | 288 mem2.c |
280 mem3.c | 289 mem3.c |
281 mem5.c | 290 mem5.c |
282 mutex.c | 291 mutex.c |
283 mutex_noop.c | 292 mutex_noop.c |
284 mutex_unix.c | 293 mutex_unix.c |
285 mutex_w32.c | 294 mutex_w32.c |
286 malloc.c | 295 malloc.c |
287 printf.c | 296 printf.c |
| 297 treeview.c |
288 random.c | 298 random.c |
289 threads.c | 299 threads.c |
290 utf.c | 300 utf.c |
291 util.c | 301 util.c |
292 hash.c | 302 hash.c |
293 opcodes.c | 303 opcodes.c |
294 | 304 |
295 os_unix.c | 305 os_unix.c |
296 os_win.c | 306 os_win.c |
297 | 307 |
298 bitvec.c | 308 bitvec.c |
299 pcache.c | 309 pcache.c |
300 pcache1.c | 310 pcache1.c |
301 rowset.c | 311 rowset.c |
302 pager.c | 312 pager.c |
303 wal.c | 313 wal.c |
304 | 314 |
305 btmutex.c | 315 btmutex.c |
306 btree.c | 316 btree.c |
307 backup.c | 317 backup.c |
308 | 318 |
309 vdbemem.c | 319 vdbemem.c |
310 vdbeaux.c | 320 vdbeaux.c |
311 vdbeapi.c | 321 vdbeapi.c |
312 vdbetrace.c | 322 vdbetrace.c |
313 vdbe.c | 323 vdbe.c |
314 vdbeblob.c | 324 vdbeblob.c |
315 vdbesort.c | 325 vdbesort.c |
316 journal.c | |
317 memjournal.c | 326 memjournal.c |
318 | 327 |
319 walker.c | 328 walker.c |
320 resolve.c | 329 resolve.c |
321 expr.c | 330 expr.c |
322 alter.c | 331 alter.c |
323 analyze.c | 332 analyze.c |
324 attach.c | 333 attach.c |
325 auth.c | 334 auth.c |
326 build.c | 335 build.c |
327 callback.c | 336 callback.c |
328 delete.c | 337 delete.c |
329 func.c | 338 func.c |
330 fkey.c | 339 fkey.c |
331 insert.c | 340 insert.c |
332 legacy.c | 341 legacy.c |
333 loadext.c | 342 loadext.c |
334 pragma.c | 343 pragma.c |
335 prepare.c | 344 prepare.c |
336 select.c | 345 select.c |
337 table.c | 346 table.c |
338 trigger.c | 347 trigger.c |
339 update.c | 348 update.c |
340 vacuum.c | 349 vacuum.c |
341 vtab.c | 350 vtab.c |
| 351 wherecode.c |
| 352 whereexpr.c |
342 where.c | 353 where.c |
343 | 354 |
344 parse.c | 355 parse.c |
345 | 356 |
346 tokenize.c | 357 tokenize.c |
347 complete.c | 358 complete.c |
348 | 359 |
349 main.c | 360 main.c |
350 notify.c | 361 notify.c |
351 } { | 362 } { |
352 copy_file tsrc/$file | 363 copy_file tsrc/$file |
353 } | 364 } |
354 | 365 |
355 close $out | 366 close $out |
OLD | NEW |