1# Copyright (C) 2018 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15gettop() { 16 # $BASH_SOURCE works if the shell is bash. $0 works when the shell was 17 # invoked from a shell script but may fail when sourced in non-bash shell. 18 SCRIPT=$(readlink -f ${BASH_SOURCE:-$0}) 19 TOPFILE="trusty/vendor/google/aosp/scripts/envsetup.sh" 20 TOPDIR=$(dirname $SCRIPT) 21 while [ \( ! -f "$TOPDIR/$TOPFILE" \) -a \( "$TOPDIR" != "/" \) ]; do 22 TOPDIR=`dirname $TOPDIR` 23 done 24 if [ ! -f "$TOPDIR/$TOPFILE" ]; then 25 echo "Error: Couldn't locate the top of the trusty tree. Try using bash?" 1>&2 26 exit 1 27 fi 28 echo $TOPDIR 29} 30 31if [ -z ${TRUSTY_BUILD_CLANG_VERSION} ]; then 32 TRUSTY_BUILD_CLANG_VERSION=clang-r522817 33fi 34if [ -z ${TRUSTY_BUILD_RUST_VERSION} ]; then 35 TRUSTY_BUILD_RUST_VERSION=1.80.1 36fi 37export TRUSTY_TOP=$(gettop) 38export CLANG_BINDIR=${TRUSTY_TOP}/prebuilts/clang/host/linux-x86/${TRUSTY_BUILD_CLANG_VERSION}/bin 39export CLANG_HOST_LIBDIR=${CLANG_BINDIR}/../lib 40export CLANG_GCC_TOOLCHAIN=${TRUSTY_TOP}/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8 41export CLANG_HOST_SYSROOT=${CLANG_GCC_TOOLCHAIN}/sysroot 42export CLANG_HOST_SEARCHDIR=${CLANG_GCC_TOOLCHAIN}/lib/gcc/x86_64-linux/4.8.3 43export CLANG_HOST_LDDIRS="${CLANG_GCC_TOOLCHAIN}/lib/gcc/x86_64-linux/4.8.3 ${CLANG_GCC_TOOLCHAIN}/x86_64-linux/lib64" 44export CLANG_TOOLS_BINDIR=${TRUSTY_TOP}/prebuilts/clang-tools/linux-x86/bin 45export LINUX_CLANG_BINDIR=${TRUSTY_TOP}/prebuilts/clang/host/linux-x86/${TRUSTY_BUILD_CLANG_VERSION}/bin 46export RUST_BINDIR=${TRUSTY_TOP}/prebuilts/rust/linux-x86/${TRUSTY_BUILD_RUST_VERSION}/bin 47export RUST_HOST_LIBDIR=${RUST_BINDIR}/../lib/rustlib/x86_64-unknown-linux-gnu/lib 48export ARCH_arm_TOOLCHAIN_PREFIX=${CLANG_BINDIR}/llvm- 49export ARCH_arm64_TOOLCHAIN_PREFIX=${CLANG_BINDIR}/llvm- 50export ARCH_x86_64_TOOLCHAIN_PREFIX=${CLANG_BINDIR}/llvm- 51export ARCH_x86_TOOLCHAIN_PREFIX=${CLANG_BINDIR}/llvm- 52export BUILDTOOLS_BINDIR=${TRUSTY_TOP}/prebuilts/build-tools/linux-x86/bin 53export BUILDTOOLS_COMMON=${TRUSTY_TOP}/prebuilts/build-tools/common 54export PY3=$BUILDTOOLS_BINDIR/py3-cmd 55export PATH_TOOLS_BINDIR=${TRUSTY_TOP}/prebuilts/build-tools/path/linux-x86 56 57SOONG_UI=$TRUSTY_TOP/build/soong/soong_ui.bash 58if [ -f "$SOONG_UI" ]; then 59 export SOONG_UI 60fi 61 62if [ -f "$TRUSTY_TOP/external/lk/engine.mk" ]; then 63 export LKROOT=$TRUSTY_TOP/external/lk 64elif [ -f "$TRUSTY_TOP/external/trusty/lk/engine.mk" ]; then 65 export LKROOT=$TRUSTY_TOP/external/trusty/lk 66else 67 echo "Error: Couldn't locate the LK root directory." 1>&2 68 exit 1 69fi 70 71# Additional Python libraries: 72# Most Trusty Python scripts source this file to find the hermetic 73# Python interpreter ($PY3). 74# The hermetic Python interpreter only exposes the Python standard library. 75# Set PYTHONPATH to make select, vendor'ed libraries available to hermetic 76# Python scripts. 77# WARNING: Python scripts that are copied to the build output directory should *not* 78# import these packages. 79PYTHONPATH=${TRUSTY_TOP}/prebuilts/libprotobuf/python 80PYTHONPATH=${PYTHONPATH}:${TRUSTY_TOP}/external/python/six 81PYTHONPATH=${PYTHONPATH}:${TRUSTY_TOP}/external/python/markupsafe/src 82PYTHONPATH=${PYTHONPATH}:${TRUSTY_TOP}/external/python/jinja/src 83export PYTHONPATH 84 85# Bindgen uses clang and libclang at runtime, so we need to tell it where to 86# look for these tools. 87export BINDGEN_CLANG_PATH=${TRUSTY_TOP}/prebuilts/clang/host/linux-x86/${TRUSTY_BUILD_CLANG_VERSION}/bin/clang 88export BINDGEN_LIBCLANG_PATH=${TRUSTY_TOP}/prebuilts/clang/host/linux-x86/${TRUSTY_BUILD_CLANG_VERSION}/lib 89