forked from MiCode/patchrom_build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
envsetup.sh
89 lines (83 loc) · 2.51 KB
/
envsetup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
#
# usage:
# under the porting workspace, run:
# $. /path/to/envsetup.sh [android_build_top] [android_product_out]
#
# description:
# If android build environment has been setup (i.e. lunch'ed), the value of
# android_build_top and android_product_out specified here would not be used.
# If android_build_top or android_product_out is empty, then ?
set -- `getopt "a:l:b:h:p:" "$@"`
android_top=
android_lunch=
ANDROID_BRANCH=
PORT_PRODUCT="Unknown"
help=
while :
do
case "$1" in
-a) shift; android_top="$1" ;;
-l) shift; android_lunch="$1";;
-b) shift; ANDROID_BRANCH="$1";;
-p) shift; PORT_PRODUCT="$1";;
-h) help=1;;
--) break ;;
esac
shift
done
shift
if [ -n "$help" ]; then
echo "Usage: . /path/to/envsetup [-a android-top [-l lunch-option] [-b android-branch]]"
return
fi
if [ -n "$android_top" ]; then
if [ ! -d "$android_top" ]; then
echo "Failed: $android_top does not exist"
return
fi
cd $android_top
. build/envsetup.sh
lunch $android_lunch
USE_ANDROID_OUT=true
export USE_ANDROID_OUT
cd -
else
ANDROID_BRANCH=
fi
TOPFILE=build/porting.mk
if [ -f $TOPFILE ] ; then
PORT_ROOT=$PWD
else
while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
cd .. > /dev/null
done
if [ -f $PWD/$TOPFILE ]; then
PORT_ROOT=$PWD
else
echo "Failed! run me under you porting workspace"
return
fi
fi
if [ -n "$PORT_ROOT" ]; then
PORT_BUILD=$PORT_ROOT/build
ANDROID_TOP=${ANDROID_BUILD_TOP:=$1}
ANDROID_OUT=${ANDROID_PRODUCT_OUT:=$2}
PATCHROM_BRANCH=$(grep -rn "BRANCH" $PORT_ROOT/android/README | cut -d'=' -f2)
ANDROID_PLATFORM=$(grep -rn "PLATFORM" $PORT_ROOT/android/README | cut -d'=' -f2)
HOST_OS=$(uname -s | tr '[A-Z]' '[a-z]')
export PORT_ROOT PORT_BUILD ANDROID_TOP ANDROID_OUT ANDROID_BRANCH PORT_PRODUCT PATCHROM_BRANCH ANDROID_PLATFORM HOST_OS
export PATH=$PORT_ROOT/tools/${HOST_OS}-x86:$PORT_ROOT/tools:$PATH
echo "PATCHROM_BRANCH = $PATCHROM_BRANCH"
echo "ANDROID_PLATFORM = $ANDROID_PLATFORM"
echo "PORT_ROOT = $PORT_ROOT"
echo "ANDROID_TOP = $ANDROID_TOP"
echo "ANDROID_OUT = $ANDROID_OUT"
echo "PORT_PRODUCT = $PORT_PRODUCT"
echo "USE_ANDROID_OUT = $USE_ANDROID_OUT"
echo "ANDROID_BRANCH = $ANDROID_BRANCH"
echo "HOST_OS = $HOST_OS"
fi
# Tell python not to spam the source tree with .pyc files. This
# only has an effect on python 2.6 and above.
export PYTHONDONTWRITEBYTECODE=1