mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-16 17:36:59 +02:00
eclass/llvm: Sync with Gentoo
It's from Gentoo commit 64a5154944610c040453e46284a20b9c2bde4d0e.
This commit is contained in:
parent
41738efbd2
commit
af99246a92
@ -180,6 +180,64 @@ get_llvm_prefix() {
|
|||||||
die "No LLVM slot${1:+ <= ${1}} satisfying the package's dependencies found installed!"
|
die "No LLVM slot${1:+ <= ${1}} satisfying the package's dependencies found installed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# @FUNCTION: llvm_fix_clang_version
|
||||||
|
# @USAGE: <variable-name>...
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# Fix the clang compiler name in specified variables to include
|
||||||
|
# the major version, to prevent PATH alterations from forcing an older
|
||||||
|
# clang version being used.
|
||||||
|
llvm_fix_clang_version() {
|
||||||
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
|
|
||||||
|
local shopt_save=$(shopt -p -o noglob)
|
||||||
|
set -f
|
||||||
|
local var
|
||||||
|
for var; do
|
||||||
|
local split=( ${!var} )
|
||||||
|
case ${split[0]} in
|
||||||
|
*clang|*clang++|*clang-cpp)
|
||||||
|
local version=()
|
||||||
|
read -r -a version < <("${split[0]}" --version)
|
||||||
|
local major=${version[-1]%%.*}
|
||||||
|
if [[ -n ${major//[0-9]} ]]; then
|
||||||
|
die "${var}=${!var} produced invalid --version: ${version[*]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
split[0]+=-${major}
|
||||||
|
if ! type -P "${split[0]}" &>/dev/null; then
|
||||||
|
die "${split[0]} does not seem to exist"
|
||||||
|
fi
|
||||||
|
declare -g "${var}=${split[*]}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
${shopt_save}
|
||||||
|
}
|
||||||
|
|
||||||
|
# @FUNCTION: llvm_fix_tool_path
|
||||||
|
# @USAGE: <variable-name>...
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# Fix the LLVM tools referenced in the specified variables to their
|
||||||
|
# current location, to prevent PATH alterations from forcing older
|
||||||
|
# versions being used.
|
||||||
|
llvm_fix_tool_path() {
|
||||||
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
|
|
||||||
|
local shopt_save=$(shopt -p -o noglob)
|
||||||
|
set -f
|
||||||
|
local var
|
||||||
|
for var; do
|
||||||
|
local split=( ${!var} )
|
||||||
|
local path=$(type -P ${split[0]} 2>/dev/null)
|
||||||
|
# if it resides in one of the LLVM prefixes, it's an LLVM tool!
|
||||||
|
if [[ ${path} == "${BROOT}/usr/lib/llvm"* ]]; then
|
||||||
|
split[0]=${path}
|
||||||
|
declare -g "${var}=${split[*]}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
${shopt_save}
|
||||||
|
}
|
||||||
|
|
||||||
# @FUNCTION: llvm_pkg_setup
|
# @FUNCTION: llvm_pkg_setup
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Prepend the appropriate executable directory for the newest
|
# Prepend the appropriate executable directory for the newest
|
||||||
@ -198,6 +256,11 @@ llvm_pkg_setup() {
|
|||||||
debug-print-function ${FUNCNAME} "${@}"
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
|
|
||||||
if [[ ${MERGE_TYPE} != binary ]]; then
|
if [[ ${MERGE_TYPE} != binary ]]; then
|
||||||
|
llvm_fix_clang_version CC CPP CXX
|
||||||
|
# keep in sync with profiles/features/llvm/make.defaults!
|
||||||
|
llvm_fix_tool_path ADDR2LINE AR AS LD NM OBJCOPY OBJDUMP RANLIB
|
||||||
|
llvm_fix_tool_path READELF STRINGS STRIP
|
||||||
|
|
||||||
local llvm_path=$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin
|
local llvm_path=$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin
|
||||||
local IFS=:
|
local IFS=:
|
||||||
local split_path=( ${PATH} )
|
local split_path=( ${PATH} )
|
||||||
|
Loading…
Reference in New Issue
Block a user