fix[build]: Avoid exporting toolchain to system PATH

Change-Id: Ic85b4a20df81d4a430ca9563d3555e38cfe97338
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
This commit is contained in:
Johnson Ding
2025-01-23 17:30:35 +08:00
committed by Herman Chen
parent 3ea5eb5a51
commit 975a0b3e69
4 changed files with 28 additions and 19 deletions

View File

@@ -1,14 +1,9 @@
cmake_minimum_required( VERSION 2.6.3 ) cmake_minimum_required( VERSION 2.6.3 )
if(NOT TOOLCHAIN)
set(TOOLCHAIN "aarch64-linux-gnu-")
endif()
SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_C_COMPILER "${TOOLCHAIN}gcc") SET(CMAKE_C_COMPILER "${TOOLCHAIN}gcc")
SET(CMAKE_CXX_COMPILER "${TOOLCHAIN}g++") SET(CMAKE_CXX_COMPILER "${TOOLCHAIN}g++")
#SET(CMAKE_SYSTEM_PROCESSOR "armv7-a")
SET(CMAKE_SYSTEM_PROCESSOR "armv8-a") SET(CMAKE_SYSTEM_PROCESSOR "armv8-a")
add_definitions(-fPIC) add_definitions(-fPIC)

View File

@@ -5,21 +5,30 @@ set +e
MPP_PWD=`pwd` MPP_PWD=`pwd`
MPP_TOP=${MPP_PWD}/../../.. MPP_TOP=${MPP_PWD}/../../..
DEFAULT_TOOLCHAIN=aarch64-linux-gnu-
# toolchain detection # toolchain detection
check_cmd(){ check_cmd(){
"$@" >> /dev/null 2>&1 "$@" >> /dev/null 2>&1
} }
check_system_arm_linux_gcc(){ check_gcc(){
check_cmd aarch64-linux-gnu-gcc -v check_cmd ${TOOLCHAIN}gcc -v
} }
source ../opt_proc.sh source ../opt_proc.sh
check_system_arm_linux_gcc if [ -z "${TOOLCHAIN}" ]; then
echo "Using system ${DEFAULT_TOOLCHAIN} as toolchain."
TOOLCHAIN=$DEFAULT_TOOLCHAIN
fi
check_gcc
if [ $? -eq 127 ];then if [ $? -eq 127 ];then
MPP_TOOLCHAIN=/usr/bin echo -e "\e[31m${TOOLCHAIN}gcc is not found!\e[0m"
export PATH=$PATH:${MPP_TOOLCHAIN} echo -e "Please specify valid toolchain path and it's prefix to variable 'TOOLCHAIN' with argument --toolchain."
echo -e "For example:\n \t./make-Makefiles.bin --toolchain /path-to-toolchain/arm-linux-gnueabi-"
exit 1
fi fi
# generate Makefile # generate Makefile

View File

@@ -1,10 +1,6 @@
cmake_minimum_required( VERSION 2.6.3 ) cmake_minimum_required( VERSION 2.6.3 )
if(NOT TOOLCHAIN)
set(TOOLCHAIN "arm-linux-gnueabi-")
endif()
SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_C_COMPILER "${TOOLCHAIN}gcc") SET(CMAKE_C_COMPILER "${TOOLCHAIN}gcc")
SET(CMAKE_CXX_COMPILER "${TOOLCHAIN}g++") SET(CMAKE_CXX_COMPILER "${TOOLCHAIN}g++")

View File

@@ -5,21 +5,30 @@ set +e
MPP_PWD=`pwd` MPP_PWD=`pwd`
MPP_TOP=${MPP_PWD}/../../.. MPP_TOP=${MPP_PWD}/../../..
DEFAULT_TOOLCHAIN=arm-linux-gnueabi-
# toolchain detection # toolchain detection
check_cmd(){ check_cmd(){
"$@" >> /dev/null 2>&1 "$@" >> /dev/null 2>&1
} }
check_system_arm_linux_gcc(){ check_gcc(){
check_cmd arm-linux-gcc -v check_cmd ${TOOLCHAIN}gcc -v
} }
source ../opt_proc.sh source ../opt_proc.sh
check_system_arm_linux_gcc if [ -z "${TOOLCHAIN}" ]; then
echo "Using system ${DEFAULT_TOOLCHAIN} as toolchain."
TOOLCHAIN=$DEFAULT_TOOLCHAIN
fi
check_gcc
if [ $? -eq 127 ];then if [ $? -eq 127 ];then
MPP_TOOLCHAIN=${MPP_TOP}/../prebuilts/toolschain/usr/bin echo -e "\e[31m${TOOLCHAIN}gcc is not found!\e[0m"
export PATH=$PATH:${MPP_TOOLCHAIN} echo -e "Please specify valid toolchain path and it's prefix to variable 'TOOLCHAIN' with argument --toolchain."
echo -e "For example:\n \t./make-Makefiles.bin --toolchain /path-to-toolchain/arm-linux-gnueabi-"
exit 1
fi fi
# generate Makefile # generate Makefile