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 #clang-r536225 reports version as 19.0.1 which is also what Rust 1.82 was built with 33 TRUSTY_BUILD_CLANG_VERSION=clang-r536225 34fi 35if [ -z ${TRUSTY_BUILD_RUST_VERSION} ]; then 36 TRUSTY_BUILD_RUST_VERSION=1.82.0 37fi 38export TRUSTY_TOP=$(gettop) 39export CLANG_BINDIR=${TRUSTY_TOP}/prebuilts/clang/host/linux-x86/${TRUSTY_BUILD_CLANG_VERSION}/bin 40export CLANG_HOST_LIBDIR=${CLANG_BINDIR}/../lib 41export CLANG_GCC_TOOLCHAIN=${TRUSTY_TOP}/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8 42export CLANG_HOST_SYSROOT=${CLANG_GCC_TOOLCHAIN}/sysroot 43export CLANG_HOST_SEARCHDIR=${CLANG_GCC_TOOLCHAIN}/lib/gcc/x86_64-linux/4.8.3 44export CLANG_HOST_LDDIRS="${CLANG_GCC_TOOLCHAIN}/lib/gcc/x86_64-linux/4.8.3 ${CLANG_GCC_TOOLCHAIN}/x86_64-linux/lib64" 45export CLANG_TOOLS_BINDIR=${TRUSTY_TOP}/prebuilts/clang-tools/linux-x86/bin 46export LINUX_CLANG_BINDIR=${TRUSTY_TOP}/prebuilts/clang/host/linux-x86/${TRUSTY_BUILD_CLANG_VERSION}/bin 47export RUST_BINDIR=${TRUSTY_TOP}/prebuilts/rust/linux-x86/${TRUSTY_BUILD_RUST_VERSION}/bin 48export RUST_HOST_LIBDIR=${RUST_BINDIR}/../lib/rustlib/x86_64-unknown-linux-gnu/lib 49export ARCH_arm_TOOLCHAIN_PREFIX=${CLANG_BINDIR}/llvm- 50export ARCH_arm64_TOOLCHAIN_PREFIX=${CLANG_BINDIR}/llvm- 51export ARCH_x86_64_TOOLCHAIN_PREFIX=${CLANG_BINDIR}/llvm- 52export ARCH_x86_TOOLCHAIN_PREFIX=${CLANG_BINDIR}/llvm- 53export BUILDTOOLS_BINDIR=${TRUSTY_TOP}/prebuilts/build-tools/linux-x86/bin 54export BUILDTOOLS_COMMON=${TRUSTY_TOP}/prebuilts/build-tools/common 55export PY3=$BUILDTOOLS_BINDIR/py3-cmd 56export PATH_TOOLS_BINDIR=${TRUSTY_TOP}/prebuilts/build-tools/path/linux-x86 57export LINUX_BUILD_TOOLS=${TRUSTY_TOP}/prebuilts/kernel-build-tools/linux-x86 58 59SOONG_UI=$TRUSTY_TOP/build/soong/soong_ui.bash 60if [ -f "$SOONG_UI" ]; then 61 export SOONG_UI 62fi 63 64if [ -f "$TRUSTY_TOP/external/lk/engine.mk" ]; then 65 export LKROOT=external/lk 66elif [ -f "$TRUSTY_TOP/external/trusty/lk/engine.mk" ]; then 67 export LKROOT=external/trusty/lk 68else 69 echo "Error: Couldn't locate the LK root directory." 1>&2 70 exit 1 71fi 72 73# Additional Python libraries: 74# Most Trusty Python scripts source this file to find the hermetic 75# Python interpreter ($PY3). 76# The hermetic Python interpreter only exposes the Python standard library. 77# Set PYTHONPATH to make select, vendor'ed libraries available to hermetic 78# Python scripts. 79# WARNING: Python scripts that are copied to the build output directory should *not* 80# import these packages. 81PYTHONPATH=${TRUSTY_TOP}/prebuilts/libprotobuf/python 82PYTHONPATH=${PYTHONPATH}:${TRUSTY_TOP}/external/python/six 83PYTHONPATH=${PYTHONPATH}:${TRUSTY_TOP}/external/python/markupsafe/src 84PYTHONPATH=${PYTHONPATH}:${TRUSTY_TOP}/external/python/jinja/src 85export PYTHONPATH 86 87# Bindgen uses clang and libclang at runtime, so we need to tell it where to 88# look for these tools. 89export BINDGEN_CLANG_PATH=${TRUSTY_TOP}/prebuilts/clang/host/linux-x86/${TRUSTY_BUILD_CLANG_VERSION}/bin/clang 90export BINDGEN_LIBCLANG_PATH=${TRUSTY_TOP}/prebuilts/clang/host/linux-x86/${TRUSTY_BUILD_CLANG_VERSION}/lib 91