diff options
author | dan miller | 2007-10-20 02:49:29 +0000 |
---|---|---|
committer | dan miller | 2007-10-20 02:49:29 +0000 |
commit | e36d23a85ebff914d74bb541558c2b6082b78edb (patch) | |
tree | 54b58fdf162e78af64055282a6035c8d2443389d /libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3c.tcl | |
parent | * Fixed an issue whereby avatar chat distances were being calculated against ... (diff) | |
download | opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.zip opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.gz opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.bz2 opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.xz |
sqlite source (unix build) added to libraries
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3c.tcl')
-rw-r--r-- | libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3c.tcl | 266 |
1 files changed, 266 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3c.tcl b/libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3c.tcl new file mode 100644 index 0000000..258beac --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3c.tcl | |||
@@ -0,0 +1,266 @@ | |||
1 | #!/usr/bin/tclsh | ||
2 | # | ||
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 | ||
5 | # interface are omitted.) first do | ||
6 | # | ||
7 | # make target_source | ||
8 | # | ||
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 | ||
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. | ||
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 | ||
15 | # "keywordhash.h" files is generated by a program named "mkkeywordhash". | ||
16 | # | ||
17 | # After the "tsrc" directory has been created and populated, run | ||
18 | # this script: | ||
19 | # | ||
20 | # tclsh mksqlite3c.tcl | ||
21 | # | ||
22 | # The amalgamated SQLite code will be written into sqlite3.c | ||
23 | # | ||
24 | |||
25 | # Begin by reading the "sqlite3.h" header file. Count the number of lines | ||
26 | # in this file and extract the version number. That information will be | ||
27 | # needed in order to generate the header of the amalgamation. | ||
28 | # | ||
29 | if {[lsearch $argv --nostatic]>=0} { | ||
30 | set addstatic 0 | ||
31 | } else { | ||
32 | set addstatic 1 | ||
33 | } | ||
34 | set in [open tsrc/sqlite3.h] | ||
35 | set cnt 0 | ||
36 | set VERSION ????? | ||
37 | while {![eof $in]} { | ||
38 | set line [gets $in] | ||
39 | if {$line=="" && [eof $in]} break | ||
40 | incr cnt | ||
41 | regexp {#define\s+SQLITE_VERSION\s+"(.*)"} $line all VERSION | ||
42 | } | ||
43 | close $in | ||
44 | |||
45 | # Open the output file and write a header comment at the beginning | ||
46 | # of the file. | ||
47 | # | ||
48 | set out [open sqlite3.c w] | ||
49 | set today [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S UTC" -gmt 1] | ||
50 | puts $out [subst \ | ||
51 | {/****************************************************************************** | ||
52 | ** This file is an amalgamation of many separate C source files from SQLite | ||
53 | ** version $VERSION. By combining all the individual C code files into this | ||
54 | ** single large file, the entire code can be compiled as a one translation | ||
55 | ** unit. This allows many compilers to do optimizations that would not be | ||
56 | ** possible if the files were compiled separately. Performance improvements | ||
57 | ** of 5% are more are commonly seen when SQLite is compiled as a single | ||
58 | ** translation unit. | ||
59 | ** | ||
60 | ** This file is all you need to compile SQLite. To use SQLite in other | ||
61 | ** programs, you need this file and the "sqlite3.h" header file that defines | ||
62 | ** the programming interface to the SQLite library. (If you do not have | ||
63 | ** the "sqlite3.h" header file at hand, you will find a copy in the first | ||
64 | ** $cnt lines past this header comment.) Additional code files may be | ||
65 | ** needed if you want a wrapper to interface SQLite with your choice of | ||
66 | ** programming language. The code for the "sqlite3" command-line shell | ||
67 | ** is also in a separate file. This file contains only code for the core | ||
68 | ** SQLite library. | ||
69 | ** | ||
70 | ** This amalgamation was generated on $today. | ||
71 | */ | ||
72 | #define SQLITE_AMALGAMATION 1}] | ||
73 | if {$addstatic} { | ||
74 | puts $out \ | ||
75 | {#ifndef SQLITE_PRIVATE | ||
76 | # define SQLITE_PRIVATE static | ||
77 | #endif | ||
78 | #ifndef SQLITE_API | ||
79 | # define SQLITE_API | ||
80 | #endif} | ||
81 | } | ||
82 | |||
83 | # These are the header files used by SQLite. The first time any of these | ||
84 | # files are seen in a #include statement in the C code, include the complete | ||
85 | # text of the file in-line. The file only needs to be included once. | ||
86 | # | ||
87 | foreach hdr { | ||
88 | btree.h | ||
89 | btreeInt.h | ||
90 | hash.h | ||
91 | keywordhash.h | ||
92 | mutex.h | ||
93 | opcodes.h | ||
94 | os_common.h | ||
95 | os.h | ||
96 | os_os2.h | ||
97 | pager.h | ||
98 | parse.h | ||
99 | sqlite3ext.h | ||
100 | sqlite3.h | ||
101 | sqliteInt.h | ||
102 | sqliteLimit.h | ||
103 | vdbe.h | ||
104 | vdbeInt.h | ||
105 | } { | ||
106 | set available_hdr($hdr) 1 | ||
107 | } | ||
108 | set available_hdr(sqlite3.h) 0 | ||
109 | |||
110 | # 78 stars used for comment formatting. | ||
111 | set s78 \ | ||
112 | {*****************************************************************************} | ||
113 | |||
114 | # Insert a comment into the code | ||
115 | # | ||
116 | proc section_comment {text} { | ||
117 | global out s78 | ||
118 | set n [string length $text] | ||
119 | set nstar [expr {60 - $n}] | ||
120 | set stars [string range $s78 0 $nstar] | ||
121 | puts $out "/************** $text $stars/" | ||
122 | } | ||
123 | |||
124 | # Read the source file named $filename and write it into the | ||
125 | # sqlite3.c output file. If any #include statements are seen, | ||
126 | # process them approprately. | ||
127 | # | ||
128 | proc copy_file {filename} { | ||
129 | global seen_hdr available_hdr out addstatic | ||
130 | set tail [file tail $filename] | ||
131 | section_comment "Begin file $tail" | ||
132 | set in [open $filename r] | ||
133 | set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)} | ||
134 | set declpattern {[a-zA-Z][a-zA-Z_0-9 ]+ \*?(sqlite3[_a-zA-Z0-9]+)\(} | ||
135 | if {[file extension $filename]==".h"} { | ||
136 | set declpattern " *$declpattern" | ||
137 | } | ||
138 | set declpattern ^$declpattern | ||
139 | while {![eof $in]} { | ||
140 | set line [gets $in] | ||
141 | if {[regexp {^#\s*include\s+["<]([^">]+)[">]} $line all hdr]} { | ||
142 | if {[info exists available_hdr($hdr)]} { | ||
143 | if {$available_hdr($hdr)} { | ||
144 | if {$hdr!="os_common.h"} { | ||
145 | set available_hdr($hdr) 0 | ||
146 | } | ||
147 | section_comment "Include $hdr in the middle of $tail" | ||
148 | copy_file tsrc/$hdr | ||
149 | section_comment "Continuing where we left off in $tail" | ||
150 | } | ||
151 | } elseif {![info exists seen_hdr($hdr)]} { | ||
152 | set seen_hdr($hdr) 1 | ||
153 | puts $out $line | ||
154 | } | ||
155 | } elseif {[regexp {^#ifdef __cplusplus} $line]} { | ||
156 | puts $out "#if 0" | ||
157 | } elseif {[regexp {^#line} $line]} { | ||
158 | # Skip #line directives. | ||
159 | } elseif {$addstatic && ![regexp {^(static|typedef)} $line]} { | ||
160 | if {[regexp $declpattern $line all funcname]} { | ||
161 | # Add the SQLITE_PRIVATE or SQLITE_API keyword before functions. | ||
162 | # so that linkage can be modified at compile-time. | ||
163 | if {[regexp {^sqlite3_} $funcname]} { | ||
164 | puts $out "SQLITE_API $line" | ||
165 | } else { | ||
166 | puts $out "SQLITE_PRIVATE $line" | ||
167 | } | ||
168 | } elseif {[regexp $varpattern $line all varname]} { | ||
169 | # Add the SQLITE_PRIVATE before variable declarations or | ||
170 | # definitions for internal use | ||
171 | if {![regexp {^sqlite3_} $varname]} { | ||
172 | regsub {^extern } $line {} line | ||
173 | puts $out "SQLITE_PRIVATE $line" | ||
174 | } elseif {![regexp {^SQLITE_EXTERN} $line]} { | ||
175 | puts $out "SQLITE_API $line" | ||
176 | } else { | ||
177 | puts $out $line | ||
178 | } | ||
179 | } elseif {[regexp {^void \(\*sqlite3_io_trace\)} $line]} { | ||
180 | puts $out "SQLITE_API $line" | ||
181 | } else { | ||
182 | puts $out $line | ||
183 | } | ||
184 | } else { | ||
185 | puts $out $line | ||
186 | } | ||
187 | } | ||
188 | close $in | ||
189 | section_comment "End of $tail" | ||
190 | } | ||
191 | |||
192 | |||
193 | # Process the source files. Process files containing commonly | ||
194 | # used subroutines first in order to help the compiler find | ||
195 | # inlining opportunities. | ||
196 | # | ||
197 | foreach file { | ||
198 | sqlite3.h | ||
199 | |||
200 | date.c | ||
201 | os.c | ||
202 | |||
203 | mem1.c | ||
204 | mem2.c | ||
205 | mutex.c | ||
206 | mutex_os2.c | ||
207 | mutex_unix.c | ||
208 | mutex_w32.c | ||
209 | malloc.c | ||
210 | printf.c | ||
211 | random.c | ||
212 | utf.c | ||
213 | util.c | ||
214 | hash.c | ||
215 | opcodes.c | ||
216 | |||
217 | os_os2.c | ||
218 | os_unix.c | ||
219 | os_win.c | ||
220 | |||
221 | pager.c | ||
222 | |||
223 | btmutex.c | ||
224 | btree.c | ||
225 | |||
226 | vdbefifo.c | ||
227 | vdbemem.c | ||
228 | vdbeaux.c | ||
229 | vdbeapi.c | ||
230 | vdbe.c | ||
231 | vdbeblob.c | ||
232 | journal.c | ||
233 | |||
234 | expr.c | ||
235 | alter.c | ||
236 | analyze.c | ||
237 | attach.c | ||
238 | auth.c | ||
239 | build.c | ||
240 | callback.c | ||
241 | delete.c | ||
242 | func.c | ||
243 | insert.c | ||
244 | legacy.c | ||
245 | loadext.c | ||
246 | pragma.c | ||
247 | prepare.c | ||
248 | select.c | ||
249 | table.c | ||
250 | trigger.c | ||
251 | update.c | ||
252 | vacuum.c | ||
253 | vtab.c | ||
254 | where.c | ||
255 | |||
256 | parse.c | ||
257 | |||
258 | tokenize.c | ||
259 | complete.c | ||
260 | |||
261 | main.c | ||
262 | } { | ||
263 | copy_file tsrc/$file | ||
264 | } | ||
265 | |||
266 | close $out | ||