blob: d653baa0a2dc24c4fb576c736b25b06a4a659f95 [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
Łukasz Duda4e1faf22021-01-27 17:47:25 +010015import("//build_overrides/build.gni")
Michael Spangefa630b2020-07-08 22:23:08 -040016import("//build_overrides/chip.gni")
17import("//build_overrides/mbedtls.gni")
18import("//build_overrides/nlassert.gni")
19import("//build_overrides/nlio.gni")
20import("//build_overrides/nlunit_test.gni")
21import("//build_overrides/pigweed.gni")
Łukasz Duda4e1faf22021-01-27 17:47:25 +010022
Kamil Kasperczykd05149c2021-01-05 16:05:27 +010023import("//src/platform/device.gni")
szatmz2244db62020-12-04 14:42:01 -050024import("$dir_pw_build/python.gni")
Michael Spangefa630b2020-07-08 22:23:08 -040025
26# This build file should not be used in superproject builds.
27assert(chip_root == "//")
28
Łukasz Duda4e1faf22021-01-27 17:47:25 +010029import("${build_root}/chip/tests.gni")
30import("${build_root}/chip/tools.gni")
Michael Spangefa630b2020-07-08 22:23:08 -040031
32if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
Andrei Litvin2d863492020-10-02 17:28:58 -040033 declare_args() {
Michael Spang4833d9c2020-10-09 09:33:02 -040034 chip_enable_python_modules =
Song Guod652be42020-11-11 00:34:35 +080035 (current_os == "mac" || current_os == "linux") &&
36 (host_cpu == "x64" || host_cpu == "arm64")
Andrei Litvin2d863492020-10-02 17:28:58 -040037 }
38
szatmz2244db62020-12-04 14:42:01 -050039 # Python packages for supporting specific targets.
40 pw_python_group("python_packages") {
41 python_deps = [
42 "integrations/mobly:chip_mobly",
43 "third_party/happy",
44 ]
45 }
46
Michael Spangefa630b2020-07-08 22:23:08 -040047 # This is a real toolchain. Build CHIP.
48 group("default") {
Michael Spangefa630b2020-07-08 22:23:08 -040049 deps = [
50 "${chip_root}/src/app",
51 "${chip_root}/src/ble",
52 "${chip_root}/src/controller",
Evgeny Margolis53538582021-01-12 09:14:24 -080053 "${chip_root}/src/credentials",
Michael Spangefa630b2020-07-08 22:23:08 -040054 "${chip_root}/src/crypto",
55 "${chip_root}/src/inet",
56 "${chip_root}/src/lib",
Evgeny Margolisdf862122020-10-22 07:47:27 -070057 "${chip_root}/src/lib/asn1",
Michael Spangefa630b2020-07-08 22:23:08 -040058 "${chip_root}/src/lib/core",
Michael Spang8d085b32020-07-10 10:26:23 -040059 "${chip_root}/src/lib/shell",
Michael Spangefa630b2020-07-08 22:23:08 -040060 "${chip_root}/src/lib/support",
61 "${chip_root}/src/lwip:all",
Yufeng Wang4fc19f12020-10-22 16:14:32 -070062 "${chip_root}/src/messaging",
Yufeng Wanga3d40542020-11-04 13:12:48 -080063 "${chip_root}/src/protocols",
Rob Walkerb14e3e32020-08-20 13:59:22 -070064 "${chip_root}/src/setup_payload",
Michael Spangefa630b2020-07-08 22:23:08 -040065 "${chip_root}/src/system",
66 "${chip_root}/src/transport",
67 "${mbedtls_root}:mbedtls",
68 "${nlassert_root}:nlassert",
69 "${nlio_root}:nlio",
70 "${nlunit_test_root}:nlunit-test",
71 ]
72
Kamil Kasperczykd05149c2021-01-05 16:05:27 +010073 if (chip_device_platform != "none") {
74 deps += [ "${chip_root}/src/app/server" ]
75 }
76
Michael Spangefa630b2020-07-08 22:23:08 -040077 if (chip_build_tests) {
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +020078 deps += [ "//src:tests" ]
Michael Spangefa630b2020-07-08 22:23:08 -040079 }
80
81 if (chip_build_tools) {
82 deps += [
Timothy Maes9e1ac482020-10-29 17:59:49 +010083 "${chip_root}/examples/shell/standalone:chip-shell",
yunhanw-googlee430b1d2021-01-06 06:12:46 -080084 "${chip_root}/src/app/tests/integration:chip-im-initiator",
85 "${chip_root}/src/app/tests/integration:chip-im-responder",
Yufeng Wang4282a072020-12-08 08:58:46 -080086 "${chip_root}/src/messaging/tests/echo:chip-echo-requester",
87 "${chip_root}/src/messaging/tests/echo:chip-echo-responder",
Michael Spangefa630b2020-07-08 22:23:08 -040088 "${chip_root}/src/qrcodetool",
89 "${chip_root}/src/setup_payload",
90 ]
Andrei Litvin2d863492020-10-02 17:28:58 -040091 if (chip_enable_python_modules) {
yunhanw-google90ea3142020-10-01 13:53:26 -070092 deps += [ "${chip_root}/src/controller/python" ]
93 }
Michael Spangefa630b2020-07-08 22:23:08 -040094 }
Andrei Litvind74a0b62020-08-30 19:58:00 -040095
96 if (current_os == "android") {
97 deps += [
98 "${chip_root}/src/controller/java",
99 "${chip_root}/src/setup_payload/java",
100 ]
101 }
Michael Spangefa630b2020-07-08 22:23:08 -0400102 }
103
Michael Spangdf712982020-09-18 10:39:35 -0400104 group("check") {
105 if (chip_link_tests) {
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +0200106 deps = [ "//src:tests_run" ]
Michael Spangefa630b2020-07-08 22:23:08 -0400107 }
108 }
Song Guo30123da2020-10-13 19:30:39 +0800109
110 # We don't always want to run happy tests, make them a seperate group.
Michael Spang60a28072020-10-13 11:03:21 -0400111 if (chip_enable_happy_tests) {
112 group("happy_tests") {
113 if (chip_link_tests) {
114 deps = [ "//src:happy_tests" ]
115 }
Song Guo30123da2020-10-13 19:30:39 +0800116 }
117 }
Michael Spangefa630b2020-07-08 22:23:08 -0400118} else {
Michael Spangf1af8fc2020-07-29 14:25:47 -0400119 # This is the unified build. Configure various real toolchains.
Łukasz Duda4e1faf22021-01-27 17:47:25 +0100120 import("${build_root}/chip/chip_build.gni")
Michael Spangefa630b2020-07-08 22:23:08 -0400121 declare_args() {
122 # Set this to false to disable all builds by default.
123 enable_default_builds = true
Michael Spang8d085b32020-07-10 10:26:23 -0400124
Michael Spangfdc49a32020-09-03 18:33:20 -0400125 # Enable building for Android.
126 enable_android_builds = false
127
Seth Rickard4f0521f2021-01-12 16:06:52 -0600128 # Set this to true to enable TI builds by default.
129 enable_cc13x2_26x2_builds = false
130
jepenven-silabscec75ca2020-08-04 09:38:48 -0400131 # Set this to true to enable efr32 builds by default.
132 enable_efr32_builds = false
Timothy Maesb5b3d382020-10-05 16:59:21 +0200133
134 # Set this to true to enable qpg6100 builds by default.
135 enable_qpg6100_builds = false
doru9104ac26b2020-10-13 18:23:28 +0300136
137 # Set this to true to enable k32w builds by default.
138 enable_k32w_builds = false
Michael Spangefa630b2020-07-08 22:23:08 -0400139 }
140
141 declare_args() {
142 # Enable building chip with clang.
Michael Spangcd0f6112021-01-22 17:06:25 -0500143 enable_host_clang_build = enable_default_builds && host_os != "win"
Michael Spangefa630b2020-07-08 22:23:08 -0400144
145 # Enable building chip with gcc.
Michael Spangcd0f6112021-01-22 17:06:25 -0500146 enable_host_gcc_build = enable_default_builds && host_os != "win"
Michael Spangefa630b2020-07-08 22:23:08 -0400147
Michael Spanga964fad2020-07-13 09:36:00 -0400148 # Enable building chip with gcc & mbedtls.
Michael Spangcd0f6112021-01-22 17:06:25 -0500149 enable_host_gcc_mbedtls_build = enable_default_builds && host_os != "win"
Michael Spanga964fad2020-07-13 09:36:00 -0400150
Michael Spang8d085b32020-07-10 10:26:23 -0400151 # Build the chip-tool example.
Michael Spangcd0f6112021-01-22 17:06:25 -0500152 enable_standalone_chip_tool_build =
153 enable_default_builds && host_os != "win"
Michael Spang8d085b32020-07-10 10:26:23 -0400154
155 # Build the shell example.
Michael Spangcd0f6112021-01-22 17:06:25 -0500156 enable_standalone_shell_build = enable_default_builds && host_os != "win"
Michael Spang8d085b32020-07-10 10:26:23 -0400157
Vivien Nicolas280d80f2020-11-06 22:56:40 +0100158 # Build the Linux all clusters app example.
159 enable_linux_all_clusters_app_build =
Vivien Nicolas1b296552020-12-07 18:24:57 +0100160 enable_default_builds && (host_os == "linux" || host_os == "mac")
Vivien Nicolas280d80f2020-11-06 22:56:40 +0100161
Michael Spang7c8f19b2020-11-02 13:05:12 -0500162 # Build the Linux lighting app example.
163 enable_linux_lighting_app_build =
Vivien Nicolas1b296552020-12-07 18:24:57 +0100164 enable_default_builds && (host_os == "linux" || host_os == "mac")
Michael Spang7c8f19b2020-11-02 13:05:12 -0500165
Seth Rickard4f0521f2021-01-12 16:06:52 -0600166 # Build the cc13x2_26x2 lock app example.
167 enable_cc13x2_26x2_lock_app_build = enable_cc13x2_26x2_builds
168
jepenven-silabscec75ca2020-08-04 09:38:48 -0400169 # Build the efr32 lock app example.
170 enable_efr32_lock_app_build = enable_efr32_builds
Michael Spang02413732020-09-24 09:45:17 -0400171
Timothy Maesb5b3d382020-10-05 16:59:21 +0200172 # Build the qpg6100 lock app example.
173 enable_qpg6100_lock_app_build = enable_qpg6100_builds
174
Michael Spang02413732020-09-24 09:45:17 -0400175 # Build the efr32 lighting app example.
176 enable_efr32_lighting_app_build = enable_efr32_builds
doru9104ac26b2020-10-13 18:23:28 +0300177
178 # Build the k32w lock app example.
179 enable_k32w_lock_app_build = enable_k32w_builds
Michael Spangefa630b2020-07-08 22:23:08 -0400180 }
181
Michael Spang7c8f19b2020-11-02 13:05:12 -0500182 if (enable_host_clang_build) {
183 chip_build("host_clang") {
Łukasz Duda4e1faf22021-01-27 17:47:25 +0100184 toolchain = "${build_root}/toolchain/host:${host_os}_${host_cpu}_clang"
Michael Spang7c8f19b2020-11-02 13:05:12 -0500185 }
Michael Spangefa630b2020-07-08 22:23:08 -0400186 }
187
Michael Spang7c8f19b2020-11-02 13:05:12 -0500188 if (enable_host_gcc_build) {
189 chip_build("host_gcc") {
Łukasz Duda4e1faf22021-01-27 17:47:25 +0100190 toolchain = "${build_root}/toolchain/host:${host_os}_${host_cpu}_gcc"
Michael Spang7c8f19b2020-11-02 13:05:12 -0500191 }
Michael Spangefa630b2020-07-08 22:23:08 -0400192 }
193
Michael Spang7c8f19b2020-11-02 13:05:12 -0500194 if (enable_host_gcc_mbedtls_build) {
195 chip_build("host_gcc_mbedtls") {
196 toolchain = "${chip_root}/config/mbedtls/toolchain:${host_os}_${host_cpu}_gcc_mbedtls"
197 }
Michael Spang8d085b32020-07-10 10:26:23 -0400198 }
199
Michael Spangfdc49a32020-09-03 18:33:20 -0400200 if (enable_android_builds) {
201 chip_build("android_arm") {
Łukasz Duda4e1faf22021-01-27 17:47:25 +0100202 toolchain = "${build_root}/toolchain/android:android_arm"
Michael Spangfdc49a32020-09-03 18:33:20 -0400203 }
204
205 chip_build("android_arm64") {
Łukasz Duda4e1faf22021-01-27 17:47:25 +0100206 toolchain = "${build_root}/toolchain/android:android_arm64"
Michael Spangfdc49a32020-09-03 18:33:20 -0400207 }
208
209 chip_build("android_x64") {
Łukasz Duda4e1faf22021-01-27 17:47:25 +0100210 toolchain = "${build_root}/toolchain/android:android_x64"
Michael Spangfdc49a32020-09-03 18:33:20 -0400211 }
212
213 chip_build("android_x86") {
Łukasz Duda4e1faf22021-01-27 17:47:25 +0100214 toolchain = "${build_root}/toolchain/android:android_x86"
Michael Spangfdc49a32020-09-03 18:33:20 -0400215 }
216 }
217
Michael Spang8d085b32020-07-10 10:26:23 -0400218 standalone_toolchain = "${chip_root}/config/standalone/toolchain:standalone"
Michael Spangf92b73d2021-01-05 10:31:03 -0500219 not_needed([ "standalone_toolchain" ]) # Might not be needed.
Michael Spang8d085b32020-07-10 10:26:23 -0400220
Michael Spang7c8f19b2020-11-02 13:05:12 -0500221 if (enable_standalone_chip_tool_build) {
222 group("standalone_chip_tool") {
223 deps = [ "${chip_root}/examples/chip-tool(${standalone_toolchain})" ]
224 }
Michael Spang8d085b32020-07-10 10:26:23 -0400225 }
226
Seth Rickard4f0521f2021-01-12 16:06:52 -0600227 if (enable_cc13x2_26x2_lock_app_build) {
228 group("cc13x2_26x2_lock_app") {
229 deps = [ "${chip_root}/examples/lock-app/cc13x2_26x2(${chip_root}/config/cc13x2_26x2/toolchain:cc13x2_26x2_lock_app)" ]
230 }
231 }
232
Michael Spang7c8f19b2020-11-02 13:05:12 -0500233 if (enable_standalone_shell_build) {
234 group("standalone_shell") {
235 deps =
236 [ "${chip_root}/examples/shell/standalone(${standalone_toolchain})" ]
237 }
238 }
239
Vivien Nicolas280d80f2020-11-06 22:56:40 +0100240 if (enable_linux_all_clusters_app_build) {
241 group("linux_all_clusters_app") {
242 deps = [
243 "${chip_root}/examples/all-clusters-app/linux(${standalone_toolchain})",
244 ]
245 }
246 }
247
Michael Spang7c8f19b2020-11-02 13:05:12 -0500248 if (enable_linux_lighting_app_build) {
249 group("linux_lighting_app") {
250 deps = [
251 "${chip_root}/examples/lighting-app/linux(${standalone_toolchain})",
252 ]
253 }
Michael Spang8d085b32020-07-10 10:26:23 -0400254 }
255
jepenven-silabscec75ca2020-08-04 09:38:48 -0400256 if (enable_efr32_lock_app_build) {
257 group("efr32_lock_app") {
258 deps = [ "${chip_root}/examples/lock-app/efr32(${chip_root}/config/efr32/toolchain:efr32_lock_app)" ]
259 }
260 }
261
Timothy Maesb5b3d382020-10-05 16:59:21 +0200262 if (enable_qpg6100_lock_app_build) {
263 group("qpg6100_lock_app") {
264 deps = [ "${chip_root}/examples/lock-app/qpg6100(${chip_root}/config/qpg6100/toolchain:qpg6100_lock_app)" ]
265 }
266 }
267
Michael Spang02413732020-09-24 09:45:17 -0400268 if (enable_efr32_lighting_app_build) {
269 group("efr32_lighting_app") {
270 deps = [ "${chip_root}/examples/lighting-app/efr32(${chip_root}/config/efr32/toolchain:efr32_lighting_app)" ]
271 }
272 }
273
doru9104ac26b2020-10-13 18:23:28 +0300274 if (enable_k32w_lock_app_build) {
275 group("k32w_lock_app") {
276 deps = [ "${chip_root}/examples/lock-app/k32w(${chip_root}/config/k32w/toolchain:k32w_lock_app)" ]
277 }
278 }
279
Michael Spangefa630b2020-07-08 22:23:08 -0400280 group("default") {
281 deps = []
282 if (enable_host_clang_build) {
Michael Spangb1139f72020-12-01 16:06:36 -0500283 deps += [ ":host_clang" ]
Michael Spangefa630b2020-07-08 22:23:08 -0400284 }
285 if (enable_host_gcc_build) {
Michael Spangb1139f72020-12-01 16:06:36 -0500286 deps += [ ":host_gcc" ]
Michael Spangefa630b2020-07-08 22:23:08 -0400287 }
Michael Spanga964fad2020-07-13 09:36:00 -0400288 if (enable_host_gcc_mbedtls_build) {
Michael Spangb1139f72020-12-01 16:06:36 -0500289 deps += [ ":host_gcc_mbedtls" ]
Michael Spangefa630b2020-07-08 22:23:08 -0400290 }
Michael Spangfdc49a32020-09-03 18:33:20 -0400291 if (enable_android_builds) {
292 deps += [
Michael Spangb1139f72020-12-01 16:06:36 -0500293 ":android_arm",
294 ":android_arm64",
295 ":android_x64",
296 ":android_x86",
Michael Spangfdc49a32020-09-03 18:33:20 -0400297 ]
298 }
Michael Spang8d085b32020-07-10 10:26:23 -0400299 if (enable_standalone_chip_tool_build) {
300 deps += [ ":standalone_chip_tool" ]
301 }
302 if (enable_standalone_shell_build) {
303 deps += [ ":standalone_shell" ]
304 }
Vivien Nicolas280d80f2020-11-06 22:56:40 +0100305 if (enable_linux_all_clusters_app_build) {
306 deps += [ ":linux_all_clusters_app" ]
307 }
Michael Spang7c8f19b2020-11-02 13:05:12 -0500308 if (enable_linux_lighting_app_build) {
309 deps += [ ":linux_lighting_app" ]
310 }
jepenven-silabscec75ca2020-08-04 09:38:48 -0400311 if (enable_efr32_lock_app_build) {
312 deps += [ ":efr32_lock_app" ]
313 }
Michael Spangf8dc12e2021-02-02 21:36:46 -0500314 if (enable_efr32_lighting_app_build) {
315 deps += [ ":efr32_lighting_app" ]
316 }
doru9104ac26b2020-10-13 18:23:28 +0300317 if (enable_k32w_lock_app_build) {
318 deps += [ ":k32w_lock_app" ]
319 }
Michael Spangf8dc12e2021-02-02 21:36:46 -0500320 if (enable_qpg6100_lock_app_build) {
321 deps += [ ":qpg6100_lock_app" ]
322 }
323 if (enable_cc13x2_26x2_lock_app_build) {
324 deps += [ ":cc13x2_26x2_lock_app" ]
325 }
Michael Spangefa630b2020-07-08 22:23:08 -0400326 }
327
Michael Spangdf712982020-09-18 10:39:35 -0400328 group("check") {
329 deps = []
330 if (enable_host_clang_build) {
331 deps += [ ":check_host_clang" ]
332 }
333 if (enable_host_gcc_build) {
334 deps += [ ":check_host_gcc" ]
335 }
336 if (enable_host_gcc_mbedtls_build) {
337 deps += [ ":check_host_gcc_mbedtls" ]
Michael Spangefa630b2020-07-08 22:23:08 -0400338 }
339 }
340}