From: stephan Date: Sat, 5 Apr 2025 02:59:37 +0000 (+0000) Subject: Refactor proj-make-from-dot-in and friends to be more useful and remove some annoying... X-Git-Tag: major-release~122 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7cf1b290652ff8cfc1c6bac052c6ed9c74017777;p=thirdparty%2Fsqlite.git Refactor proj-make-from-dot-in and friends to be more useful and remove some annoying limitations. FossilOrigin-Name: 501ff84e1263e2b026b0ca5f043bcc912ea935229b625b113b7402955df20dd3 --- diff --git a/autosetup/proj.tcl b/autosetup/proj.tcl index 4f6a602863..55ea3c4373 100644 --- a/autosetup/proj.tcl +++ b/autosetup/proj.tcl @@ -54,6 +54,16 @@ # $proj_ is an internal-use-only array for storing whatever generic # internal stuff we need stored. array set proj_ {} +# +# List of dot-in files to filter in the final stages of +# configuration. Some configuration steps may append to this. Each +# one in this list which exists will trigger the generation of a +# file with that same name, minus the ".in", in the build directory +# (which differ from the source dir in out-of-tree builds). +# +# See: proj-dot-ins-append and proj-dot-ins-process +# +set proj_(dot-in-files) {} set proj_(isatty) [isatty? stdout] ######################################################################## @@ -71,7 +81,7 @@ proc proj-warn {msg} { # Emits an error message to stderr and exits with non-0. proc proj-fatal {msg} { show-notices - puts stderr "ERROR: $msg" + puts stderr "ERROR: \[[proj-current-proc-name 1]]: $msg" exit 1 } @@ -670,11 +680,18 @@ proc proj-touch {filename} { } ######################################################################## -# @proj-make-from-dot-in ?-touch? filename... +# @proj-make-from-dot-in ?-touch? infile ?outfile? +# +# Uses [make-template] to create makefile(-like) file(s) $outfile from +# $infile but explicitly makes the output read-only, to avoid +# inadvertent editing (who, me?). +# +# If $outfile is empty then: +# +# - If $infile is a 2-element list, it is assumed to be an in/out pair, +# and $outfile is set from the 2nd entry in that list. Else... # -# Uses [make-template] to create makefile(-like) file(s) $filename -# from $filename.in but explicitly makes the output read-only, to -# avoid inadvertent editing (who, me?). +# - $outfile is set to $infile stripped of its extension. # # If the first argument is -touch then the generated file is touched # to update its timestamp. This can be used as a workaround for @@ -684,26 +701,35 @@ proc proj-touch {filename} { # # Failures when running chmod or touch are silently ignored. proc proj-make-from-dot-in {args} { - set filename $args + set fIn "" + set fOut "" set touch 0 if {[lindex $args 0] eq "-touch"} { set touch 1 - set filename [lrange $args 1 end] + lassign $args - fIn fOut + } else { + lassign $args fIn fOut } - foreach f $filename { - set f [string trim $f] - if {[file exists $f]} { - catch { exec chmod u+w $f } - } - make-template $f.in $f - if {$touch} { - proj-touch $f - } - catch { - exec chmod -w $f - #file attributes -w $f; #jimtcl has no 'attributes' + if {"" eq $fOut} { + if {2==[llength $fIn]} { + lassign $fIn fIn fOut + } else { + set fOut [file rootname $fIn] } } + #puts "filenames=$filename" + if {[file exists $fOut]} { + catch { exec chmod u+w $fOut } + } + #puts "making template: $fIn ==> $fOut" + make-template $fIn $fOut + if {$touch} { + proj-touch $fOut + } + catch { + exec chmod -w $fOut + #file attributes -w $f; #jimtcl has no 'attributes' + } } ######################################################################## @@ -1476,3 +1502,78 @@ proc proj-tweak-default-env-dirs {} { } return 0 } + +######################################################################## +# @proj-dot-ins-append {file ?fileOut?}... +# +# Queues up an autosetup [make-template]-style file to be processed +# at a later time using [proj-dot-ins-process]. +# +# $file is the input file. If $fileOut is empty then this function +# derives $fileOut from $file, stripping both its directory and +# extension parts. +# +# See [proj-dot-ins-process] +proc proj-dot-ins-append {args} { + set srcdir $::autosetup(srcdir) + foreach f ${args} { + if {1==[llength $f]} { + lappend f [file rootname [file tail $f]] + } + #puts "******* [proj-current-proc-name]: adding $f" + lappend ::proj_(dot-in-files) $f + } +} + +######################################################################## +# @proj-dot-ins-list +# +# Returns the current list of [proj-dot-ins-append]'d files, noting +# that each entry is a 2-element list. +proc proj-dot-ins-list {} { + return $::proj_(dot-in-files) +} + +######################################################################## +# @proj-dot-ins-process ?-touch? +# +# Each file which has previously been passed to [proj-dot-ins-append] +# is processed, with its passing its in-file out-file names to +# [proj-make-from-dot-in]. +# +# The optional argument may be the -touch flag, which is passed on to +# that [proj-make-from-dot-in]. +# +# The intent is that a project accumulate any number of files to +# filter and delay their actual filtering until the last stage of the +# configure script, calling this function at that time. +proc proj-dot-ins-process {args} { + set flags "" + if {"-touch" eq $args} { + set flags "-touch" + } + foreach f $::proj_(dot-in-files) { + proj-assert {2==[llength $f]} + lassign $f fIn fOut + #puts "DOING $fIn ==> $fOut" + proj-make-from-dot-in {*}$flags $fIn $fOut + } +} + +######################################################################## +# @proj-validate-no-unresolved-ats filenames... +# +# For each filename given to it, it validates that the file has no +# unresolved @VAR@ references. If it finds any, it produces an error +# with location information. +proc proj-validate-no-unresolved-ats {args} { + foreach f $args { + set lnno 1 + foreach line [proj-file-content-list $f] { + if {[regexp {(@[A-Za-z0-9_]+@)} $line match]} { + error "Unresolved reference to $match at line $lnno of $f" + } + incr lnno + } + } +} diff --git a/autosetup/sqlite-config.tcl b/autosetup/sqlite-config.tcl index 56569ed5fe..b723a53c6d 100644 --- a/autosetup/sqlite-config.tcl +++ b/autosetup/sqlite-config.tcl @@ -490,6 +490,12 @@ proc sqlite-configure-phase1 {buildMode} { # may not) define HAVE_LFS. cc-check-lfs } + + set srcdir $::autosetup(srcdir) + proj-dot-ins-append $srcdir/Makefile.in + if {[file exists $srcdir/sqlite3.pc.in]} { + proj-dot-ins-append $srcdir/sqlite3.pc.in + } }; # sqlite-configure-phase1 ######################################################################## @@ -1005,8 +1011,17 @@ proc sqlite-handle-emsdk {} { # Maybe there's a copy in the path? proj-bin-define wasm-opt BIN_WASM_OPT } - proj-make-from-dot-in $emccSh $extWasmConfig + # + # We would prefer to pass these to proj-dot-ins-append but that + # family of APIs cannot handle the output being in a dir other + # than the current one. Also, we need to chmod +x $emccSh, and we + # don't have a hook to do that with if we defer dot-in-processing + # it. + # + proj-make-from-dot-in $emccSh.in + proj-make-from-dot-in $extWasmConfig.in catch {exec chmod u+x $emccSh} + proj-validate-no-unresolved-ats $emccSh $extWasmConfig } else { define EMCC_WRAPPER "" file delete -force -- $emccSh $extWasmConfig @@ -1725,15 +1740,7 @@ proc sqlite-process-dot-in-files {} { # (e.g. [proj-check-rpath]) may do so before we "mangle" them here. proj-remap-autoconf-dir-vars - 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 - } - } + proj-dot-ins-process make-config-header sqlite_cfg.h \ -bare {SIZEOF_* HAVE_DECL_*} \ -none {HAVE_CFLAG_* LDFLAGS_* SH_* SQLITE_AUTORECONFIG @@ -1755,17 +1762,9 @@ proc sqlite-post-config-validation {} { # contain any unresolved @VAR@ refs. That may indicate an # unexported/unused var or a typo. set srcdir $::autosetup(srcdir) - foreach f [list Makefile sqlite3.pc \ - $srcdir/tool/emcc.sh \ - $srcdir/ext/wasm/config.make] { - if {![file exists $f]} continue - set lnno 1 - foreach line [proj-file-content-list $f] { - if {[regexp {(@[A-Za-z0-9_]+@)} $line match]} { - error "Unresolved reference to $match at line $lnno of $f" - } - incr lnno - } + foreach f [proj-dot-ins-list] { + proj-assert {2==[llength $f]} + proj-validate-no-unresolved-ats [lindex $f 1] } } diff --git a/manifest b/manifest index bfb96183ce..e88ea04072 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rename\smakefile\svar\slibtclsqlite3.SO\sto\slibtclsqlite3.DLL\sfor\sconsistency. -D 2025-04-04T23:12:32.981 +C Refactor\sproj-make-from-dot-in\sand\sfriends\sto\sbe\smore\suseful\sand\sremove\ssome\sannoying\slimitations. +D 2025-04-05T02:59:37.477 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -51,8 +51,8 @@ F autosetup/cc.tcl c0fcc50ca91deff8741e449ddad05bcd08268bc31177e613a6343bbd1fd3e F autosetup/find_tclconfig.tcl e64886ffe3b982d4df42cd28ed91fe0b5940c2c5785e126c1821baf61bc86a7e F autosetup/jimsh0.c a57c16e65dcffc9c76e496757cb3f7fb47e01ecbd1631a0a5e01751fc856f049 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba -F autosetup/proj.tcl b808e3b176671d994358fcd6c47d5645a284658773e6f9e3c6292ed698a0b220 -F autosetup/sqlite-config.tcl 5c356e61d53b4f8b358b1a18aa27bc7856b745c425d5324c30b5231c967c9e52 +F autosetup/proj.tcl b180256ed6ebf651c49afcbb9c53bd471865f86db68357c90e2fc5a62a6a318c +F autosetup/sqlite-config.tcl 397cc72249133f72b21337c0d51426ee1cbc4e48ab9b53aa1f0fca8870104d64 F autosetup/system.tcl 51d4be76cd9a9074704b584e5c9cbba616202c8468cf9ba8a4f8294a7ab1dba9 F configure 9a00b21dfd13757bbfb8d89b30660a89ec1f8f3a79402b8f9f9b6fc475c3303a x F contrib/sqlitecon.tcl eb4c6578e08dd353263958da0dc620f8400b869a50d06e271ab0be85a51a08d3 @@ -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 84d77c5fe84d99d4af695a4da424b7dfc65f2343624e201736b7d673b2a8f179 -R 41dbfa3a3eb3de976c07f1845f1b45cd +P 6fb364c853be84c8d1f20497a2cae6e8f06a1d10ae364e3b011cadeaa3e0244b +R f77f5fd6c14452717ebb4784f39f44f1 U stephan -Z 62730cb1d0d281d2a24934aa35440eec +Z e4146e4a510a3a048f586eec271c895c # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 9f3da7735a..d48122b9a7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6fb364c853be84c8d1f20497a2cae6e8f06a1d10ae364e3b011cadeaa3e0244b +501ff84e1263e2b026b0ca5f043bcc912ea935229b625b113b7402955df20dd3