From 90fdfedf4bb258597ab0e3c90f2771ad4a6e09d3 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Wed, 4 May 2016 12:10:45 +0300 Subject: [PATCH] Update toolchain selection code --- common.sh | 21 ++++++++++++--------- main.sh | 8 ++++---- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/common.sh b/common.sh index b04cb734f3..00a9f44212 100644 --- a/common.sh +++ b/common.sh @@ -200,37 +200,40 @@ compile_kernel (){ mv *.deb $DEST/debs/ || exit_with_error "Failed moving kernel DEBs" } -# check_toolchain +# check_toolchain # # checks if system default toolchain version satisfies # : "< 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 +# find_toolchain # # writes path to toolchain that satisfies to # 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 diff --git a/main.sh b/main.sh index 599018fbe6..cabc3670cb 100644 --- a/main.sh +++ b/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