-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathenvsetup.sh
executable file
·121 lines (98 loc) · 2.61 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
if [ -z "${BASH_SOURCE}" ];then
echo Not in bash, switching to it...
bash -c "$0 $@"
fi
function choose_board()
{
echo
echo "You're building on Linux"
echo "Lunch menu...pick a combo:"
echo ""
echo "0. non-rockchip boards"
echo ${RK_DEFCONFIG_ARRAY[@]} | xargs -n 1 | sed "=" | sed "N;s/\n/. /"
local INDEX
while true; do
read -p "Which would you like? [0]: " INDEX
INDEX=$((${INDEX:-0} - 1))
if [ "$INDEX" -eq -1 ]; then
echo "Lunching for non-rockchip boards..."
unset TARGET_OUTPUT_DIR
unset RK_BUILD_CONFIG
break;
fi
if echo $INDEX | grep -vq [^0-9]; then
RK_BUILD_CONFIG="${RK_DEFCONFIG_ARRAY[$INDEX]}"
[ -n "$RK_BUILD_CONFIG" ] && break
fi
echo
echo "Choice not available. Please try again."
echo
done
}
function lunch_rockchip()
{
TARGET_DIR_NAME="$RK_BUILD_CONFIG"
export TARGET_OUTPUT_DIR="$BUILDROOT_OUTPUT_DIR/$TARGET_DIR_NAME"
mkdir -p $TARGET_OUTPUT_DIR || return
echo "==========================================="
echo
echo "#TARGET_BOARD=`echo $RK_BUILD_CONFIG | cut -d '_' -f 2`"
echo "#OUTPUT_DIR=output/$TARGET_DIR_NAME"
echo "#CONFIG=${RK_BUILD_CONFIG}_defconfig"
echo
echo "==========================================="
make -C ${BUILDROOT_DIR} O="$TARGET_OUTPUT_DIR" \
"$RK_BUILD_CONFIG"_defconfig
CONFIG=${TARGET_OUTPUT_DIR}/.config
cp ${CONFIG}{,.new}
[ -f ${CONFIG}.old ] || return 0
mv ${CONFIG}{.old,} &>/dev/null
make -C ${BUILDROOT_DIR} O="$TARGET_OUTPUT_DIR" olddefconfig &>/dev/null
if ! diff ${CONFIG}{,.new}; then
read -t 10 -p "Found old config, override it? (y/n):" YES
[ "$YES" != "n" ] && cp ${CONFIG}{.new,}
fi
}
function main()
{
SCRIPT_PATH=$(realpath ${BASH_SOURCE})
SCRIPT_DIR=$(dirname ${SCRIPT_PATH})
BUILDROOT_DIR=$(dirname ${SCRIPT_DIR})
BUILDROOT_OUTPUT_DIR=${BUILDROOT_DIR}/output
TOP_DIR=$(dirname ${BUILDROOT_DIR})
echo Top of tree: ${TOP_DIR}
# Set croot alias
alias croot="cd ${TOP_DIR}"
RK_DEFCONFIG_ARRAY=(
$(cd ${BUILDROOT_DIR}/configs/; ls rockchip_* | \
sed "s/_defconfig$//" | grep "$1" | sort)
)
unset RK_BUILD_CONFIG
RK_DEFCONFIG_ARRAY_LEN=${#RK_DEFCONFIG_ARRAY[@]}
case $RK_DEFCONFIG_ARRAY_LEN in
0)
echo No available configs${1:+" for: $1"}
;;
1)
RK_BUILD_CONFIG=${RK_DEFCONFIG_ARRAY[0]}
;;
*)
if [ "$1" = ${RK_DEFCONFIG_ARRAY[0]} ]; then
# Prefer exact-match
RK_BUILD_CONFIG=$1
else
choose_board
fi
;;
esac
[ -n "$RK_BUILD_CONFIG" ] || return
source ${TOP_DIR}/device/rockchip/.BoardConfig.mk
lunch_rockchip
}
if [ "${BASH_SOURCE}" == "$0" ];then
echo This script is executed directly...
bash -c "source \"$0\" \"$@\"; bash"
else
main "$@"
fi