• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# source this script in bash
2
3source ${ANDROID_BUILD_TOP}/build/envsetup.sh
4
5# See envsetup.sh for an example of using --dumpvars-mode to set shell variables.
6eval "$(cd ${ANDROID_BUILD_TOP}; build/soong/soong_ui.bash --dumpvars-mode --vars="\
7    TARGET_ARCH \
8    TARGET_OUT \
9    TARGET_OUT_EXECUTABLES \
10    TARGET_OUT_DATA \
11    HOST_OS \
12    HOST_ARCH \
13    HOST_OUT \
14    ")"
15
16function prepare()
17{
18    local BITS=$1
19    shift
20
21    BENCHMARKS=${TARGET_OUT_DATA}/benchmarktest
22    NATIVETEST=${TARGET_OUT_DATA}/nativetest
23    if [ "${BITS}" = 64 ]; then
24        BENCHMARKS=${BENCHMARKS}64
25        NATIVETEST=${NATIVETEST}64
26    fi
27
28    if [ ${TARGET_ARCH} = x86 -o ${TARGET_ARCH} = x86_64 ]; then
29        m -j MODULES-IN-bionic MODULES-IN-external-icu MODULES-IN-external-mksh ${TARGET_OUT}/etc/hosts "$@"
30
31        if [ ! -d /system ]; then
32            echo "Attempting to create /system"
33            sudo mkdir -p -m 0777 /system
34            mkdir -p -m 0777 /system/bin
35            mkdir -p -m 0777 /system/lib
36            mkdir -p -m 0777 /system/lib64
37        fi
38        (
39            function make_link() {
40                dir=$1
41                tgt=$2
42                name=`basename ${tgt}`
43                src=$dir/$name
44                if [ -e $tgt ]; then
45                    ln -sfT `realpath ${tgt}` $src
46                fi
47            }
48            cd ${ANDROID_BUILD_TOP}
49            mkdir -p ${TARGET_OUT_DATA}/local/tmp
50            for i in ${TARGET_OUT}/bin/bootstrap/* ${TARGET_OUT}/bin/*; do
51                make_link /system/bin ${i}
52            done
53            ln -fs `realpath ${TARGET_OUT}/etc` /system/
54            for i in ${TARGET_OUT}/lib/bootstrap/* ${TARGET_OUT}/lib/*; do
55                make_link /system/lib ${i}
56            done
57            for i in ${TARGET_OUT}/lib64/bootstrap/* ${TARGET_OUT}/lib64/*; do
58                make_link /system/lib64 ${i}
59            done
60        )
61    fi
62}
63