Refactor all.sh clang version detection code

Prevents a script failure when attempting to run build_aes_armce on a system without clang

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
This commit is contained in:
Tom Cosgrove 2024-01-30 13:56:38 +00:00
parent 9e4eeff6e0
commit d4c373a597

View file

@ -821,6 +821,14 @@ pre_generate_files() {
fi fi
} }
clang_version() {
if command -v clang > /dev/null ; then
clang --version|grep version|sed -E 's#.*version ([0-9]+).*#\1#'
else
echo 0 # report version 0 for "no clang"
fi
}
################################################################ ################################################################
#### Helpers for components using libtestdriver1 #### Helpers for components using libtestdriver1
################################################################ ################################################################
@ -4692,14 +4700,8 @@ component_test_aesni_m32 () { # ~ 60s
} }
support_test_aesni_m32_clang() { support_test_aesni_m32_clang() {
support_test_aesni_m32 && if command -v clang > /dev/null ; then # clang >= 4 is required to build with target attributes
# clang >= 4 is required to build with target attributes support_test_aesni_m32 && [[ $(clang_version) -ge 4 ]]
clang_ver="$(clang --version|grep version|sed -E 's#.*version ([0-9]+).*#\1#')"
[[ "${clang_ver}" -ge 4 ]]
else
# clang not available
false
fi
} }
component_test_aesni_m32_clang() { component_test_aesni_m32_clang() {
@ -4751,8 +4753,7 @@ component_build_aes_aesce_armcc () {
support_build_aes_armce() { support_build_aes_armce() {
# clang >= 11 is required to build with AES extensions # clang >= 11 is required to build with AES extensions
ver="$(clang --version|grep version|sed -E 's#.*version ([0-9]+).*#\1#')" [[ $(clang_version) -ge 11 ]]
[ "${ver}" -ge 11 ]
} }
component_build_aes_armce () { component_build_aes_armce () {
@ -4807,15 +4808,8 @@ component_build_aes_armce () {
} }
support_build_sha_armce() { support_build_sha_armce() {
if command -v clang > /dev/null ; then # clang >= 4 is required to build with SHA extensions
# clang >= 4 is required to build with SHA extensions [[ $(clang_version) -ge 4 ]]
clang_ver="$(clang --version|grep version|sed -E 's#.*version ([0-9]+).*#\1#')"
[[ "${clang_ver}" -ge 4 ]]
else
# clang not available
false
fi
} }
component_build_sha_armce () { component_build_sha_armce () {