Get #line tags into amalgamation, subject to configure.

FossilOrigin-Name: 5d81b598a7cd2cea2553fdf6ca38d2f65f0f1b2d5a8eea8a01c1800f68aa2422
This commit is contained in:
larrybr
2021-07-13 11:59:17 +00:00
5 changed files with 74 additions and 52 deletions
+2 -1
View File
@@ -165,6 +165,7 @@ LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
###############################################################################
USE_AMALGAMATION = @USE_AMALGAMATION@
AMALGAMATION_LINE_TAGS = @AMALGAMATION_LINE_TAGS@
# Object files for the SQLite library (non-amalgamation).
#
@@ -756,7 +757,7 @@ mptest: mptester$(TEXE)
touch .target_source
sqlite3.c: .target_source $(TOP)/tool/mksqlite3c.tcl
$(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl
$(TCLSH_CMD) $(TOP)/tool/mksqlite3c.tcl $(AMALGAMATION_LINE_TAGS)
cp tsrc/sqlite3ext.h .
cp $(TOP)/ext/session/sqlite3session.h .
Vendored
+22
View File
@@ -774,6 +774,7 @@ USE_GCOV
OPT_FEATURE_FLAGS
HAVE_ZLIB
USE_AMALGAMATION
AMALGAMATION_LINE_TAGS
TARGET_DEBUG
TARGET_HAVE_EDITLINE
TARGET_HAVE_READLINE
@@ -902,6 +903,7 @@ with_readline_lib
with_readline_inc
enable_debug
enable_amalgamation
amalgamation_line_tags
enable_load_extension
enable_math
enable_all
@@ -10305,6 +10307,13 @@ done
#
USE_AMALGAMATION=1
#########
# By default, amalgamation sqlite3.c will have #line directives.
# This is a build option not shown by ./configure --help
# To control it, use configure option: amalgamation_line_tags=?
# where ? is no to suppress #line directives or yes to create them.
AMALGAMATION_LINE_TAGS=--line_tags=1
#########
# See whether we can run specific tclsh versions known to work well;
# if not, then we fall back to plain tclsh.
@@ -11275,6 +11284,19 @@ if test "${enable_amalgamation}" = "no" ; then
USE_AMALGAMATION=0
fi
########
# See whether --disable
if test "${amalgamation_line_tags+set}" = set; then :
enableval=$amalgamation_line_tags;
fi
if test "${amalgamation_line_tags}" = "yes" ; then
AMALGAMATION_LINE_TAGS=--line_tags=1
fi
if test "${amalgamation_line_tags}" = "no" ; then
AMALGAMATION_LINE_TAGS=--line_tags=0
fi
#########
# Look for zlib. Only needed by extensions and by the sqlite3.exe shell
+9 -9
View File
@@ -1,9 +1,9 @@
C Do\snot\sattempt\sto\srun\sTcl\ssessions\stests\sunless\sboth\sSQLITE_ENABLE_PREUPDATE_HOOK\sand\sSQLITE_ENABLE_SESSIONS\sare\sdefined.
D 2021-07-13T11:30:46.013
C Get\s#line\stags\sinto\samalgamation,\ssubject\sto\sconfigure.
D 2021-07-13T11:59:17.680
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F Makefile.in ff5ac24ec9cb700135ee4453fa14c18ea371e94250d3673bda1f2cb56e1108ce
F Makefile.in 31b3f386d47577c610dedf116aa5deab039c749d36b7735e9bc01a6f31c90f2b
F Makefile.linux-gcc f609543700659711fbd230eced1f01353117621dccae7b9fb70daa64236c5241
F Makefile.msc 8285e1ea7264f32b08702866d69dd127c0f663bbc2002323d853c68c27c6b6e4
F README.md 27fb76aa7eb57ed63a53bbba7292b6bf71f51125554f79f16b5d040edd1e6110
@@ -34,7 +34,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63
F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6
F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc
F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559
F configure 9712ea724ff2a1d48fadcf04b29fa1852f325792462c55f4fc71ab972653b20d x
F configure 6d4409696c9f91a4a9108123ea52b97d8f2b4f056565e0a4ab62f899944f3acb x
F configure.ac 4e4b58b32f88c8da9914a2f2c3158f80e69907eccc019fcc7e3ba14ffd91c640
F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad
F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd
@@ -1858,7 +1858,7 @@ F tool/mkshellc.tcl 5fe7e518112b262e25726f248c0f33dd153192867453984b6af0a76a88e9
F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f
F tool/mksqlite3c.tcl b4a930a4c3f8f43273cde45a459eb8881479be3c2845526c92b2513a4995aab8
F tool/mksqlite3c.tcl e5d1c5b61f530e9307f7dc9c2880ebe5d0578cb3817d8223933f24ca8a74cc2d
F tool/mksqlite3h.tcl 1f5e4a1dbbbc43c83cc6e74fe32c6c620502240b66c7c0f33a51378e78fc4edf
F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5
@@ -1920,7 +1920,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 7cb09aef49c0b98c0c5e332d953a2eeb71ae9e243b1e37ab1c8ed4af15d46f50
R ffe5fcedbe611fc5d143174623ac9c96
U dan
Z 4dfdb08b45660ff4713e22026b265656
P 385db794477e046b5dde726489375786d7565b113084f6e730efb050b08f9a6e 9327f73c1b87fb9ca78e261d16b092763f497bb9c6f9784a33eabdc961b06343
R dbca2ff374fa12dc1b7d55e8c48721d1
U larrybr
Z 63da48257739363f6cf3cff556a25d79
+1 -1
View File
@@ -1 +1 @@
385db794477e046b5dde726489375786d7565b113084f6e730efb050b08f9a6e
5d81b598a7cd2cea2553fdf6ca38d2f65f0f1b2d5a8eea8a01c1800f68aa2422
+40 -41
View File
@@ -17,31 +17,53 @@
# After the "tsrc" directory has been created and populated, run
# this script:
#
# tclsh mksqlite3c.tcl --srcdir $SRC
# tclsh mksqlite3c.tcl
#
# The amalgamated SQLite code will be written into sqlite3.c
#
set help {Usage: tclsh mksqlite3c.tcl <options>
where <options> is zero or more of the following with these effects:
--nostatic => Do not generate with compile-time modifiable linkage.
--line_tags=? => Emit #line directives into output or not. (? = 1 or 0)
--useapicall => Prepend functions with SQLITE_APICALL or SQLITE_CDECL.
--srcdir $SRC => Specify the directory containing constituent sources.
--help => See this.
The value setting options default to --line_tags=1 and '--srcdir tsrc' .
}
# Begin by reading the "sqlite3.h" header file. Extract the version number
# from in this file. The version number is needed to generate the header
# comment of the amalgamation.
#
set addstatic 1
set linemacros 0
set line_tags 1
set useapicall 0
set srcdir tsrc
for {set i 0} {$i<[llength $argv]} {incr i} {
set x [lindex $argv $i]
if {[regexp {^-+nostatic$} $x]} {
if {[regexp {^-?-nostatic$} $x]} {
set addstatic 0
} elseif {[regexp {^-+linemacros} $x]} {
set linemacros 1
} elseif {[regexp {^-+useapicall} $x]} {
} elseif {[regexp {^-?-line_tags=([01])$} $x ma ulm]} {
set line_tags $ulm
} elseif {[regexp {^-?-useapicall$} $x]} {
set useapicall 1
} elseif {[regexp {^-?-srcdir$} $x]} {
incr i
if {$i==[llength $argv]} {
error "No argument following $x"
}
set srcdir [lindex $argv $i]
} elseif {[regexp {^-?-((help)|\?)$} $x]} {
puts $help
exit 0
} else {
error "unknown command-line option: $x"
}
}
set in [open tsrc/sqlite3.h]
set in [open $srcdir/sqlite3.h]
set cnt 0
set VERSION ?????
while {![eof $in]} {
@@ -94,7 +116,7 @@ if {$addstatic} {
#
# then set the SQLITE_UDL_CAPABLE_PARSER flag in the amalgamation.
#
set in [open tsrc/parse.c]
set in [open $srcdir/parse.c]
if {[regexp {ifndef SQLITE_ENABLE_UPDATE_DELETE_LIMIT} [read $in]]} {
puts $out "#define SQLITE_UDL_CAPABLE_PARSER 1"
}
@@ -182,11 +204,11 @@ proc section_comment {text} {
#
proc copy_file {filename} {
global seen_hdr available_hdr varonly_hdr cdecllist out
global addstatic linemacros useapicall
global addstatic line_tags useapicall srcdir
set ln 0
set tail [file tail $filename]
section_comment "Begin file $tail"
if {$linemacros} {puts $out "#line 1 \"$filename\""}
if {$line_tags} {puts $out "#line 1 \"$filename\""}
set in [open $filename r]
set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)}
set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)}
@@ -204,9 +226,9 @@ proc copy_file {filename} {
set available_hdr($hdr) 0
}
section_comment "Include $hdr in the middle of $tail"
copy_file tsrc/$hdr
copy_file $srcdir/$hdr
section_comment "Continuing where we left off in $tail"
if {$linemacros} {puts $out "#line [expr {$ln+1}] \"$filename\""}
if {$line_tags} {puts $out "#line [expr {$ln+1}] \"$filename\""}
} else {
# Comment out the entire line, replacing any nested comment
# begin/end markers with the harmless substring "**".
@@ -228,7 +250,7 @@ proc copy_file {filename} {
}
} elseif {[regexp {^#ifdef __cplusplus} $line]} {
puts $out "#if 0"
} elseif {!$linemacros && [regexp {^#line} $line]} {
} elseif {!$line_tags && [regexp {^#line} $line]} {
# Skip #line directives.
} elseif {$addstatic
&& ![regexp {^(static|typedef|SQLITE_PRIVATE)} $line]} {
@@ -255,7 +277,7 @@ proc copy_file {filename} {
}
}
append line $funcname $rest
if {$funcname=="sqlite3_sourceid" && !$linemacros} {
if {$funcname=="sqlite3_sourceid"} {
# The sqlite3_sourceid() routine is synthesized at the end of
# the amalgamation
puts $out "/* $line */"
@@ -417,36 +439,13 @@ foreach file {
fts5.c
stmt.c
} {
copy_file tsrc/$file
copy_file $srcdir/$file
}
# Synthesize an alternative sqlite3_sourceid() implementation that
# that tries to detects changes in the amalgamation source text
# and modify returns a modified source-id if changes are detected.
#
# The only detection mechanism we have is the __LINE__ macro. So only
# edits that changes the number of lines of source code are detected.
#
if {!$linemacros} {
flush $out
set in2 [open sqlite3.c]
set cnt 0
set oldsrcid {}
while {![eof $in2]} {
incr cnt
gets $in2 line
if {[regexp {^#define SQLITE_SOURCE_ID } $line]} {set oldsrcid $line}
}
close $in2
regsub {[0-9a-flt]{4}"} $oldsrcid {alt2"} oldsrcid
puts $out \
"#if __LINE__!=[expr {$cnt+0}]
#undef SQLITE_SOURCE_ID
$oldsrcid
#endif
/* Return the source-id for this library */
puts $out \
"/* Return the source-id for this library */
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }"
}
puts $out \
"/************************** End of sqlite3.c ******************************/"