@@ -16,10 +16,13 @@ if [[ ! -x "$LLVM_ROOT/bin/clang++" ]]; then
1616 echo " SKIP: no llvm payload installed ($LLVM_ROOT )" ; exit 0
1717fi
1818work=" $( mktemp -d) "
19+ # Paths written INTO a manifest go through host_path (see _host_path.sh).
20+ source " $( dirname " $0 " ) /_host_path.sh"
1921trap ' rm -rf "$work"' EXIT
2022export NO_COLOR=1
2123
2224T=" $work /llvm"
25+ T_HOST=" $( host_path " $T " ) "
2326mkdir -p " $T /bin"
2427for f in " $LLVM_ROOT " /bin/* ; do
2528 case " $f " in * .cfg) ;; * ) ln -s " $f " " $T /bin/" ;; esac
@@ -28,35 +31,37 @@ for d in include lib share libexec; do [ -e "$LLVM_ROOT/$d" ] && ln -s "$LLVM_RO
2831# A linker stated by role, as a wrapper the test can change in place.
2932printf ' #!/bin/sh\nexec "%s/bin/ld.lld" "$@"\n' " $LLVM_ROOT " > " $work /ld-wrapper"
3033chmod +x " $work /ld-wrapper"
34+ wrapper_HOST=" $( host_path " $work /ld-wrapper" ) "
3135
3236mkdir -p " $work /app/src"
3337cat > " $work /app/src/main.cpp" << 'CPP '
3438#include <cstdio>
3539int main() { std::puts("built by a toolchain named by path"); return 0; }
3640CPP
3741write_manifest () {
42+ local root_HOST; root_HOST=" $( host_path " $1 " ) "
3843 cat > " $work /app/mcpp.toml" << TOML
3944[package]
4045name = "app"
4146version = "0.1.0"
4247
4348[toolchain]
44- default = { path = "$1 "$2 }
49+ default = { path = "$root_HOST "$2 }
4550TOML
4651}
4752cd " $work /app"
4853fail () { echo " FAIL: $* " ; echo " ----" ; echo " $out " ; exit 1; }
4954
50- write_manifest " $T " ' , launcher = "/usr/bin/env", tools = { ld = "' " $work /ld-wrapper " ' " }'
55+ write_manifest " $T " ' , launcher = "/usr/bin/env", tools = { ld = "' " $wrapper_HOST " ' " }'
5156rm -rf target
5257out=" $( " $MCPP " build 2>&1 ) " || fail " the build failed"
53- grep -q " Using toolchain clang .* ← $T \[custom · mcpp.toml:[0-9]*\]" <<< " $out" || fail " no Using line for the toolchain"
58+ grep -q " Using toolchain clang .* ← $T_HOST \[custom · mcpp.toml:[0-9]*\]" <<< " $out" || fail " no Using line for the toolchain"
5459grep -q " Finished .* · custom: toolchain" <<< " $out" || fail " Finished does not summarise the source"
5560run=" $( ./target/* /* /bin/app) "
5661[[ " $run " == " built by a toolchain named by path" ]] || fail " the program did not run: $run "
5762ninja=" $( cat target/* /* /build.ninja) "
58- grep -q " ^cxx *= /usr/bin/env $T /bin/clang++" <<< " $ninja" || fail " the launcher does not prefix the compiler"
59- grep -q -- " --ld-path=$work /ld-wrapper " <<< " $ninja" || fail " the stated linker is not used"
63+ grep -q " ^cxx *= /usr/bin/env $T_HOST /bin/clang++" <<< " $ninja" || fail " the launcher does not prefix the compiler"
64+ grep -q -- " --ld-path=$wrapper_HOST " <<< " $ninja" || fail " the stated linker is not used"
6065[[ -z " $( find " $T /" -maxdepth 2 -name ' *.cfg' -print -quit) " ]] || fail " mcpp wrote a cfg into the tree"
6166
6267# The fast path serves an unchanged tree, and declines once a program of it changed.
@@ -77,7 +82,8 @@ out="$(MCPP_TOOLCHAIN="path:$T" "$MCPP" build 2>&1)" || fail "MCPP_TOOLCHAIN=pat
7782grep -q " \[custom · env MCPP_TOOLCHAIN\]" <<< " $out" || fail " the env-named toolchain is not reported"
7883
7984# A stated family the drivers contradict is refused.
80- write_manifest " $T " ' , family = "gcc", tools = { cxx = "' " $T /bin/clang++" ' " }'
85+ driver_HOST=" $( host_path " $T /bin/clang++" ) "
86+ write_manifest " $T " ' , family = "gcc", tools = { cxx = "' " $driver_HOST " ' " }'
8187rm -rf target
8288out=" $( " $MCPP " build 2>&1 || true) "
8389grep -q ' stated as family "gcc"' <<< " $out" || fail " a contradicting family was accepted"
@@ -96,7 +102,7 @@ gcc_base="$HOME/.mcpp/registry/data/xpkgs/xim-x-gcc"
96102[[ -d " $gcc_base " && -n " ${USERPROFILE:- } " ]] || true
97103gcc_ver=" $( ls -1 " $gcc_base " 2> /dev/null | grep -E ' ^[0-9]+(\.[0-9]+)*$' | sort -V | tail -1) "
98104if [[ -n " $gcc_ver " && -x " $gcc_base /$gcc_ver /bin/g++" ]]; then
99- write_manifest " $gcc_base /$gcc_ver " ' , tools = { ld = "' " $work /ld-wrapper " ' " }'
105+ write_manifest " $gcc_base /$gcc_ver " ' , tools = { ld = "' " $wrapper_HOST " ' " }'
100106 rm -rf target
101107 out=" $( " $MCPP " build 2>&1 || true) "
102108 grep -q " this is a gcc toolchain" <<< " $out" \
0 commit comments