blob: 4a84cffb96f093efe81b526a7c66c533bc58a123 [file] [log] [blame]
Michael Spangefa630b2020-07-08 22:23:08 -04001# Copyright (c) 2020 Project CHIP Authors
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
15import("//build_overrides/chip.gni")
16import("//build_overrides/mbedtls.gni")
17import("//build_overrides/nlassert.gni")
18import("//build_overrides/nlio.gni")
19import("//build_overrides/nlunit_test.gni")
20import("//build_overrides/pigweed.gni")
21
22# This build file should not be used in superproject builds.
23assert(chip_root == "//")
24
25import("${chip_root}/gn/chip/tests.gni")
26import("${chip_root}/gn/chip/tools.gni")
27
28if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
29 # This is a real toolchain. Build CHIP.
30 group("default") {
31 deps = [ ":all" ]
32 }
33
34 group("all") {
35 deps = [
36 "${chip_root}/src/app",
37 "${chip_root}/src/ble",
38 "${chip_root}/src/controller",
39 "${chip_root}/src/crypto",
40 "${chip_root}/src/inet",
41 "${chip_root}/src/lib",
42 "${chip_root}/src/lib/core",
Michael Spang8d085b32020-07-10 10:26:23 -040043 "${chip_root}/src/lib/shell",
Michael Spangefa630b2020-07-08 22:23:08 -040044 "${chip_root}/src/lib/support",
45 "${chip_root}/src/lwip:all",
Rob Walkerb14e3e32020-08-20 13:59:22 -070046 "${chip_root}/src/setup_payload",
Michael Spangefa630b2020-07-08 22:23:08 -040047 "${chip_root}/src/system",
48 "${chip_root}/src/transport",
49 "${mbedtls_root}:mbedtls",
50 "${nlassert_root}:nlassert",
51 "${nlio_root}:nlio",
52 "${nlunit_test_root}:nlunit-test",
53 ]
54
randyrossi90988b62020-08-19 13:39:57 -040055 # Temporary until RNG issue sorted out
56 if (current_os != "android") {
Michael Spang3afd9932020-08-20 14:00:46 -040057 deps += [ "${chip_root}/src/lib/message" ]
randyrossi90988b62020-08-19 13:39:57 -040058 }
59
Michael Spangefa630b2020-07-08 22:23:08 -040060 if (chip_build_tests) {
61 deps += [ ":tests" ]
62 }
63
64 if (chip_build_tools) {
65 deps += [
Michael Spangfa6b5222020-08-17 12:54:40 -040066 "${chip_root}/examples/shell",
Michael Spangefa630b2020-07-08 22:23:08 -040067 "${chip_root}/src/qrcodetool",
68 "${chip_root}/src/setup_payload",
69 ]
70 }
Andrei Litvind74a0b62020-08-30 19:58:00 -040071
72 if (current_os == "android") {
73 deps += [
74 "${chip_root}/src/controller/java",
75 "${chip_root}/src/setup_payload/java",
76 ]
77 }
Michael Spangefa630b2020-07-08 22:23:08 -040078 }
79
80 if (chip_build_tests) {
81 import("${chip_root}/gn/chip/chip_test_group.gni")
82
83 chip_test_group("tests") {
84 deps = [
Michael Spangefa630b2020-07-08 22:23:08 -040085 "${chip_root}/src/ble/tests",
86 "${chip_root}/src/crypto/tests",
87 "${chip_root}/src/inet/tests",
88 "${chip_root}/src/lib/core/tests",
Martin Turonf3d80ff2020-07-20 11:10:38 -070089 "${chip_root}/src/lib/shell/tests",
Michael Spangfa6b5222020-08-17 12:54:40 -040090 "${chip_root}/src/lib/support/tests",
Michael Spangefa630b2020-07-08 22:23:08 -040091 "${chip_root}/src/lwip/tests",
Michael Spang8d085b32020-07-10 10:26:23 -040092 "${chip_root}/src/platform/tests",
Michael Spangefa630b2020-07-08 22:23:08 -040093 "${chip_root}/src/setup_payload/tests",
94 "${chip_root}/src/system/tests",
95 "${chip_root}/src/transport/tests",
96 ]
97 }
98
99 group("check") {
100 deps = [ ":tests_run" ]
101 }
102 }
103} else {
Michael Spangf1af8fc2020-07-29 14:25:47 -0400104 # This is the unified build. Configure various real toolchains.
Michael Spangefa630b2020-07-08 22:23:08 -0400105 import("${chip_root}/gn/chip/chip_build.gni")
106 declare_args() {
107 # Set this to false to disable all builds by default.
108 enable_default_builds = true
Michael Spang8d085b32020-07-10 10:26:23 -0400109
Michael Spangfdc49a32020-09-03 18:33:20 -0400110 # Enable building for Android.
111 enable_android_builds = false
112
Michael Spang8d085b32020-07-10 10:26:23 -0400113 # Set this to true to enable nRF5 builds by default.
114 enable_nrf5_builds = false
jepenven-silabscec75ca2020-08-04 09:38:48 -0400115
116 # Set this to true to enable efr32 builds by default.
117 enable_efr32_builds = false
Michael Spangefa630b2020-07-08 22:23:08 -0400118 }
119
120 declare_args() {
121 # Enable building chip with clang.
122 enable_host_clang_build = enable_default_builds
123
124 # Enable building chip with gcc.
125 enable_host_gcc_build = enable_default_builds
126
Michael Spanga964fad2020-07-13 09:36:00 -0400127 # Enable building chip with gcc & mbedtls.
128 enable_host_gcc_mbedtls_build = enable_default_builds
129
130 # Enable building chip for linux embedded.
131 enable_linux_embedded_build = enable_default_builds && host_os == "linux"
Michael Spangefa630b2020-07-08 22:23:08 -0400132
Michael Spang8d085b32020-07-10 10:26:23 -0400133 # Build the chip-tool example.
134 enable_standalone_chip_tool_build = enable_default_builds
135
136 # Build the shell example.
137 enable_standalone_shell_build = enable_default_builds
138
Michael Spangefa630b2020-07-08 22:23:08 -0400139 # Build the nRF5 lock app example.
Michael Spang8d085b32020-07-10 10:26:23 -0400140 enable_nrf5_lock_app_build = enable_nrf5_builds
141
142 # Build the nRF5 lighting app example.
143 enable_nrf5_lighting_app_build = enable_nrf5_builds
jepenven-silabscec75ca2020-08-04 09:38:48 -0400144
145 # Build the efr32 lock app example.
146 enable_efr32_lock_app_build = enable_efr32_builds
Michael Spangefa630b2020-07-08 22:23:08 -0400147 }
148
Michael Spangefa630b2020-07-08 22:23:08 -0400149 chip_build("host_clang") {
Michael Spang8d085b32020-07-10 10:26:23 -0400150 toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang"
Michael Spangefa630b2020-07-08 22:23:08 -0400151 }
152
153 chip_build("host_gcc") {
Michael Spang8d085b32020-07-10 10:26:23 -0400154 toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc"
Michael Spangefa630b2020-07-08 22:23:08 -0400155 }
156
157 chip_build("host_gcc_mbedtls") {
Michael Spang8d085b32020-07-10 10:26:23 -0400158 toolchain = "${chip_root}/config/mbedtls/toolchain:${host_os}_${host_cpu}_gcc_mbedtls"
159 }
160
Michael Spangfdc49a32020-09-03 18:33:20 -0400161 if (enable_android_builds) {
162 chip_build("android_arm") {
163 toolchain = "//build/toolchain/android:android_arm"
164 }
165
166 chip_build("android_arm64") {
167 toolchain = "//build/toolchain/android:android_arm64"
168 }
169
170 chip_build("android_x64") {
171 toolchain = "//build/toolchain/android:android_x64"
172 }
173
174 chip_build("android_x86") {
175 toolchain = "//build/toolchain/android:android_x86"
176 }
177 }
178
Michael Spanga964fad2020-07-13 09:36:00 -0400179 if (host_os == "linux") {
180 chip_build("linux_embedded") {
181 toolchain =
182 "${chip_root}/config/linux/toolchain:linux_${host_cpu}_gcc_embedded"
183 }
184 }
185
Michael Spang8d085b32020-07-10 10:26:23 -0400186 standalone_toolchain = "${chip_root}/config/standalone/toolchain:standalone"
187
188 group("standalone_chip_tool") {
189 deps = [ "${chip_root}/examples/chip-tool(${standalone_toolchain})" ]
190 }
191
192 group("standalone_shell") {
193 deps = [ "${chip_root}/examples/shell(${standalone_toolchain})" ]
194 }
195
196 if (enable_nrf5_lock_app_build) {
197 group("nrf5_lock_app") {
198 deps = [ "${chip_root}/examples/lock-app/nrf5(${chip_root}/config/nrf5/toolchain:nrf5_lock_app)" ]
199 }
200 }
201
202 if (enable_nrf5_lighting_app_build) {
203 group("nrf5_lighting_app") {
204 deps = [ "${chip_root}/examples/lighting-app/nrf5(${chip_root}/config/nrf5/toolchain:nrf5_lighting_app)" ]
205 }
Michael Spangefa630b2020-07-08 22:23:08 -0400206 }
207
jepenven-silabscec75ca2020-08-04 09:38:48 -0400208 if (enable_efr32_lock_app_build) {
209 group("efr32_lock_app") {
210 deps = [ "${chip_root}/examples/lock-app/efr32(${chip_root}/config/efr32/toolchain:efr32_lock_app)" ]
211 }
212 }
213
Michael Spangefa630b2020-07-08 22:23:08 -0400214 group("default") {
215 deps = []
216 if (enable_host_clang_build) {
217 deps += [ ":all_host_clang" ]
218 }
219 if (enable_host_gcc_build) {
220 deps += [ ":all_host_gcc" ]
221 }
Michael Spanga964fad2020-07-13 09:36:00 -0400222 if (enable_host_gcc_mbedtls_build) {
Michael Spangefa630b2020-07-08 22:23:08 -0400223 deps += [ ":all_host_gcc_mbedtls" ]
224 }
Michael Spangfdc49a32020-09-03 18:33:20 -0400225 if (enable_android_builds) {
226 deps += [
227 ":all_android_arm",
228 ":all_android_arm64",
229 ":all_android_x64",
230 ":all_android_x86",
231 ]
232 }
Michael Spanga964fad2020-07-13 09:36:00 -0400233 if (enable_linux_embedded_build) {
234 deps += [ ":all_linux_embedded" ]
235 }
Michael Spang8d085b32020-07-10 10:26:23 -0400236 if (enable_standalone_chip_tool_build) {
237 deps += [ ":standalone_chip_tool" ]
238 }
239 if (enable_standalone_shell_build) {
240 deps += [ ":standalone_shell" ]
241 }
Michael Spangefa630b2020-07-08 22:23:08 -0400242 if (enable_nrf5_lock_app_build) {
Michael Spang8d085b32020-07-10 10:26:23 -0400243 deps += [ ":nrf5_lock_app" ]
244 }
245 if (enable_nrf5_lighting_app_build) {
246 deps += [ ":nrf5_lighting_app" ]
Michael Spangefa630b2020-07-08 22:23:08 -0400247 }
jepenven-silabscec75ca2020-08-04 09:38:48 -0400248 if (enable_efr32_lock_app_build) {
249 deps += [ ":efr32_lock_app" ]
250 }
Michael Spangefa630b2020-07-08 22:23:08 -0400251 }
252
253 if (chip_build_tests) {
254 group("check") {
255 deps = []
256 if (enable_host_clang_build) {
257 deps += [ ":check_host_clang" ]
258 }
259 if (enable_host_gcc_build) {
260 deps += [ ":check_host_gcc" ]
261 }
Michael Spanga964fad2020-07-13 09:36:00 -0400262 if (enable_host_gcc_mbedtls_build) {
Michael Spangefa630b2020-07-08 22:23:08 -0400263 deps += [ ":check_host_gcc_mbedtls" ]
264 }
Michael Spanga964fad2020-07-13 09:36:00 -0400265 if (enable_linux_embedded_build) {
266 deps += [ ":check_linux_embedded" ]
267 }
Michael Spangefa630b2020-07-08 22:23:08 -0400268 }
269 }
270}