2017-07-11 15:34:40 +02:00
|
|
|
#!/usr/bin/tclsh
|
|
|
|
#
|
2017-10-12 15:47:48 +02:00
|
|
|
# Run this script to generate the "shell.c" source file from
|
2017-07-11 15:34:40 +02:00
|
|
|
# constituent parts.
|
|
|
|
#
|
2017-10-12 15:47:48 +02:00
|
|
|
# No arguments are required. This script determines the location
|
|
|
|
# of its input files relative to the location of the script itself.
|
|
|
|
# This script should be tool/mkshellc.tcl. If the directory holding
|
|
|
|
# the script is $DIR, then the component parts are located in $DIR/../src
|
|
|
|
# and $DIR/../ext/misc.
|
|
|
|
#
|
2017-07-11 15:34:40 +02:00
|
|
|
set topdir [file dir [file dir [file normal $argv0]]]
|
2017-10-12 15:47:48 +02:00
|
|
|
set out stdout
|
2021-06-16 17:56:09 +02:00
|
|
|
fconfigure stdout -translation binary
|
2017-07-11 15:34:40 +02:00
|
|
|
puts $out {/* DO NOT EDIT!
|
|
|
|
** This file is automatically generated by the script in the canonical
|
|
|
|
** SQLite source tree at tool/mkshellc.tcl. That script combines source
|
|
|
|
** code from various constituent source files of SQLite into this single
|
|
|
|
** "shell.c" file used to implement the SQLite command-line shell.
|
|
|
|
**
|
|
|
|
** Most of the code found below comes from the "src/shell.c.in" file in
|
|
|
|
** the canonical SQLite source tree. That main file contains "INCLUDE"
|
|
|
|
** lines that specify other files in the canonical source tree that are
|
|
|
|
** inserted to getnerate this complete program source file.
|
|
|
|
**
|
|
|
|
** The code from multiple files is combined into this single "shell.c"
|
|
|
|
** source file to help make the command-line program easier to compile.
|
|
|
|
**
|
|
|
|
** To modify this program, get a copy of the canonical SQLite source tree,
|
|
|
|
** edit the src/shell.c.in" and/or some of the other files that are included
|
|
|
|
** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script.
|
|
|
|
*/}
|
2021-07-29 18:49:28 +02:00
|
|
|
set in [open $topdir/src/shell.c.in]
|
|
|
|
fconfigure $in -translation binary
|
2018-01-05 21:30:54 +01:00
|
|
|
proc omit_redundant_typedefs {line} {
|
|
|
|
global typedef_seen
|
2022-11-07 19:36:02 +01:00
|
|
|
if {[regexp {^typedef .*\y([a-zA-Z0-9_]+);} $line all typename]} {
|
|
|
|
if {[info exists typedef_seen($typename)]} {
|
2022-11-07 20:40:20 +01:00
|
|
|
return "/* [string map {/* // */ //} $line] */"
|
2018-01-05 21:30:54 +01:00
|
|
|
}
|
2022-11-07 19:36:02 +01:00
|
|
|
set typedef_seen($typename) 1
|
2018-01-05 21:30:54 +01:00
|
|
|
}
|
|
|
|
return $line
|
|
|
|
}
|
2019-04-20 22:57:28 +02:00
|
|
|
set iLine 0
|
2017-08-28 16:33:27 +02:00
|
|
|
while {1} {
|
2018-01-05 21:30:54 +01:00
|
|
|
set lx [omit_redundant_typedefs [gets $in]]
|
2017-08-28 16:33:27 +02:00
|
|
|
if {[eof $in]} break;
|
2019-04-20 22:57:28 +02:00
|
|
|
incr iLine
|
2017-07-11 15:34:40 +02:00
|
|
|
if {[regexp {^INCLUDE } $lx]} {
|
|
|
|
set cfile [lindex $lx 1]
|
|
|
|
puts $out "/************************* Begin $cfile ******************/"
|
2019-04-27 22:30:19 +02:00
|
|
|
# puts $out "#line 1 \"$cfile\""
|
2021-07-29 18:49:28 +02:00
|
|
|
set in2 [open $topdir/src/$cfile]
|
|
|
|
fconfigure $in2 -translation binary
|
2017-07-11 15:34:40 +02:00
|
|
|
while {![eof $in2]} {
|
2018-01-05 21:30:54 +01:00
|
|
|
set lx [omit_redundant_typedefs [gets $in2]]
|
2022-12-23 20:04:59 +01:00
|
|
|
if {[regexp {^# *include "sqlite} $lx]} {
|
2019-04-20 22:57:28 +02:00
|
|
|
set lx "/* $lx */"
|
|
|
|
}
|
2018-01-07 22:58:17 +01:00
|
|
|
if {[regexp {^# *include "test_windirent.h"} $lx]} {
|
|
|
|
set lx "/* $lx */"
|
|
|
|
}
|
2017-08-30 15:21:17 +02:00
|
|
|
set lx [string map [list __declspec(dllexport) {}] $lx]
|
2017-07-11 15:34:40 +02:00
|
|
|
puts $out $lx
|
|
|
|
}
|
|
|
|
close $in2
|
|
|
|
puts $out "/************************* End $cfile ********************/"
|
2019-04-27 22:30:19 +02:00
|
|
|
# puts $out "#line [expr $iLine+1] \"shell.c.in\""
|
2017-07-11 15:34:40 +02:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
puts $out $lx
|
|
|
|
}
|
|
|
|
close $in
|
|
|
|
close $out
|