| #!/bin/bash |
| # Usage: |
| # source setup_env.sh |
| # |
| # Inputs: |
| # TOP_DIR: where the .repo of prebuilts reside |
| # It is optional. Default is this script's <dir>/ ../.. |
| # ENABLE_64BIT_BUILD: if we are building 64bit prebuilts |
| # It is optional. Default is TRUE. |
| # Exports: |
| # used for kernel or kernel module configs |
| # |
| # CROSS_COMPILER_DIR: where cross compilers are |
| # ARCH: arm or arm64 |
| # CROSS_COMPILE: the prefix of cross compiler |
| # LD: the linker to use |
| # PATH: new PATH includes the cross compiler |
| # CROSS_MAKE: make cmd with essential paramerters to do cross make |
| # |
| # Functions |
| # GetModulePath: |
| # Take <eureka_src_path> and <product> to generate target |
| # kernel module path |
| |
| if [ ! -d "${TOP_DIR}" ]; then |
| TOP_DIR="$(readlink -e $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../..)" |
| fi |
| ENABLE_64BIT_BUILD=${ENABLE_64BIT_BUILD:-"true"} |
| |
| _toolchain_dir=$(readlink -e ${TOP_DIR}/prebuilt/toolchain) |
| _num_jobs=$(grep -c processor /proc/cpuinfo) |
| |
| if [ "${ENABLE_64BIT_BUILD}" = "false" ]; then |
| export CROSS_COMPILER_DIR=${_toolchain_dir}/armv7a/bin |
| export ARCH=arm |
| export CROSS_COMPILE=armv7a-cros-linux-gnueabihf- |
| export LD=${CROSS_COMPILE}ld |
| export CC=${CROSS_COMPILE}gcc |
| else |
| export CROSS_COMPILER_DIR=${_toolchain_dir}/aarch64/bin |
| export ARCH=arm64 |
| export CROSS_COMPILE=aarch64-cros-linux-gnu- |
| export LD=${CROSS_COMPILE}ld.bfd |
| export CC=${CROSS_COMPILE}clang |
| fi |
| |
| function GetModulePath() { |
| local eureka_src_path=$1 |
| local product=$2 |
| |
| echo "${eureka_src_path}/vendor/qualcomm/${product}/prebuilt/systemfs_overlay/lib/modules" |
| } |
| |
| function GetKernelPath() { |
| local eureka_src_path=$1 |
| local product=$2 |
| |
| echo ${eureka_src_path}/vendor/qualcomm/${product}/prebuilt/kernel |
| } |
| |
| export PATH=${CROSS_COMPILER_DIR}:$PATH |
| export CROSS_MAKE="make -j${_num_jobs} CC=${CC} LD=${LD}" |