aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3internalh.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3internalh.tcl')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3internalh.tcl145
1 files changed, 145 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3internalh.tcl b/libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3internalh.tcl
new file mode 100644
index 0000000..cacd7cb
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/tool/mksqlite3internalh.tcl
@@ -0,0 +1,145 @@
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#
29set in [open tsrc/sqlite3.h]
30set cnt 0
31set VERSION ?????
32while {![eof $in]} {
33 set line [gets $in]
34 if {$line=="" && [eof $in]} break
35 incr cnt
36 regexp {#define\s+SQLITE_VERSION\s+"(.*)"} $line all VERSION
37}
38close $in
39
40# Open the output file and write a header comment at the beginning
41# of the file.
42#
43set out [open sqlite3internal.h w]
44set today [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S UTC" -gmt 1]
45puts $out [subst \
46{/******************************************************************************
47** This file is an amalgamation of many private header files from SQLite
48** version $VERSION.
49*/}]
50
51# These are the header files used by SQLite. The first time any of these
52# files are seen in a #include statement in the C code, include the complete
53# text of the file in-line. The file only needs to be included once.
54#
55foreach hdr {
56 btree.h
57 btreeInt.h
58 hash.h
59 keywordhash.h
60 opcodes.h
61 os_common.h
62 os.h
63 os_os2.h
64 pager.h
65 parse.h
66 sqlite3ext.h
67 sqlite3.h
68 sqliteInt.h
69 sqliteLimit.h
70 vdbe.h
71 vdbeInt.h
72} {
73 set available_hdr($hdr) 1
74}
75
76# 78 stars used for comment formatting.
77set s78 \
78{*****************************************************************************}
79
80# Insert a comment into the code
81#
82proc section_comment {text} {
83 global out s78
84 set n [string length $text]
85 set nstar [expr {60 - $n}]
86 set stars [string range $s78 0 $nstar]
87 puts $out "/************** $text $stars/"
88}
89
90# Read the source file named $filename and write it into the
91# sqlite3.c output file. If any #include statements are seen,
92# process them approprately.
93#
94proc copy_file {filename} {
95 global seen_hdr available_hdr out
96 set tail [file tail $filename]
97 section_comment "Begin file $tail"
98 set in [open $filename r]
99 while {![eof $in]} {
100 set line [gets $in]
101 if {[regexp {^#\s*include\s+["<]([^">]+)[">]} $line all hdr]} {
102 if {[info exists available_hdr($hdr)]} {
103 if {$available_hdr($hdr)} {
104 section_comment "Include $hdr in the middle of $tail"
105 copy_file tsrc/$hdr
106 section_comment "Continuing where we left off in $tail"
107 }
108 } elseif {![info exists seen_hdr($hdr)]} {
109 set seen_hdr($hdr) 1
110 puts $out $line
111 }
112 } elseif {[regexp {^#ifdef __cplusplus} $line]} {
113 puts $out "#if 0"
114 } elseif {[regexp {^#line} $line]} {
115 # Skip #line directives.
116 } else {
117 puts $out $line
118 }
119 }
120 close $in
121 section_comment "End of $tail"
122}
123
124
125# Process the source files. Process files containing commonly
126# used subroutines first in order to help the compiler find
127# inlining opportunities.
128#
129foreach file {
130 sqliteInt.h
131 sqlite3.h
132 btree.h
133 hash.h
134 os.h
135 pager.h
136 parse.h
137 sqlite3ext.h
138 vdbe.h
139} {
140 if {$available_hdr($file)} {
141 copy_file tsrc/$file
142 }
143}
144
145close $out