drh | 2ce15c3 | 2017-07-11 13:34:40 +0000 | [diff] [blame] | 1 | #!/usr/bin/tclsh |
| 2 | # |
drh | aa62d2e | 2017-10-12 13:47:48 +0000 | [diff] [blame] | 3 | # Run this script to generate the "shell.c" source file from |
drh | 2ce15c3 | 2017-07-11 13:34:40 +0000 | [diff] [blame] | 4 | # constituent parts. |
| 5 | # |
drh | aa62d2e | 2017-10-12 13:47:48 +0000 | [diff] [blame] | 6 | # No arguments are required. This script determines the location |
| 7 | # of its input files relative to the location of the script itself. |
| 8 | # This script should be tool/mkshellc.tcl. If the directory holding |
| 9 | # the script is $DIR, then the component parts are located in $DIR/../src |
| 10 | # and $DIR/../ext/misc. |
| 11 | # |
drh | 2ce15c3 | 2017-07-11 13:34:40 +0000 | [diff] [blame] | 12 | set topdir [file dir [file dir [file normal $argv0]]] |
drh | aa62d2e | 2017-10-12 13:47:48 +0000 | [diff] [blame] | 13 | set out stdout |
drh | 2ce15c3 | 2017-07-11 13:34:40 +0000 | [diff] [blame] | 14 | puts $out {/* DO NOT EDIT! |
| 15 | ** This file is automatically generated by the script in the canonical |
| 16 | ** SQLite source tree at tool/mkshellc.tcl. That script combines source |
| 17 | ** code from various constituent source files of SQLite into this single |
| 18 | ** "shell.c" file used to implement the SQLite command-line shell. |
| 19 | ** |
| 20 | ** Most of the code found below comes from the "src/shell.c.in" file in |
| 21 | ** the canonical SQLite source tree. That main file contains "INCLUDE" |
| 22 | ** lines that specify other files in the canonical source tree that are |
| 23 | ** inserted to getnerate this complete program source file. |
| 24 | ** |
| 25 | ** The code from multiple files is combined into this single "shell.c" |
| 26 | ** source file to help make the command-line program easier to compile. |
| 27 | ** |
| 28 | ** To modify this program, get a copy of the canonical SQLite source tree, |
| 29 | ** edit the src/shell.c.in" and/or some of the other files that are included |
| 30 | ** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script. |
| 31 | */} |
| 32 | set in [open $topdir/src/shell.c.in rb] |
drh | b3c4523 | 2017-08-28 14:33:27 +0000 | [diff] [blame] | 33 | while {1} { |
drh | 2ce15c3 | 2017-07-11 13:34:40 +0000 | [diff] [blame] | 34 | set lx [gets $in] |
drh | b3c4523 | 2017-08-28 14:33:27 +0000 | [diff] [blame] | 35 | if {[eof $in]} break; |
drh | 2ce15c3 | 2017-07-11 13:34:40 +0000 | [diff] [blame] | 36 | if {[regexp {^INCLUDE } $lx]} { |
| 37 | set cfile [lindex $lx 1] |
| 38 | puts $out "/************************* Begin $cfile ******************/" |
| 39 | set in2 [open $topdir/src/$cfile rb] |
| 40 | while {![eof $in2]} { |
| 41 | set lx [gets $in2] |
| 42 | if {[regexp {^#include "sqlite} $lx]} continue |
dan | 9c1cf32 | 2017-08-30 13:21:17 +0000 | [diff] [blame] | 43 | set lx [string map [list __declspec(dllexport) {}] $lx] |
drh | 2ce15c3 | 2017-07-11 13:34:40 +0000 | [diff] [blame] | 44 | puts $out $lx |
| 45 | } |
| 46 | close $in2 |
| 47 | puts $out "/************************* End $cfile ********************/" |
| 48 | continue |
| 49 | } |
| 50 | puts $out $lx |
| 51 | } |
| 52 | close $in |
| 53 | close $out |