-
Notifications
You must be signed in to change notification settings - Fork 0
/
gn_build.sh
executable file
·203 lines (163 loc) · 5.85 KB
/
gn_build.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/env bash
#
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e
CHIP_ROOT="$(dirname "$0")"
_chip_red() {
echo -e "\033[0;31m$*\033[0m"
}
_chip_yellow() {
echo -e "\033[0;33m$*\033[0m"
}
_chip_banner() {
_chip_yellow '.--------------------------------'
_chip_yellow "-- $1"
_chip_yellow "'--------------------------------"
}
_chip_banner "Environment bringup"
git -C "$CHIP_ROOT" submodule update --init
# TODO: Fix pigweed to bootstrap if necessary in activate.sh.
echo
echo "NB: If this fails run \"source scripts/bootstrap.sh\""
source "$CHIP_ROOT/scripts/activate.sh"
_chip_banner "Instructions"
echo
echo 'To activate existing build environment in your shell, run (do this first):'
echo source "$CHIP_ROOT/scripts/activate.sh"
echo
echo 'To re-create the build environment from scratch, run:'
echo source "$CHIP_ROOT/scripts/bootstrap.sh"
echo
echo 'To compile the generated debug build:'
echo ninja -C "$CHIP_ROOT/out/debug"
echo
echo 'To test the generated debug build (idempotent):'
echo ninja -C "$CHIP_ROOT/out/debug" check
echo
echo 'To compile the generated release build':
echo ninja -C "$CHIP_ROOT/out/release"
echo
echo 'To test the generated release build (idempotent):'
echo ninja -C "$CHIP_ROOT/out/release" check
echo
echo 'To build a custom build (for help run "gn args --list out/debug")'
echo gn args "$CHIP_ROOT/out/custom"
echo ninja -C "$CHIP_ROOT/out/custom"
extra_args=""
user_args=""
ninja_args=()
while getopts :d:j:k:l:nt:vw: opt; do
case "$opt" in
[nv])
ninja_args+=("-$opt")
;;
[djkltw])
ninja_args+=("-$opt" "$OPTARG")
;;
'?')
printf '\nError: unknown option -%s\n' "$OPTARG"
printf 'Usage: %s [ninja-options] [gn-args]\n' "$0"
exit 1
;;
esac
done
shift $((OPTIND - 1))
for arg; do
case $arg in
enable_qpg_builds=true)
qpg_enabled=1
;;
enable_efr32_builds=true)
efr32_enabled=1
;;
enable_p6_builds=true)
p6_builds_enabled=1
;;
p6_board=*)
p6_board_selected=1
;;
esac
user_args+=" $arg"
done
# Android prebuilt JAR setup
python3 build/chip/java/tests/generate_jars_for_test.py
python3 third_party/android_deps/set_up_android_deps.py
# Android SDK setup
android_sdk_args=""
if [[ -d "${ANDROID_NDK_HOME}/toolchains" && -d "${ANDROID_HOME}/platforms" ]]; then
android_sdk_args+="android_sdk_root=\"$ANDROID_HOME\" android_ndk_root=\"$ANDROID_NDK_HOME\""
extra_args+=" $android_sdk_args enable_android_builds=true"
else
echo
echo "Hint: Set \$ANDROID_HOME and \$ANDROID_NDK_HOME to enable building for Android"
echo " The required android sdk platform version is 21. It can be obtained from"
echo " https://dl.google.com/android/repository/android-21_r02.zip"
fi
echo
# EFR32 SDK setup
if [[ -z "$efr32_enabled" ]]; then
echo "Hint: Pass enable_efr32_builds=true to enable building for EFR32"
else
echo 'To build the EFR32 lock sample as a standalone project':
echo "(cd $CHIP_ROOT/examples/lock-app/efr32; gn gen out/debug; ninja -C out/debug)"
fi
echo
# P6 Build setup
if [[ -z "$p6_builds_enabled" ]]; then
echo "Hint: Pass enable_p6_builds=true to this script to enable building for PSoC6-43012"
else
p6_sdk_args=""
if [[ -z "$p6_board_selected" ]]; then
p6_sdk_args="p6_board=\"CY8CKIT-062S2-43012\""
fi
fi
# K32W SDK setup
k32w_sdk_args=""
if [[ -d "$NXP_K32W061_SDK_ROOT" ]]; then
k32w_sdk_args+="k32w0_sdk_root=\"$NXP_K32W061_SDK_ROOT\""
extra_args+=" $k32w0_sdk_args enable_k32w_builds=true"
fi
echo
if [[ ! -d "$NXP_K32W061_SDK_ROOT" ]]; then
echo "Hint: Set \$NXP_K32W061_SDK_ROOT to enable building for K32W061"
else
echo 'To build the K32W lock sample as a standalone project':
echo "(cd $CHIP_ROOT/examples/lock-app/nxp/k32w/k32w0; gn gen out/debug --args='$k32w_sdk_args'; ninja -C out/debug)"
fi
echo
if [[ -z "$qpg_enabled" ]]; then
echo "Hint: Pass enable_qpg_builds=true to this script to enable building for QPG"
else
echo 'To build the QPG6100 lock sample as a standalone project:'
echo "(cd $CHIP_ROOT/examples/lock-app/qpg; gn gen out/debug; ninja -C out/debug)"
fi
echo
# TI SimpleLink SDK setup
ti_simplelink_sdk_args=""
if [[ -d "${TI_SIMPLELINK_SDK_ROOT}/source" && -f "${TI_SYSCONFIG_ROOT}/sysconfig_cli.sh" ]]; then
ti_simplelink_sdk_args+="ti_simplelink_sdk_root=\"$TI_SIMPLELINK_SDK_ROOT\" ti_sysconfig_root=\"$TI_SYSCONFIG_ROOT\""
extra_args+=" $ti_simplelink_sdk_args enable_ti_simplelink_builds=true"
echo 'To build the cc13x2x7_26x2x7 lock sample as a standalone project':
echo "(cd $CHIP_ROOT/examples/lock-app/cc13x2x7_26x2x7; gn gen out/debug --args='$ti_simplelink_sdk_args'; ninja -C out/debug)"
else
echo "Hint: Set \$TI_SIMPLELINK_SDK_ROOT and \$TI_SYSCONFIG_ROOT to enable building for cc13x2_26x2"
fi
echo
_chip_banner "Build: GN configure"
gn --root="$CHIP_ROOT" gen --check --fail-on-unused-args "$CHIP_ROOT/out/debug" --args='target_os="all"'"$extra_args$user_args"
gn --root="$CHIP_ROOT" gen --check --fail-on-unused-args "$CHIP_ROOT/out/release" --args='target_os="all" is_debug=false'"$extra_args$user_args"
_chip_banner "Build: Ninja build"
time ninja -C "$CHIP_ROOT/out/debug" "${ninja_args[@]}" all check