| 1 |
#!/bin/sh |
| 2 |
# restart with tclsh \ |
| 3 |
exec tclsh "$0" "$@" |
| 4 |
|
| 5 |
set srcdir [file dirname [file dirname [info script]]] |
| 6 |
set G(src) [string map [list %dir% $srcdir] { |
| 7 |
%dir%/lsm.h |
| 8 |
%dir%/lsmInt.h |
| 9 |
%dir%/lsm_vtab.c |
| 10 |
%dir%/lsm_ckpt.c |
| 11 |
%dir%/lsm_file.c |
| 12 |
%dir%/lsm_log.c |
| 13 |
%dir%/lsm_main.c |
| 14 |
%dir%/lsm_mem.c |
| 15 |
%dir%/lsm_mutex.c |
| 16 |
%dir%/lsm_shared.c |
| 17 |
%dir%/lsm_sorted.c |
| 18 |
%dir%/lsm_str.c |
| 19 |
%dir%/lsm_tree.c |
| 20 |
%dir%/lsm_unix.c |
| 21 |
%dir%/lsm_varint.c |
| 22 |
%dir%/lsm_win32.c |
| 23 |
}] |
| 24 |
|
| 25 |
set G(hdr) { |
| 26 |
|
| 27 |
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_LSM1) |
| 28 |
|
| 29 |
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) |
| 30 |
# define NDEBUG 1 |
| 31 |
#endif |
| 32 |
#if defined(NDEBUG) && defined(SQLITE_DEBUG) |
| 33 |
# undef NDEBUG |
| 34 |
#endif |
| 35 |
|
| 36 |
} |
| 37 |
|
| 38 |
set G(footer) { |
| 39 |
|
| 40 |
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_LSM1) */ |
| 41 |
} |
| 42 |
|
| 43 |
#------------------------------------------------------------------------- |
| 44 |
# Read and return the entire contents of text file $zFile from disk. |
| 45 |
# |
| 46 |
proc readfile {zFile} { |
| 47 |
set fd [open $zFile] |
| 48 |
set data [read $fd] |
| 49 |
close $fd |
| 50 |
return $data |
| 51 |
} |
| 52 |
|
| 53 |
proc lsm1c_init {zOut} { |
| 54 |
global G |
| 55 |
set G(fd) stdout |
| 56 |
set G(fd) [open $zOut w] |
| 57 |
|
| 58 |
puts -nonewline $G(fd) $G(hdr) |
| 59 |
} |
| 60 |
|
| 61 |
proc lsm1c_printfile {zIn} { |
| 62 |
global G |
| 63 |
set data [readfile $zIn] |
| 64 |
set zTail [file tail $zIn] |
| 65 |
puts $G(fd) "#line 1 \"$zTail\"" |
| 66 |
|
| 67 |
foreach line [split $data "\n"] { |
| 68 |
if {[regexp {^# *include.*lsm} $line]} { |
| 69 |
set line "/* $line */" |
| 70 |
} elseif { [regexp {^(const )?[a-zA-Z][a-zA-Z0-9]* [*]?lsm[^_]} $line] } { |
| 71 |
set line "static $line" |
| 72 |
} |
| 73 |
puts $G(fd) $line |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
proc lsm1c_close {} { |
| 78 |
global G |
| 79 |
puts -nonewline $G(fd) $G(footer) |
| 80 |
if {$G(fd)!="stdout"} { |
| 81 |
close $G(fd) |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
lsm1c_init lsm1.c |
| 87 |
foreach f $G(src) { lsm1c_printfile $f } |
| 88 |
lsm1c_close |