OLD | NEW |
1 #!/usr/bin/tclsh | 1 #!/usr/bin/tclsh |
2 # | 2 # |
3 # This script constructs the "sqlite3.h" header file from the following | 3 # This script constructs the "sqlite3.h" header file from the following |
4 # sources: | 4 # sources: |
5 # | 5 # |
6 # 1) The src/sqlite.h.in source file. This is the template for sqlite3.h. | 6 # 1) The src/sqlite.h.in source file. This is the template for sqlite3.h. |
7 # 2) The VERSION file containing the current SQLite version number. | 7 # 2) The VERSION file containing the current SQLite version number. |
8 # 3) The manifest file from the fossil SCM. This gives use the date. | 8 # 3) The manifest file from the fossil SCM. This gives use the date. |
9 # 4) The manifest.uuid file from the fossil SCM. This gives the SHA1 hash. | 9 # 4) The manifest.uuid file from the fossil SCM. This gives the SHA1 hash. |
10 # | 10 # |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 break | 58 break |
59 } | 59 } |
60 } | 60 } |
61 close $in | 61 close $in |
62 | 62 |
63 # Set up patterns for recognizing API declarations. | 63 # Set up patterns for recognizing API declarations. |
64 # | 64 # |
65 set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+sqlite3_[_a-zA-Z0-9]+(\[|;| =)} | 65 set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+sqlite3_[_a-zA-Z0-9]+(\[|;| =)} |
66 set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \**sqlite3_[_a-zA-Z0-9]+\(} | 66 set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \**sqlite3_[_a-zA-Z0-9]+\(} |
67 | 67 |
68 # Process the src/sqlite.h.in file. | 68 # Process the src/sqlite.h.in ext/rtree/sqlite3rtree.h files. |
69 # | 69 # |
70 set in [open $TOP/src/sqlite.h.in] | 70 foreach file [list $TOP/src/sqlite.h.in $TOP/ext/rtree/sqlite3rtree.h] { |
71 while {![eof $in]} { | 71 set in [open $file] |
| 72 while {![eof $in]} { |
| 73 |
| 74 set line [gets $in] |
72 | 75 |
73 set line [gets $in] | 76 # File sqlite3rtree.h contains a line "#include <sqlite3.h>". Omit this |
74 | 77 # line when copying sqlite3rtree.h into sqlite3.h. |
75 regsub -- --VERS-- $line $zVersion line | 78 # |
76 regsub -- --VERSION-NUMBER-- $line $nVersion line | 79 if {[string match {*#include*<sqlite3.h>*} $line]} continue |
77 regsub -- --SOURCE-ID-- $line "$zDate $zUuid" line | 80 |
78 | 81 regsub -- --VERS-- $line $zVersion line |
79 if {[regexp {define SQLITE_EXTERN extern} $line]} { | 82 regsub -- --VERSION-NUMBER-- $line $nVersion line |
| 83 regsub -- --SOURCE-ID-- $line "$zDate $zUuid" line |
| 84 |
| 85 if {[regexp {define SQLITE_EXTERN extern} $line]} { |
| 86 puts $line |
| 87 puts [gets $in] |
| 88 puts "" |
| 89 puts "#ifndef SQLITE_API" |
| 90 puts "# define SQLITE_API" |
| 91 puts "#endif" |
| 92 set line "" |
| 93 } |
| 94 |
| 95 if {([regexp $varpattern $line] && ![regexp {^ *typedef} $line]) |
| 96 || ([regexp $declpattern $line]) |
| 97 } { |
| 98 set line "SQLITE_API $line" |
| 99 } |
80 puts $line | 100 puts $line |
81 puts [gets $in] | |
82 puts "" | |
83 puts "#ifndef SQLITE_API" | |
84 puts "# define SQLITE_API" | |
85 puts "#endif" | |
86 set line "" | |
87 } | 101 } |
88 | 102 close $in |
89 if {([regexp $varpattern $line] && ![regexp {^ *typedef} $line]) | |
90 || ([regexp $declpattern $line]) | |
91 } { | |
92 set line "SQLITE_API $line" | |
93 } | |
94 puts $line | |
95 } | 103 } |
96 close $in | |
OLD | NEW |