aboutsummaryrefslogtreecommitdiff
path: root/autosetup/autosetup
diff options
context:
space:
mode:
Diffstat (limited to 'autosetup/autosetup')
-rwxr-xr-xautosetup/autosetup89
1 files changed, 51 insertions, 38 deletions
diff --git a/autosetup/autosetup b/autosetup/autosetup
index 0dee7a5..e4d5a31 100755
--- a/autosetup/autosetup
+++ b/autosetup/autosetup
@@ -6,7 +6,7 @@
dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@"
# Note that the version has a trailing + on unreleased versions
-set autosetup(version) 0.7.1
+set autosetup(version) 0.7.1+
# Can be set to 1 to debug early-init problems
set autosetup(debug) [expr {"--debug" in $argv}]
@@ -204,19 +204,10 @@ proc main {argv} {
autosetup_add_dep $autosetup(autodef)
- # Add $argv to CONFIGURE_OPTS, but ignore duplicates and quote if needed
- set configure_opts {}
- foreach arg $autosetup(argv) {
- set quoted [quote-if-needed $arg]
- # O(n^2), but n will be small
- if {$quoted ni $configure_opts} {
- lappend configure_opts $quoted
- }
- }
- define CONFIGURE_OPTS [join $configure_opts]
- define AUTOREMAKE [quote-if-needed $autosetup(exe)]
- define-append AUTOREMAKE [get-define CONFIGURE_OPTS]
-
+ # Add $argv to CONFIGURE_OPTS
+ define-append-argv CONFIGURE_OPTS {*}$autosetup(argv)
+ # Set up AUTOREMAKE to reconfigure with the same args
+ define-append-argv AUTOREMAKE {*}$autosetup(exe) {*}$autosetup(argv)
# Log how we were invoked
configlog "Invoked as: [getenv WRAPPER $::argv0] [quote-argv $autosetup(argv)]"
@@ -744,24 +735,17 @@ proc undefine {name} {
# If the variable is not defined or empty, it is set to '$value'.
# Otherwise the value is appended, separated by a space.
# Any extra values are similarly appended.
-# If any value is already contained in the variable (as a substring) it is omitted.
+#
+# Note that define-append is not designed to add values containing spaces.
+# If values may contain spaces, consider define-append-argv instead.
#
proc define-append {name args} {
if {[get-define $name ""] ne ""} {
- # Avoid duplicates
foreach arg $args {
if {$arg eq ""} {
continue
}
- set found 0
- foreach str [split $::define($name) " "] {
- if {$str eq $arg} {
- incr found
- }
- }
- if {!$found} {
- append ::define($name) " " $arg
- }
+ append ::define($name) " " $arg
}
} else {
set ::define($name) [join $args]
@@ -769,6 +753,27 @@ proc define-append {name args} {
#dputs "$name += [join $args] => $::define($name)"
}
+# @define-append-argv name value ...
+#
+# Similar to define-append except designed to construct shell command
+# lines, including correct handling of parameters with spaces.
+#
+# Each non-empty value is quoted if necessary and then appended to the given variable
+# if it does not already exist.
+#
+proc define-append-argv {name args} {
+ set seen {}
+ set new {}
+ foreach val [list {*}[get-define $name ""] {*}$args] {
+ if {$val ne {} && ![dict exists $seen $val]} {
+ lappend new [quote-if-needed $val]
+ dict set seen $val 1
+ }
+ }
+ set ::define($name) [join $new " "]
+ #dputs "$name += [join $args] => $::define($name)"
+}
+
# @get-define name ?default=0?
#
# Returns the current value of the "defined" variable, or '$default'
@@ -1487,7 +1492,7 @@ proc autosetup_help {what} {
puts "Usage: [file tail $::autosetup(exe)] \[options\] \[settings\]\n"
puts "This is [autosetup_version], a build environment \"autoconfigurator\""
- puts "See the documentation online at http://msteveb.github.io/autosetup/\n"
+ puts "See the documentation online at https://msteveb.github.io/autosetup/\n"
if {$what in {all local}} {
# Need to load auto.def now
@@ -1560,8 +1565,8 @@ proc autosetup_reference {{type text}} {
section {Introduction}
p {
- See http://msteveb.github.com/autosetup/ for the online documentation for 'autosetup'.
- This documentation can also be accessed locally with `autosetup --ref`.
+ See https://msteveb.github.io/autosetup/ for the online documentation for 'autosetup'.
+ This documentation can also be accessed locally with `autosetup --ref`.
}
p {
@@ -1971,7 +1976,7 @@ can be loaded with the 'use' directive.
*.auto files in this directory are auto-loaded.
-For more information, see http://msteveb.github.io/autosetup/
+For more information, see https://msteveb.github.io/autosetup/
}
dputs "install: autosetup/README.autosetup"
writefile $target $readme
@@ -2105,6 +2110,19 @@ if {$autosetup(istcl)} {
proc isatty? {channel} {
dict exists [fconfigure $channel] -xchar
}
+ # Jim-compatible stacktrace using info frame
+ proc stacktrace {} {
+ set stacktrace {}
+ # 2 to skip the current frame
+ for {set i 2} {$i < [info frame]} {incr i} {
+ set frame [info frame -$i]
+ if {[dict exists $frame file]} {
+ # We don't need proc, so use ""
+ lappend stacktrace "" [dict get $frame file] [dict get $frame line]
+ }
+ }
+ return $stacktrace
+ }
} else {
if {$autosetup(iswin)} {
# On Windows, backslash convert all environment variables
@@ -2158,16 +2176,11 @@ proc error-location {msg} {
return -code error $msg
}
# Search back through the stack trace for the first error in a .def file
- for {set i 1} {$i < [info level]} {incr i} {
- if {$::autosetup(istcl)} {
- array set info [info frame -$i]
- } else {
- lassign [info frame -$i] info(caller) info(file) info(line)
+ foreach {p f l} [stacktrace] {
+ if {[string match *.def $f]} {
+ return "[relative-path $f]:$l: Error: $msg"
}
- if {[string match *.def $info(file)]} {
- return "[relative-path $info(file)]:$info(line): Error: $msg"
- }
- #puts "Skipping $info(file):$info(line)"
+ #puts "Skipping $f:$l"
}
return $msg
}