mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
Update toolchain selection code
This commit is contained in:
21
common.sh
21
common.sh
@@ -200,37 +200,40 @@ compile_kernel (){
|
||||
mv *.deb $DEST/debs/ || exit_with_error "Failed moving kernel DEBs"
|
||||
}
|
||||
|
||||
# check_toolchain <expression> <path>
|
||||
# check_toolchain <UBOOT|KERNEL> <expression>
|
||||
#
|
||||
# checks if system default toolchain version satisfies <expression>
|
||||
# <expression>: "< x.y"; "> x.y"; "== x.y"
|
||||
check_toolchain()
|
||||
{
|
||||
local expression=$1
|
||||
local path=$2
|
||||
local target=$1
|
||||
local expression=$2
|
||||
eval local compiler=\$${target}_COMPILER
|
||||
# get major.minor gcc version
|
||||
local gcc_ver=$(${COMPILER}gcc -dumpversion | grep -oE "^[[:digit:]].[[:digit:]]")
|
||||
local gcc_ver=$(${compiler}gcc -dumpversion | grep -oE "^[[:digit:]].[[:digit:]]")
|
||||
awk "BEGIN{exit ! ($gcc_ver $expression)}" && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
# find_toolchain <expression> <var_name>
|
||||
# find_toolchain <UBOOT|KERNEL> <expression> <var_name>
|
||||
#
|
||||
# writes path to toolchain that satisfies <expression> to <var_name>
|
||||
#
|
||||
find_toolchain()
|
||||
{
|
||||
local expression=$1
|
||||
local var_name=$2
|
||||
local target=$1
|
||||
local expression=$2
|
||||
local var_name=$3
|
||||
local dist=10
|
||||
eval local compiler=\$${target}_COMPILER
|
||||
local toolchain=""
|
||||
# extract target major.minor version from expression
|
||||
local target_ver=$(grep -oE "[[:digit:]].[[:digit:]]" <<< "$expression")
|
||||
for dir in $SRC/toolchains/*/; do
|
||||
# check if is a toolchain for current $ARCH
|
||||
[[ ! -f ${dir}bin/${COMPILER}gcc ]] && continue
|
||||
[[ ! -f ${dir}bin/${compiler}gcc ]] && continue
|
||||
# get toolchain major.minor version
|
||||
local gcc_ver=$(${dir}bin/${COMPILER}gcc -dumpversion | grep -oE "^[[:digit:]].[[:digit:]]")
|
||||
local gcc_ver=$(${dir}bin/${compiler}gcc -dumpversion | grep -oE "^[[:digit:]].[[:digit:]]")
|
||||
# check if toolchain version satisfies requirement
|
||||
awk "BEGIN{exit ! ($gcc_ver $expression)}" || continue
|
||||
# check if found version is the closest to target
|
||||
|
||||
8
main.sh
8
main.sh
@@ -204,9 +204,9 @@ done
|
||||
# Compile u-boot if packed .deb does not exist
|
||||
if [[ ! -f $DEST/debs/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then
|
||||
# if requires specific toolchain, check if default is suitable
|
||||
if [[ -n $UBOOT_NEEDS_GCC ]] && ! check_toolchain "$UBOOT_NEEDS_GCC" ; then
|
||||
if [[ -n $UBOOT_NEEDS_GCC ]] && ! check_toolchain "UBOOT" "$UBOOT_NEEDS_GCC" ; then
|
||||
# try to find suitable in $SRC/toolchains
|
||||
find_toolchain "$UBOOT_NEEDS_GCC" UBOOT_TOOLCHAIN
|
||||
find_toolchain "UBOOT" "$UBOOT_NEEDS_GCC" "UBOOT_TOOLCHAIN"
|
||||
[[ -z $UBOOT_TOOLCHAIN ]] && exit_with_error "Could not find required u-boot toolchain" "$UBOOT_NEEDS_GCC"
|
||||
fi
|
||||
cd $SOURCES/$BOOTSOURCEDIR
|
||||
@@ -218,9 +218,9 @@ fi
|
||||
# Compile kernel if packed .deb does not exist
|
||||
if [[ ! -f $DEST/debs/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then
|
||||
# if requires specific toolchain, check if default is suitable
|
||||
if [[ -n $KERNEL_NEEDS_GCC ]] && ! check_toolchain $KERNEL_NEEDS_GCC ; then
|
||||
if [[ -n $KERNEL_NEEDS_GCC ]] && ! check_toolchain "$KERNEL" "$KERNEL_NEEDS_GCC" ; then
|
||||
# try to find suitable in $SRC/toolchains
|
||||
find_toolchain $KERNEL_NEEDS_GCC KERNEL_TOOLCHAIN
|
||||
find_toolchain "KERNEL" "$KERNEL_NEEDS_GCC" "KERNEL_TOOLCHAIN"
|
||||
[[ -z $KERNEL_TOOLCHAIN ]] && exit_with_error "Could not find required kernel toolchain" "$KERNEL_NEEDS_GCC"
|
||||
fi
|
||||
cd $SOURCES/$LINUXSOURCEDIR
|
||||
|
||||
Reference in New Issue
Block a user