|
6 | 6 | dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@" |
7 | 7 |
|
8 | 8 | # Note that the version has a trailing + on unreleased versions |
9 | | -set autosetup(version) 0.7.1 |
| 9 | +set autosetup(version) 0.7.1+ |
10 | 10 |
|
11 | 11 | # Can be set to 1 to debug early-init problems |
12 | 12 | set autosetup(debug) [expr {"--debug" in $argv}] |
@@ -204,19 +204,10 @@ proc main {argv} { |
204 | 204 |
|
205 | 205 | autosetup_add_dep $autosetup(autodef) |
206 | 206 |
|
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) |
220 | 211 |
|
221 | 212 | # Log how we were invoked |
222 | 213 | configlog "Invoked as: [getenv WRAPPER $::argv0] [quote-argv $autosetup(argv)]" |
@@ -744,31 +735,45 @@ proc undefine {name} { |
744 | 735 | # If the variable is not defined or empty, it is set to '$value'. |
745 | 736 | # Otherwise the value is appended, separated by a space. |
746 | 737 | # 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. |
748 | 741 | # |
749 | 742 | proc define-append {name args} { |
750 | 743 | if {[get-define $name ""] ne ""} { |
751 | | - # Avoid duplicates |
752 | 744 | foreach arg $args { |
753 | 745 | if {$arg eq ""} { |
754 | 746 | continue |
755 | 747 | } |
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 |
765 | 749 | } |
766 | 750 | } else { |
767 | 751 | set ::define($name) [join $args] |
768 | 752 | } |
769 | 753 | #dputs "$name += [join $args] => $::define($name)" |
770 | 754 | } |
771 | 755 |
|
| 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 | + |
772 | 777 | # @get-define name ?default=0? |
773 | 778 | # |
774 | 779 | # Returns the current value of the "defined" variable, or '$default' |
@@ -1487,7 +1492,7 @@ proc autosetup_help {what} { |
1487 | 1492 |
|
1488 | 1493 | puts "Usage: [file tail $::autosetup(exe)] \[options\] \[settings\]\n" |
1489 | 1494 | 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" |
1491 | 1496 |
|
1492 | 1497 | if {$what in {all local}} { |
1493 | 1498 | # Need to load auto.def now |
@@ -1560,8 +1565,8 @@ proc autosetup_reference {{type text}} { |
1560 | 1565 | section {Introduction} |
1561 | 1566 |
|
1562 | 1567 | 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`. |
1565 | 1570 | } |
1566 | 1571 |
|
1567 | 1572 | p { |
@@ -1971,7 +1976,7 @@ can be loaded with the 'use' directive. |
1971 | 1976 |
|
1972 | 1977 | *.auto files in this directory are auto-loaded. |
1973 | 1978 |
|
1974 | | -For more information, see http://msteveb.github.io/autosetup/ |
| 1979 | +For more information, see https://msteveb.github.io/autosetup/ |
1975 | 1980 | } |
1976 | 1981 | dputs "install: autosetup/README.autosetup" |
1977 | 1982 | writefile $target $readme |
@@ -2105,6 +2110,19 @@ if {$autosetup(istcl)} { |
2105 | 2110 | proc isatty? {channel} { |
2106 | 2111 | dict exists [fconfigure $channel] -xchar |
2107 | 2112 | } |
| 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 | + } |
2108 | 2126 | } else { |
2109 | 2127 | if {$autosetup(iswin)} { |
2110 | 2128 | # On Windows, backslash convert all environment variables |
@@ -2158,16 +2176,11 @@ proc error-location {msg} { |
2158 | 2176 | return -code error $msg |
2159 | 2177 | } |
2160 | 2178 | # 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" |
2166 | 2182 | } |
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" |
2171 | 2184 | } |
2172 | 2185 | return $msg |
2173 | 2186 | } |
|
0 commit comments