From 8d80ca2d1cab1f42a2430e249adcee28c19fd587 Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 23 Mar 2025 21:38:28 +0000 Subject: [PATCH] Internal configure refactoring to support an ongoing conversion of ./autoconf/tea to autosetup. FossilOrigin-Name: e1d483e342670092c3579f2f0975e49a0c74516ae34103a63b4cde156bf5e92b --- {tool => autosetup}/find_tclconfig.tcl | 0 autosetup/proj.tcl | 62 +++++++++++++++++- autosetup/sqlite-config.tcl | 91 +++++++++++++++----------- manifest | 18 ++--- manifest.uuid | 2 +- 5 files changed, 123 insertions(+), 50 deletions(-) rename {tool => autosetup}/find_tclconfig.tcl (100%) diff --git a/tool/find_tclconfig.tcl b/autosetup/find_tclconfig.tcl similarity index 100% rename from tool/find_tclconfig.tcl rename to autosetup/find_tclconfig.tcl diff --git a/autosetup/proj.tcl b/autosetup/proj.tcl index 3e703d007a..5ba71bd5cc 100644 --- a/autosetup/proj.tcl +++ b/autosetup/proj.tcl @@ -594,7 +594,7 @@ proc proj-file-content {args} { set trim 1 lassign $args - fname } - set fp [open $fname r] + set fp [open $fname rb] set rc [read $fp] close $fp if {$trim} { return [string trim $rc] } @@ -607,7 +607,7 @@ proc proj-file-content {args} { # Returns the contents of the given file as an array of lines, with # the EOL stripped from each input line. proc proj-file-content-list {fname} { - set fp [open $fname r] + set fp [open $fname rb] set rc {} while { [gets $fp line] >= 0 } { lappend rc $line @@ -616,6 +616,17 @@ proc proj-file-content-list {fname} { return $rc } +######################################################################## +# @proj-file-write fname content +# +# Works like autosetup's [writefile] but explicitly uses binary mode +# to avoid EOL translation on Windows. +proc proj-file-write {fname content} { + set f [open $fname wb] + puts -nonewline $f $content + close $f +} + ######################################################################## # @proj-check-compile-commands ?configFlag? # @@ -1377,3 +1388,50 @@ proc proj-current-proc-name {{lvl 0}} { #uplevel [expr {$lvl + 1}] {lindex [info level 0] 0} lindex [info level [expr {-$lvl - 1}]] 0 } + + +######################################################################## +# Converts parts of tclConfig.sh to autosetup [define]s. +# +# Expects to be passed the name of a value tclConfig.sh or an empty +# string. It converts certain parts of that file's contents to +# [define]s (see the code for the whole list). If $tclConfigSh is an +# empty string then it [define]s the various vars as empty strings. +proc proj-tclConfig-to-autosetup {tclConfigSh} { + set shBody {} + set tclVars { + TCL_INCLUDE_SPEC + TCL_LIB_SPEC + TCL_STUB_LIB_SPEC + TCL_EXEC_PREFIX + TCL_PREFIX + TCL_VERSION + } + lappend shBody "if test x = \"x${tclConfigSh}\"; then" + foreach v $tclVars { + lappend shBody "$v= ;" + } + lappend shBody "else . \"${tclConfigSh}\"; fi" + foreach v $tclVars { + lappend shBody "echo define $v {\$$v} ;" + } + lappend shBody "exit" + set shBody [join $shBody "\n"] + #puts "shBody=$shBody\n"; exit + if {0} { + # This doesn't work but would be preferable to using a temp file... + set fd [open "| sh" "rw"] + #puts "fd = $fd"; exit + puts $fd $shBody + flush $fd + set rd [read $fd] + close $fd + puts "rd=$rd"; exit 1 + eval $rd + } else { + set shName ".tclConfigSh.tcl" + proj-file-write $shName $shBody + eval [exec sh $shName $tclConfigSh] + file delete --force $shName + } +} diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index d1347c0fda..53a21ded9a 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -64,7 +64,7 @@ array set sqliteConfig [subst [proj-strip-hash-comments { ######################################################################## # Processes all configure --flags for this build, run build-specific # config checks, then finalize the configure process. $buildMode must -# be either "canonical" or "autoconf", and others may be added in the +# be one of (canonical, autoconf), and others may be added in the # future. After bootstrapping, $configScript is eval'd in the caller's # scope, then post-configuration finalization is run. $configScript is # intended to hold configure code which is specific to the given @@ -83,7 +83,7 @@ array set sqliteConfig [subst [proj-strip-hash-comments { proc sqlite-configure {buildMode configScript} { proj-assert {$::sqliteConfig(build-mode) eq "unknown"} \ "sqlite-configure must not be called more than once" - set allBuildModes {canonical autoconf} + set allBuildModes {canonical autoconf tcl-extension} if {$buildMode ni $allBuildModes} { user-error "Invalid build mode: $buildMode. Expecting one of: $allBuildModes" } @@ -165,7 +165,7 @@ proc sqlite-configure {buildMode configScript} { # Options for how to build the library build-modes { - {*} { + {canonical autoconf} { shared=1 => {Disable build of shared library} static=1 => {Disable build of static library} } @@ -203,6 +203,13 @@ proc sqlite-configure {buildMode configScript} { # Options for TCL support tcl { {canonical} { + tcl=1 + => {Disable components which require TCL, including all tests. + This tree requires TCL for code generation but can use the in-tree + copy of autosetup/jimsh0.c for that. The SQLite TCL extension and the + test code require a canonical tclsh.} + } + {canonical tcl-extension} { with-tcl:DIR => {Directory containing tclConfig.sh or a directory one level up from that, from which we can derive a directory containing tclConfig.sh. @@ -213,17 +220,12 @@ proc sqlite-configure {buildMode configScript} { tclConfig.sh and (B) all TCL-based code generation. Warning: if its containing dir has multiple tclsh versions, it may select the wrong tclConfig.sh!} - tcl=1 - => {Disable components which require TCL, including all tests. - This tree requires TCL for code generation but can use the in-tree - copy of autosetup/jimsh0.c for that. The SQLite TCL extension and the - test code require a canonical tclsh.} } } # Options for line-editing modes for the CLI shell line-editing { - {*} { + {canonical autoconf} { readline=1 => {Disable readline support} # --with-readline-lib is a backwards-compatible alias for @@ -265,12 +267,12 @@ proc sqlite-configure {buildMode configScript} { # Options for exotic/alternative build modes alternative-builds { - {*} { + {canonical autoconf} { with-wasi-sdk:=/opt/wasi-sdk => {Top-most dir of the wasi-sdk for a WASI build} } - {canonical} { + {canonical} { with-emsdk:=auto => {Top-most dir of the Emscripten SDK installation. Needed only by ext/wasm. Default=EMSDK env var.} @@ -288,7 +290,7 @@ proc sqlite-configure {buildMode configScript} { static-shell=1 => {Link the sqlite3 shell app against the DLL instead of embedding sqlite3.c} } - {*} { + {canonical autoconf} { # A potential TODO without a current use case: #rpath=1 => {Disable use of the rpath linker flag} # soname: https://sqlite.org/src/forumpost/5a3b44f510df8ded @@ -458,17 +460,21 @@ proc sqlite-configure-finalize {} { sqlite-handle-load-extension sqlite-handle-math sqlite-handle-icu - sqlite-handle-line-editing - - proj-define-for-opt shared ENABLE_LIB_SHARED "Build shared library?" - if {![proj-define-for-opt static ENABLE_LIB_STATIC "Build static library?"]} { - # This notice really only applies to the canonical build... - proj-indented-notice { - NOTICE: static lib build may be implicitly re-activated by - other components, e.g. some test apps. + if {[proj-opt-exists readline]} { + sqlite-handle-line-editing + } + if {[proj-opt-exists shared]} { + proj-define-for-opt shared ENABLE_LIB_SHARED "Build shared library?" + } + if {[proj-opt-exists static]} { + if {![proj-define-for-opt static ENABLE_LIB_STATIC "Build static library?"]} { + # This notice really only applies to the canonical build... + proj-indented-notice { + NOTICE: static lib build may be implicitly re-activated by + other components, e.g. some test apps. + } } } - sqlite-handle-env-quirks sqlite-handle-common-feature-flags sqlite-finalize-feature-flags @@ -1225,9 +1231,10 @@ proc sqlite-check-line-editing {} { }; # sqlite-check-line-editing ######################################################################## -# Runs sqlite-check-line-editing and adds a message around it In the +# Runs sqlite-check-line-editing and adds a message around it. In the # canonical build this must not be called before -# sqlite-determine-codegen-tcl. +# sqlite-determine-codegen-tcl for reasons now lost to history (and +# might not still be applicable). proc sqlite-handle-line-editing {} { msg-result "Line-editing support for the sqlite3 shell: [sqlite-check-line-editing]" } @@ -1625,7 +1632,15 @@ proc sqlite-process-dot-in-files {} { # (e.g. [proj-check-rpath]) may do so before we "mangle" them here. proj-remap-autoconf-dir-vars - proj-make-from-dot-in -touch Makefile sqlite3.pc + set srcdir $::autosetup(srcdir)/ + foreach f {Makefile sqlite3.pc} { + if {[file exists $srcdir/$f.in]} { + # ^^^ we do this only so that this block can be made to work for + # multiple builds. e.g. the tea build (under construction) does + # not hae sqlite3.pc.in. + proj-make-from-dot-in -touch $f + } + } make-config-header sqlite_cfg.h \ -bare {SIZEOF_* HAVE_DECL_*} \ -none {HAVE_CFLAG_* LDFLAGS_* SH_* SQLITE_AUTORECONFIG @@ -1695,7 +1710,7 @@ proc sqlite-handle-wasi-sdk {} { threadsafe } { if {[proj-opt-exists $opt] && [opt-bool $opt]} { - # -^^^^ distinguish between canonical and autoconf builds + # -^^^^ not all builds define all of these flags msg-result " --disable-$opt" proj-opt-set $opt 0 } @@ -1772,12 +1787,10 @@ proc sqlite-check-tcl {} { define TCLLIBDIR "" ; # Installation dir for TCL extension lib define TCL_CONFIG_SH ""; # full path to tclConfig.sh - # Clear out all vars which would be set by tclConfigToAutoDef.sh, so + # Clear out all vars which would be set by tclConfigShToAutoDef.sh, so # that the late-config validation of @VARS@ works even if # --disable-tcl is used. - foreach k {TCL_INCLUDE_SPEC TCL_LIB_SPEC TCL_STUB_LIB_SPEC TCL_EXEC_PREFIX TCL_VERSION} { - define $k "" - } + proj-tclConfig-to-autosetup "" file delete -force ".tclenv.sh"; # ensure no stale state from previous configures. if {![opt-bool tcl]} { @@ -1804,7 +1817,7 @@ proc sqlite-check-tcl {} { if {"" eq $with_tclsh && "" eq $with_tcl} { # If neither --with-tclsh nor --with-tcl are provided, try to find # a workable tclsh. - set with_tclsh [proj-first-bin-of tclsh9.0 tclsh8.6 tclsh] + set with_tclsh [proj-first-bin-of tclsh9.1 tclsh9.0 tclsh8.6 tclsh] proc-debug "with_tclsh=${with_tclsh}" } @@ -1819,7 +1832,7 @@ proc sqlite-check-tcl {} { #msg-result "Using tclsh: $with_tclsh" } if {$doConfigLookup && - [catch {exec $with_tclsh $srcdir/tool/find_tclconfig.tcl} result] == 0} { + [catch {exec $with_tclsh $::autosetup(libdir)/find_tclconfig.tcl} result] == 0} { set with_tcl $result } if {"" ne $with_tcl && [file isdir $with_tcl]} { @@ -1830,7 +1843,7 @@ proc sqlite-check-tcl {} { } } set cfg "" - set tclSubdirs {tcl9.0 tcl8.6 lib} + set tclSubdirs {tcl9.1 tcl9.0 tcl8.6 lib} while {$use_tcl} { if {"" ne $with_tcl} { # Ensure that we can find tclConfig.sh under ${with_tcl}/... @@ -1876,9 +1889,7 @@ proc sqlite-check-tcl {} { # Export a subset of tclConfig.sh to the current TCL-space. If $cfg # is an empty string, this emits empty-string entries for the # various options we're interested in. - eval [exec sh "$srcdir/tool/tclConfigShToAutoDef.sh" "$cfg"] - # ---------^^ a Windows/msys workaround, without which it cannot - # exec a .sh file: https://sqlite.org/forum/forumpost/befb352a42a7cd6d + proj-tclConfig-to-autosetup $cfg if {"" eq $with_tclsh && $cfg ne ""} { # We have tclConfig.sh but no tclsh. Attempt to locate a tclsh @@ -2047,10 +2058,14 @@ proc sqlite-determine-codegen-tcl {} { }; # sqlite-determine-codegen-tcl ######################################################################## -# Runs sqlite-check-tcl and sqlite-determine-codegen-tcl. -proc sqlite-handle-tcl {} { +# Runs sqlite-check-tcl and, if $alsoCheckCodeGen is true, +# sqlite-determine-codegen-tcl (intended only for the canonical +# build). +proc sqlite-handle-tcl {{alsoCheckCodeGen 1}} { sqlite-check-tcl - msg-result "TCL for code generation: [sqlite-determine-codegen-tcl]" + if {$alsoCheckCodeGen} { + msg-result "TCL for code generation: [sqlite-determine-codegen-tcl]" + } } ######################################################################## diff --git a/manifest b/manifest index 088f57eec8..7a2d34a15e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sgenerate_series()\senhancement\sfrom\scheck-in\s[d50b784807333c54]\nso\sthat\sit\sworks\seven\sif\sthe\snumber\sthat\s"value"\sis\sbeing\scompared\sagainst\nis\sa\snon-integer\sfloating\spoint\snumber.\s\sBug\sreported\sby\n[forum:/forumpost/0d5d63257e3ff4f6|forum\spost\s0d5d63257]. -D 2025-03-22T22:55:33.194 +C Internal\sconfigure\srefactoring\sto\ssupport\san\songoing\sconversion\sof\s./autoconf/tea\sto\sautosetup. +D 2025-03-23T21:38:28.791 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -47,10 +47,11 @@ F autosetup/cc-db.tcl 6e0ed90146197a5a05b245e649975c07c548e30926b218ca3e1d4dc034 F autosetup/cc-lib.tcl 493c5935b5dd3bf9bd4eca89b07c8b1b1a9356d61783035144e21795facf7360 F autosetup/cc-shared.tcl 4f024e94a47f427ba61de1739f6381ef0080210f9fae89112d5c1de1e5460d78 F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e45f +F autosetup/find_tclconfig.tcl e64886ffe3b982d4df42cd28ed91fe0b5940c2c5785e126c1821baf61bc86a7e w tool/find_tclconfig.tcl F autosetup/jimsh0.c a57c16e65dcffc9c76e496757cb3f7fb47e01ecbd1631a0a5e01751fc856f049 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba -F autosetup/proj.tcl 49faf960df88a374686234105def663dbfc297ab79c87686df0a0b973dd77018 -F autosetup/sqlite-config.tcl a2a786ccdccead789c8e4cc82408257bf7857dcbdf45accab4a1538d641d3070 +F autosetup/proj.tcl 18ab0775dab8864d9f38ad0becb5d2a13b0c3986ecf4f9661de490341085e7b9 +F autosetup/sqlite-config.tcl 45182c777228e92f66357b63b686a80fcedd114e77a86f562e6b27c981454e95 F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl eb4c6578e08dd353263958da0dc620f8400b869a50d06e271ab0be85a51a08d3 @@ -2135,7 +2136,6 @@ F tool/enlargedb.c 3e8b2612b985cfa7e3e8800031ee191b43ae80de96abb5abbd5eada62651e F tool/extract-sqlite3h.tcl 069ceab0cee26cba99952bfa08c0b23e35941c837acabe143f0c355d96c9e2eb x F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c c129ae2924a48310c7b766810391da9e8fda532b9f6bd3f9a9e3a799a1b42af9 -F tool/find_tclconfig.tcl e64886ffe3b982d4df42cd28ed91fe0b5940c2c5785e126c1821baf61bc86a7e F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 F tool/fuzzershell.c 41480c8a1e4749351f381431ecfdfceba645396c5d836f8d26b51a33c4a21b33 F tool/genfkey.README e550911fa984c8255ebed2ef97824125d83806eb5232582700de949edf836eb1 @@ -2216,8 +2216,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f3c0071284fbe1c0a8c3fe73792a79f9df6be983e5c9bd1a7e2fe71ba7b2d400 -R bb2b8fb97c5254c022b045f9e204d5a8 -U drh -Z 3b840e739e362fa32d6af0f736408d3e +P c113e31b818d16770bec1edc980f6833dfb27c4d74178e66a778fbb5671c3a13 +R 309a2c3afab1d662c70990a09672e776 +U stephan +Z fb7c999d8dfb13e08fe006e0a7885fc0 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c29e8e308c..9a5c1cf815 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c113e31b818d16770bec1edc980f6833dfb27c4d74178e66a778fbb5671c3a13 +e1d483e342670092c3579f2f0975e49a0c74516ae34103a63b4cde156bf5e92b -- 2.47.2