Fix detection of compiler crates in test script (#556)

* Be a bit more clever detecting a compiler dependency

* Work around premature closing of pipe

Co-authored-by: GHA <actions@github.com>
This commit is contained in:
Alejandro R Mosteo
2022-06-23 11:33:40 +02:00
committed by GitHub
parent 452ab8f14d
commit 69e6ae18f7
+9 -5
View File
@@ -133,11 +133,15 @@ for file in $CHANGES; do
if grep -iq 'gnat_' <<< $solution && ! grep -iq 'gnat_external' <<< $solution; then
gnat_dep=$(grep -E -o '^ gnat_[a-z0-9_]*=\S*' <<< $solution | tail -1 | xargs)
gnat_dep=${gnat_dep:-gnat_native}
echo "INSTALLING indexed gprbuild compatible with $gnat_dep"
alr toolchain --select $gnat_dep gprbuild
# -E for regex, -o for only the matched part, xargs to trim space
# We must give both the gnat in the solution and gprbuild, so both are compatible
# Even if we default to gnat_native, that would select the appropriate gprbuild
if alr show $gnat_dep | grep 'Provides: gnat=' >/dev/null; then
echo "INSTALLING indexed toolchain compatible with $gnat_dep"
alr toolchain --select $gnat_dep gprbuild
# -E for regex, -o for only the matched part, xargs to trim space
# We must give both the gnat in the solution and gprbuild, so both are compatible
# Even if we default to gnat_native, that would select the appropriate gprbuild
else
echo "Dependency $gnat_dep is not a GNAT compiler dependency, treating it as a regular crate"
fi
fi
# Detect whether the crate is binary to skip build