Skip to content

Commit a683904

Browse files
committed
Upstream teaish for a tcl portability fix on Haiku and a much nicer impl of proj-tclConfig-sh-to-autosetup.
1 parent 2b39999 commit a683904

6 files changed

Lines changed: 109 additions & 75 deletions

File tree

autoconf/tea/Makefile.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,9 @@ install-core: install-pre
324324
install-test: install-core
325325
@echo "Post-install test of [package require $(tx.name.pkg) $(tx.version)]..."; \
326326
if echo \
327-
'set c 0;' \
328-
'if {[catch {package require $(tx.name.pkg) $(tx.version)}]} {incr c};' \
327+
'set c 0; ' \
328+
'@TEAISH_POSTINST_PREREQUIRE@' \
329+
'if {[catch {package require $(tx.name.pkg) $(tx.version)}]} {incr c};' \
329330
'exit $$c' \
330331
| $(TCLSH) ; then \
331332
echo "passed"; \

autoconf/tea/autosetup/core.tcl

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ proc teaish-configure-core {} {
279279
# Set up some default values if the extension did not set them.
280280
# This must happen _after_ it's sourced but before
281281
# teaish-configure is called.
282-
teaish__f2d_array f2d
282+
array set f2d $::teaish__Config(pkginfo-f2d)
283283
foreach {pflag key type val} {
284284
- TEAISH_CFLAGS -v ""
285285
- TEAISH_LDFLAGS -v ""
@@ -397,7 +397,7 @@ proc teaish-configure-core {} {
397397
#
398398
proc teaish-debug {msg} {
399399
if {$::teaish__Config(debug-enabled)} {
400-
puts stderr [proj-bold "** DEBUG: \[[proj-current-scope 1]\]: $msg"]
400+
puts stderr [proj-bold "** DEBUG: \[[proj-scope 1]\]: $msg"]
401401
}
402402
}
403403

@@ -831,8 +831,60 @@ proc teaish__check_tcl {} {
831831
}
832832
}
833833
msg-result "Using Tcl [get-define TCL_VERSION] from [get-define TCL_PREFIX]."
834+
teaish__tcl_platform_quirks
834835
}; # teaish__check_tcl
835836

837+
#
838+
# Perform last-minute platform-specific tweaks to account for quirks.
839+
#
840+
proc teaish__tcl_platform_quirks {} {
841+
define TEAISH_POSTINST_PREREQUIRE ""
842+
switch -glob -- [get-define host] {
843+
*-haiku {
844+
# Haiku's default TCLLIBDIR is "all wrong": it points to a
845+
# read-only virtual filesystem mount-point. We bend it back to
846+
# fit under $TCL_PACKAGE_PATH here.
847+
foreach {k d} {
848+
vj TCL_MAJOR_VERSION
849+
vn TCL_MINOR_VERSION
850+
pp TCL_PACKAGE_PATH
851+
ld TCLLIBDIR
852+
} {
853+
set $k [get-define $d]
854+
}
855+
if {[string match /packages/* $ld]} {
856+
set old $ld
857+
set tail [file tail $ld]
858+
if {8 == $vj} {
859+
set ld "${pp}/tcl${vj}.${vn}/${tail}"
860+
} else {
861+
proj-assert {9 == $vj}
862+
set ld "${pp}/${tail}"
863+
}
864+
define TCLLIBDIR $ld
865+
# [load foo.so], without a directory part, does not work via
866+
# automated tests on Haiku (but works when run
867+
# manually). Similarly, the post-install [package require ...]
868+
# test fails, presumably for a similar reason. We work around
869+
# the former in teaish.tester.tcl.in. We work around the
870+
# latter by amending the post-install check's ::auto_path (in
871+
# Makefile.in). This code MUST NOT contain any single-quotes.
872+
define TEAISH_POSTINST_PREREQUIRE \
873+
[join [list set ::auto_path \
874+
\[ linsert \$::auto_path 0 $ld \] \; \
875+
]]
876+
proj-indented-notice [subst -nocommands -nobackslashes {
877+
Haiku users take note: patching target installation dir to match
878+
Tcl's home because Haiku's is not writable.
879+
880+
Original : $old
881+
Substitute: $ld
882+
}]
883+
}
884+
}
885+
}
886+
}; # teaish__tcl_platform_quirks
887+
836888
#
837889
# Searches $::argv and/or the build dir and/or the source dir for
838890
# teaish.tcl and friends. Fails if it cannot find teaish.tcl or if
@@ -1246,7 +1298,7 @@ proc teaish-dist-add {args} {
12461298
#}
12471299

12481300
#
1249-
# @teash-append-make args...
1301+
# @teash-make-add args...
12501302
#
12511303
# Appends makefile code to the TEAISH_MAKEFILE_CODE define. Each
12521304
# arg may be any of:
@@ -1331,7 +1383,7 @@ proc teaish-make-obj {o src args} {
13311383
}
13321384
}
13331385
teaish-make-add \
1334-
"# [proj-current-scope 1] -> [proj-current-scope] $o $src" -nl \
1386+
"# [proj-scope 1] -> [proj-scope] $o $src" -nl \
13351387
"$o: $src $::teaish__Config(teaish.tcl)"
13361388
if {[info exists flags(-deps)]} {
13371389
teaish-make-add " " [join $flags(-deps)]
@@ -1378,7 +1430,7 @@ proc teaish-make-clean {args} {
13781430
}
13791431
}
13801432
set rule [teaish__cleanup_rule $tgt]
1381-
teaish-make-add "# [proj-current-scope 1] -> [proj-current-scope]: [join $args]\n"
1433+
teaish-make-add "# [proj-scope 1] -> [proj-scope]: [join $args]\n"
13821434
teaish-make-add "${rule}:\n\trm ${rmflags}"
13831435
foreach a $args {
13841436
teaish-make-add " \"$a\""
@@ -1461,7 +1513,7 @@ proc teaish-check-cached {args} {
14611513
}
14621514
lassign $args msg script
14631515
if {"" eq $msg} {
1464-
set msg [proj-current-scope 1]
1516+
set msg [proj-scope 1]
14651517
}
14661518
msg-checking "${msg} ... "
14671519
if {[teaish-feature-cache-check 1 check]} {
@@ -1583,7 +1635,7 @@ proc teaish__defs_format {type value} {
15831635
default {
15841636
proj-error \
15851637
"Unknown [project-current-scope] -type ($type) called from" \
1586-
[proj-current-scope 1]
1638+
[proj-scope 1]
15871639
}
15881640
}
15891641
return $value
@@ -1850,7 +1902,7 @@ proc teaish-pkginfo-set {args} {
18501902
}
18511903
proj-parse-simple-flags args flags $flagDefs
18521904
if {[llength $args]} {
1853-
proj-error -up "Too many (or unknown) arguments to [proj-current-scope]: $args"
1905+
proj-error -up "Too many (or unknown) arguments to [proj-scope]: $args"
18541906
}
18551907
foreach {f d} $::teaish__Config(pkginfo-f2d) {
18561908
if {$sentinel eq [set v $flags($f)]} continue
@@ -1964,13 +2016,12 @@ proc teaish-pkginfo-get {args} {
19642016
}
19652017

19662018
default {
1967-
proj-error "invalid arg count from [proj-current-scope 1]"
2019+
proj-error "invalid arg count from [proj-scope 1]"
19682020
}
19692021
}
19702022

1971-
set cases [join $cases]
19722023
foreach {flag defName} $::teaish__Config(pkginfo-f2d) {
1973-
switch -exact -- $flag $cases
2024+
switch -exact -- $flag [join $cases]
19742025
}
19752026
if {0 == $argc} { return $rv }
19762027
}
@@ -2080,12 +2131,6 @@ proc teaish-get {flag} {
20802131
proj-error "Unhandled flag: $flag"
20812132
}
20822133

2083-
array set ::teaish__PkgInfoF2D $::teaish__Config(pkginfo-f2d)
2084-
proc teaish__f2d_array {tgtArrayName} {
2085-
upvar $tgtArrayName tgt
2086-
set tgt $::teaish__PkgInfoF2D
2087-
}
2088-
20892134
#
20902135
# Handles --teaish-create-extension=TARGET-DIR
20912136
#

autoconf/tea/autosetup/feature-tests.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ proc teaish-import-features {args} {
186186
#
187187
if {$flags(-run) && "" ne $pk} {
188188
proj-error "Cannot use both -run and $pk" \
189-
" (called from [proj-current-scope 1])"
189+
" (called from [proj-scope 1])"
190190
}
191191

192192
foreach arg $args {

autoconf/tea/teaish.tester.tcl.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
@TEAISH_VSATISFIES_CODE@
1818
@endif
1919
if {[llength [lindex $::argv 0]] > 0} {
20-
load [lindex $::argv 0] [lindex $::argv 1];
20+
load [file normalize [lindex $::argv 0]] [lindex $::argv 1];
21+
# ----^^^^^^^ needed on Haiku when argv 0 is just a filename, else
22+
# load cannot find the file.
2123
}
2224
source -encoding utf-8 [lindex $::argv 2]; # teaish/tester.tcl
2325
@if TEAISH_PKGINIT_TCL

0 commit comments

Comments
 (0)