1#!/usr/bin/tclsh 2# 3# Run this script to generate the "src/shell.c" source file from 4# constituent parts. 5# 6set topdir [file dir [file dir [file normal $argv0]]] 7puts "Overwriting $topdir/src/shell.c with new shell source code..." 8set out [open $topdir/src/shell.c wb] 9puts $out {/* DO NOT EDIT! 10** This file is automatically generated by the script in the canonical 11** SQLite source tree at tool/mkshellc.tcl. That script combines source 12** code from various constituent source files of SQLite into this single 13** "shell.c" file used to implement the SQLite command-line shell. 14** 15** Most of the code found below comes from the "src/shell.c.in" file in 16** the canonical SQLite source tree. That main file contains "INCLUDE" 17** lines that specify other files in the canonical source tree that are 18** inserted to getnerate this complete program source file. 19** 20** The code from multiple files is combined into this single "shell.c" 21** source file to help make the command-line program easier to compile. 22** 23** To modify this program, get a copy of the canonical SQLite source tree, 24** edit the src/shell.c.in" and/or some of the other files that are included 25** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script. 26*/} 27set in [open $topdir/src/shell.c.in rb] 28while {![eof $in]} { 29 set lx [gets $in] 30 if {[regexp {^INCLUDE } $lx]} { 31 set cfile [lindex $lx 1] 32 puts $out "/************************* Begin $cfile ******************/" 33 set in2 [open $topdir/src/$cfile rb] 34 while {![eof $in2]} { 35 set lx [gets $in2] 36 if {[regexp {^#include "sqlite} $lx]} continue 37 puts $out $lx 38 } 39 close $in2 40 puts $out "/************************* End $cfile ********************/" 41 continue 42 } 43 puts $out $lx 44} 45close $in 46close $out 47