Skip to content

Commit 6a1af5b

Browse files
committed
build: update autosetup to v0.7.1-11-g9d20e8a
Mostly for update bootstrap jimsh Signed-off-by: Steve Bennett <[email protected]>
1 parent e7872e6 commit 6a1af5b

File tree

5 files changed

+4002
-2181
lines changed

5 files changed

+4002
-2181
lines changed

autosetup/README.autosetup

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
README.autosetup created by autosetup v0.7.1
1+
README.autosetup created by autosetup v0.7.1+
22

33
This is the autosetup directory for a local install of autosetup.
44
It contains autosetup, support files and loadable modules.
@@ -8,4 +8,4 @@ can be loaded with the 'use' directive.
88

99
*.auto files in this directory are auto-loaded.
1010

11-
For more information, see http://msteveb.github.io/autosetup/
11+
For more information, see https://msteveb.github.io/autosetup/

autosetup/autosetup

Lines changed: 51 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@"
77

88
# Note that the version has a trailing + on unreleased versions
9-
set autosetup(version) 0.7.1
9+
set autosetup(version) 0.7.1+
1010

1111
# Can be set to 1 to debug early-init problems
1212
set autosetup(debug) [expr {"--debug" in $argv}]
@@ -204,19 +204,10 @@ proc main {argv} {
204204

205205
autosetup_add_dep $autosetup(autodef)
206206

207-
# Add $argv to CONFIGURE_OPTS, but ignore duplicates and quote if needed
208-
set configure_opts {}
209-
foreach arg $autosetup(argv) {
210-
set quoted [quote-if-needed $arg]
211-
# O(n^2), but n will be small
212-
if {$quoted ni $configure_opts} {
213-
lappend configure_opts $quoted
214-
}
215-
}
216-
define CONFIGURE_OPTS [join $configure_opts]
217-
define AUTOREMAKE [quote-if-needed $autosetup(exe)]
218-
define-append AUTOREMAKE [get-define CONFIGURE_OPTS]
219-
207+
# Add $argv to CONFIGURE_OPTS
208+
define-append-argv CONFIGURE_OPTS {*}$autosetup(argv)
209+
# Set up AUTOREMAKE to reconfigure with the same args
210+
define-append-argv AUTOREMAKE {*}$autosetup(exe) {*}$autosetup(argv)
220211

221212
# Log how we were invoked
222213
configlog "Invoked as: [getenv WRAPPER $::argv0] [quote-argv $autosetup(argv)]"
@@ -744,31 +735,45 @@ proc undefine {name} {
744735
# If the variable is not defined or empty, it is set to '$value'.
745736
# Otherwise the value is appended, separated by a space.
746737
# Any extra values are similarly appended.
747-
# If any value is already contained in the variable (as a substring) it is omitted.
738+
#
739+
# Note that define-append is not designed to add values containing spaces.
740+
# If values may contain spaces, consider define-append-argv instead.
748741
#
749742
proc define-append {name args} {
750743
if {[get-define $name ""] ne ""} {
751-
# Avoid duplicates
752744
foreach arg $args {
753745
if {$arg eq ""} {
754746
continue
755747
}
756-
set found 0
757-
foreach str [split $::define($name) " "] {
758-
if {$str eq $arg} {
759-
incr found
760-
}
761-
}
762-
if {!$found} {
763-
append ::define($name) " " $arg
764-
}
748+
append ::define($name) " " $arg
765749
}
766750
} else {
767751
set ::define($name) [join $args]
768752
}
769753
#dputs "$name += [join $args] => $::define($name)"
770754
}
771755

756+
# @define-append-argv name value ...
757+
#
758+
# Similar to define-append except designed to construct shell command
759+
# lines, including correct handling of parameters with spaces.
760+
#
761+
# Each non-empty value is quoted if necessary and then appended to the given variable
762+
# if it does not already exist.
763+
#
764+
proc define-append-argv {name args} {
765+
set seen {}
766+
set new {}
767+
foreach val [list {*}[get-define $name ""] {*}$args] {
768+
if {$val ne {} && ![dict exists $seen $val]} {
769+
lappend new [quote-if-needed $val]
770+
dict set seen $val 1
771+
}
772+
}
773+
set ::define($name) [join $new " "]
774+
#dputs "$name += [join $args] => $::define($name)"
775+
}
776+
772777
# @get-define name ?default=0?
773778
#
774779
# Returns the current value of the "defined" variable, or '$default'
@@ -1487,7 +1492,7 @@ proc autosetup_help {what} {
14871492
14881493
puts "Usage: [file tail $::autosetup(exe)] \[options\] \[settings\]\n"
14891494
puts "This is [autosetup_version], a build environment \"autoconfigurator\""
1490-
puts "See the documentation online at http://msteveb.github.io/autosetup/\n"
1495+
puts "See the documentation online at https://msteveb.github.io/autosetup/\n"
14911496
14921497
if {$what in {all local}} {
14931498
# Need to load auto.def now
@@ -1560,8 +1565,8 @@ proc autosetup_reference {{type text}} {
15601565
section {Introduction}
15611566
15621567
p {
1563-
See http://msteveb.github.com/autosetup/ for the online documentation for 'autosetup'.
1564-
This documentation can also be accessed locally with `autosetup --ref`.
1568+
See https://msteveb.github.io/autosetup/ for the online documentation for 'autosetup'.
1569+
This documentation can also be accessed locally with `autosetup --ref`.
15651570
}
15661571
15671572
p {
@@ -1971,7 +1976,7 @@ can be loaded with the 'use' directive.
19711976
19721977
*.auto files in this directory are auto-loaded.
19731978
1974-
For more information, see http://msteveb.github.io/autosetup/
1979+
For more information, see https://msteveb.github.io/autosetup/
19751980
}
19761981
dputs "install: autosetup/README.autosetup"
19771982
writefile $target $readme
@@ -2105,6 +2110,19 @@ if {$autosetup(istcl)} {
21052110
proc isatty? {channel} {
21062111
dict exists [fconfigure $channel] -xchar
21072112
}
2113+
# Jim-compatible stacktrace using info frame
2114+
proc stacktrace {} {
2115+
set stacktrace {}
2116+
# 2 to skip the current frame
2117+
for {set i 2} {$i < [info frame]} {incr i} {
2118+
set frame [info frame -$i]
2119+
if {[dict exists $frame file]} {
2120+
# We don't need proc, so use ""
2121+
lappend stacktrace "" [dict get $frame file] [dict get $frame line]
2122+
}
2123+
}
2124+
return $stacktrace
2125+
}
21082126
} else {
21092127
if {$autosetup(iswin)} {
21102128
# On Windows, backslash convert all environment variables
@@ -2158,16 +2176,11 @@ proc error-location {msg} {
21582176
return -code error $msg
21592177
}
21602178
# Search back through the stack trace for the first error in a .def file
2161-
for {set i 1} {$i < [info level]} {incr i} {
2162-
if {$::autosetup(istcl)} {
2163-
array set info [info frame -$i]
2164-
} else {
2165-
lassign [info frame -$i] info(caller) info(file) info(line)
2179+
foreach {p f l} [stacktrace] {
2180+
if {[string match *.def $f]} {
2181+
return "[relative-path $f]:$l: Error: $msg"
21662182
}
2167-
if {[string match *.def $info(file)]} {
2168-
return "[relative-path $info(file)]:$info(line): Error: $msg"
2169-
}
2170-
#puts "Skipping $info(file):$info(line)"
2183+
#puts "Skipping $f:$l"
21712184
}
21722185
return $msg
21732186
}

autosetup/cc.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ proc calc-define-output-type {name spec} {
678678
}
679679

680680
# Initialise some values from the environment or commandline or default settings
681-
foreach i {LDFLAGS LIBS CPPFLAGS LINKFLAGS {CFLAGS "-g -O2"}} {
681+
foreach i {LDFLAGS LIBS CPPFLAGS LINKFLAGS CFLAGS} {
682682
lassign $i var default
683683
define $var [get-env $var $default]
684684
}
@@ -727,7 +727,7 @@ foreach i {CC CXX CCACHE CPP CFLAGS CXXFLAGS CXXFLAGS LDFLAGS LIBS CROSS CPPFLAG
727727
if {[env-is-set $i]} {
728728
# Note: If the variable is set on the command line, get-env will return that value
729729
# so the command line will continue to override the environment
730-
define-append AUTOREMAKE [quote-if-needed $i=[get-env $i ""]]
730+
define-append-argv AUTOREMAKE $i=[get-env $i ""]
731731
}
732732
}
733733

0 commit comments

Comments
 (0)