blob: 22ff9f3939cce9252e53815c9148fafc1656bd14 [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")
szatmz2244db62020-12-04 14:42:01 -050021import("$dir_pw_build/python.gni")
Michael Spangefa630b2020-07-08 22:23:08 -040022
23# This build file should not be used in superproject builds.
24assert(chip_root == "//")
25
Michael Spang55d6a5f2020-10-07 00:43:56 -040026import("${chip_root}/build/chip/tests.gni")
27import("${chip_root}/build/chip/tools.gni")
Michael Spangefa630b2020-07-08 22:23:08 -040028
29if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
Andrei Litvin2d863492020-10-02 17:28:58 -040030 declare_args() {
Michael Spang4833d9c2020-10-09 09:33:02 -040031 chip_enable_python_modules =
Song Guod652be42020-11-11 00:34:35 +080032 (current_os == "mac" || current_os == "linux") &&
33 (host_cpu == "x64" || host_cpu == "arm64")
Andrei Litvin2d863492020-10-02 17:28:58 -040034 }
35
szatmz2244db62020-12-04 14:42:01 -050036 # Python packages for supporting specific targets.
37 pw_python_group("python_packages") {
38 python_deps = [
39 "integrations/mobly:chip_mobly",
40 "third_party/happy",
41 ]
42 }
43
Michael Spangefa630b2020-07-08 22:23:08 -040044 # This is a real toolchain. Build CHIP.
45 group("default") {
Michael Spangefa630b2020-07-08 22:23:08 -040046 deps = [
47 "${chip_root}/src/app",
48 "${chip_root}/src/ble",
49 "${chip_root}/src/controller",
50 "${chip_root}/src/crypto",
51 "${chip_root}/src/inet",
52 "${chip_root}/src/lib",
Evgeny Margolisdf862122020-10-22 07:47:27 -070053 "${chip_root}/src/lib/asn1",
Michael Spangefa630b2020-07-08 22:23:08 -040054 "${chip_root}/src/lib/core",
Michael Spang8d085b32020-07-10 10:26:23 -040055 "${chip_root}/src/lib/shell",
Michael Spangefa630b2020-07-08 22:23:08 -040056 "${chip_root}/src/lib/support",
57 "${chip_root}/src/lwip:all",
Yufeng Wang4fc19f12020-10-22 16:14:32 -070058 "${chip_root}/src/messaging",
Yufeng Wanga3d40542020-11-04 13:12:48 -080059 "${chip_root}/src/protocols",
Rob Walkerb14e3e32020-08-20 13:59:22 -070060 "${chip_root}/src/setup_payload",
Michael Spangefa630b2020-07-08 22:23:08 -040061 "${chip_root}/src/system",
62 "${chip_root}/src/transport",
63 "${mbedtls_root}:mbedtls",
64 "${nlassert_root}:nlassert",
65 "${nlio_root}:nlio",
66 "${nlunit_test_root}:nlunit-test",
67 ]
68
69 if (chip_build_tests) {
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +020070 deps += [ "//src:tests" ]
Michael Spangefa630b2020-07-08 22:23:08 -040071 }
72
73 if (chip_build_tools) {
74 deps += [
Timothy Maes9e1ac482020-10-29 17:59:49 +010075 "${chip_root}/examples/shell/standalone:chip-shell",
Yufeng Wang4282a072020-12-08 08:58:46 -080076 "${chip_root}/src/messaging/tests/echo:chip-echo-requester",
77 "${chip_root}/src/messaging/tests/echo:chip-echo-responder",
Michael Spangefa630b2020-07-08 22:23:08 -040078 "${chip_root}/src/qrcodetool",
79 "${chip_root}/src/setup_payload",
80 ]
Andrei Litvin2d863492020-10-02 17:28:58 -040081 if (chip_enable_python_modules) {
yunhanw-google90ea3142020-10-01 13:53:26 -070082 deps += [ "${chip_root}/src/controller/python" ]
83 }
Michael Spangefa630b2020-07-08 22:23:08 -040084 }
Andrei Litvind74a0b62020-08-30 19:58:00 -040085
86 if (current_os == "android") {
87 deps += [
88 "${chip_root}/src/controller/java",
89 "${chip_root}/src/setup_payload/java",
90 ]
91 }
Michael Spangefa630b2020-07-08 22:23:08 -040092 }
93
Michael Spangdf712982020-09-18 10:39:35 -040094 group("check") {
95 if (chip_link_tests) {
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +020096 deps = [ "//src:tests_run" ]
Michael Spangefa630b2020-07-08 22:23:08 -040097 }
98 }
Song Guo30123da2020-10-13 19:30:39 +080099
100 # We don't always want to run happy tests, make them a seperate group.
Michael Spang60a28072020-10-13 11:03:21 -0400101 if (chip_enable_happy_tests) {
102 group("happy_tests") {
103 if (chip_link_tests) {
104 deps = [ "//src:happy_tests" ]
105 }
Song Guo30123da2020-10-13 19:30:39 +0800106 }
107 }
Michael Spangefa630b2020-07-08 22:23:08 -0400108} else {
Michael Spangf1af8fc2020-07-29 14:25:47 -0400109 # This is the unified build. Configure various real toolchains.
Michael Spang55d6a5f2020-10-07 00:43:56 -0400110 import("${chip_root}/build/chip/chip_build.gni")
Michael Spangefa630b2020-07-08 22:23:08 -0400111 declare_args() {
112 # Set this to false to disable all builds by default.
113 enable_default_builds = true
Michael Spang8d085b32020-07-10 10:26:23 -0400114
Michael Spangfdc49a32020-09-03 18:33:20 -0400115 # Enable building for Android.
116 enable_android_builds = false
117
jepenven-silabscec75ca2020-08-04 09:38:48 -0400118 # Set this to true to enable efr32 builds by default.
119 enable_efr32_builds = false
Timothy Maesb5b3d382020-10-05 16:59:21 +0200120
121 # Set this to true to enable qpg6100 builds by default.
122 enable_qpg6100_builds = false
doru9104ac26b2020-10-13 18:23:28 +0300123
124 # Set this to true to enable k32w builds by default.
125 enable_k32w_builds = false
Michael Spangefa630b2020-07-08 22:23:08 -0400126 }
127
128 declare_args() {
129 # Enable building chip with clang.
130 enable_host_clang_build = enable_default_builds
131
132 # Enable building chip with gcc.
133 enable_host_gcc_build = enable_default_builds
134
Michael Spanga964fad2020-07-13 09:36:00 -0400135 # Enable building chip with gcc & mbedtls.
136 enable_host_gcc_mbedtls_build = enable_default_builds
137
Michael Spang8d085b32020-07-10 10:26:23 -0400138 # Build the chip-tool example.
139 enable_standalone_chip_tool_build = enable_default_builds
140
141 # Build the shell example.
142 enable_standalone_shell_build = enable_default_builds
143
Vivien Nicolas280d80f2020-11-06 22:56:40 +0100144 # Build the Linux all clusters app example.
145 enable_linux_all_clusters_app_build =
Vivien Nicolas1b296552020-12-07 18:24:57 +0100146 enable_default_builds && (host_os == "linux" || host_os == "mac")
Vivien Nicolas280d80f2020-11-06 22:56:40 +0100147
Michael Spang7c8f19b2020-11-02 13:05:12 -0500148 # Build the Linux lighting app example.
149 enable_linux_lighting_app_build =
Vivien Nicolas1b296552020-12-07 18:24:57 +0100150 enable_default_builds && (host_os == "linux" || host_os == "mac")
Michael Spang7c8f19b2020-11-02 13:05:12 -0500151
jepenven-silabscec75ca2020-08-04 09:38:48 -0400152 # Build the efr32 lock app example.
153 enable_efr32_lock_app_build = enable_efr32_builds
Michael Spang02413732020-09-24 09:45:17 -0400154
Timothy Maesb5b3d382020-10-05 16:59:21 +0200155 # Build the qpg6100 lock app example.
156 enable_qpg6100_lock_app_build = enable_qpg6100_builds
157
Michael Spang02413732020-09-24 09:45:17 -0400158 # Build the efr32 lighting app example.
159 enable_efr32_lighting_app_build = enable_efr32_builds
doru9104ac26b2020-10-13 18:23:28 +0300160
161 # Build the k32w lock app example.
162 enable_k32w_lock_app_build = enable_k32w_builds
Michael Spangefa630b2020-07-08 22:23:08 -0400163 }
164
Michael Spang7c8f19b2020-11-02 13:05:12 -0500165 if (enable_host_clang_build) {
166 chip_build("host_clang") {
167 toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang"
168 }
Michael Spangefa630b2020-07-08 22:23:08 -0400169 }
170
Michael Spang7c8f19b2020-11-02 13:05:12 -0500171 if (enable_host_gcc_build) {
172 chip_build("host_gcc") {
173 toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc"
174 }
Michael Spangefa630b2020-07-08 22:23:08 -0400175 }
176
Michael Spang7c8f19b2020-11-02 13:05:12 -0500177 if (enable_host_gcc_mbedtls_build) {
178 chip_build("host_gcc_mbedtls") {
179 toolchain = "${chip_root}/config/mbedtls/toolchain:${host_os}_${host_cpu}_gcc_mbedtls"
180 }
Michael Spang8d085b32020-07-10 10:26:23 -0400181 }
182
Michael Spangfdc49a32020-09-03 18:33:20 -0400183 if (enable_android_builds) {
184 chip_build("android_arm") {
185 toolchain = "//build/toolchain/android:android_arm"
186 }
187
188 chip_build("android_arm64") {
189 toolchain = "//build/toolchain/android:android_arm64"
190 }
191
192 chip_build("android_x64") {
193 toolchain = "//build/toolchain/android:android_x64"
194 }
195
196 chip_build("android_x86") {
197 toolchain = "//build/toolchain/android:android_x86"
198 }
199 }
200
Michael Spang8d085b32020-07-10 10:26:23 -0400201 standalone_toolchain = "${chip_root}/config/standalone/toolchain:standalone"
202
Michael Spang7c8f19b2020-11-02 13:05:12 -0500203 if (enable_standalone_chip_tool_build) {
204 group("standalone_chip_tool") {
205 deps = [ "${chip_root}/examples/chip-tool(${standalone_toolchain})" ]
206 }
Michael Spang8d085b32020-07-10 10:26:23 -0400207 }
208
Michael Spang7c8f19b2020-11-02 13:05:12 -0500209 if (enable_standalone_shell_build) {
210 group("standalone_shell") {
211 deps =
212 [ "${chip_root}/examples/shell/standalone(${standalone_toolchain})" ]
213 }
214 }
215
Vivien Nicolas280d80f2020-11-06 22:56:40 +0100216 if (enable_linux_all_clusters_app_build) {
217 group("linux_all_clusters_app") {
218 deps = [
219 "${chip_root}/examples/all-clusters-app/linux(${standalone_toolchain})",
220 ]
221 }
222 }
223
Michael Spang7c8f19b2020-11-02 13:05:12 -0500224 if (enable_linux_lighting_app_build) {
225 group("linux_lighting_app") {
226 deps = [
227 "${chip_root}/examples/lighting-app/linux(${standalone_toolchain})",
228 ]
229 }
Michael Spang8d085b32020-07-10 10:26:23 -0400230 }
231
jepenven-silabscec75ca2020-08-04 09:38:48 -0400232 if (enable_efr32_lock_app_build) {
233 group("efr32_lock_app") {
234 deps = [ "${chip_root}/examples/lock-app/efr32(${chip_root}/config/efr32/toolchain:efr32_lock_app)" ]
235 }
236 }
237
Timothy Maesb5b3d382020-10-05 16:59:21 +0200238 if (enable_qpg6100_lock_app_build) {
239 group("qpg6100_lock_app") {
240 deps = [ "${chip_root}/examples/lock-app/qpg6100(${chip_root}/config/qpg6100/toolchain:qpg6100_lock_app)" ]
241 }
242 }
243
Michael Spang02413732020-09-24 09:45:17 -0400244 if (enable_efr32_lighting_app_build) {
245 group("efr32_lighting_app") {
246 deps = [ "${chip_root}/examples/lighting-app/efr32(${chip_root}/config/efr32/toolchain:efr32_lighting_app)" ]
247 }
248 }
249
doru9104ac26b2020-10-13 18:23:28 +0300250 if (enable_k32w_lock_app_build) {
251 group("k32w_lock_app") {
252 deps = [ "${chip_root}/examples/lock-app/k32w(${chip_root}/config/k32w/toolchain:k32w_lock_app)" ]
253 }
254 }
255
Michael Spangefa630b2020-07-08 22:23:08 -0400256 group("default") {
257 deps = []
258 if (enable_host_clang_build) {
Michael Spangb1139f72020-12-01 16:06:36 -0500259 deps += [ ":host_clang" ]
Michael Spangefa630b2020-07-08 22:23:08 -0400260 }
261 if (enable_host_gcc_build) {
Michael Spangb1139f72020-12-01 16:06:36 -0500262 deps += [ ":host_gcc" ]
Michael Spangefa630b2020-07-08 22:23:08 -0400263 }
Michael Spanga964fad2020-07-13 09:36:00 -0400264 if (enable_host_gcc_mbedtls_build) {
Michael Spangb1139f72020-12-01 16:06:36 -0500265 deps += [ ":host_gcc_mbedtls" ]
Michael Spangefa630b2020-07-08 22:23:08 -0400266 }
Michael Spangfdc49a32020-09-03 18:33:20 -0400267 if (enable_android_builds) {
268 deps += [
Michael Spangb1139f72020-12-01 16:06:36 -0500269 ":android_arm",
270 ":android_arm64",
271 ":android_x64",
272 ":android_x86",
Michael Spangfdc49a32020-09-03 18:33:20 -0400273 ]
274 }
Michael Spang8d085b32020-07-10 10:26:23 -0400275 if (enable_standalone_chip_tool_build) {
276 deps += [ ":standalone_chip_tool" ]
277 }
278 if (enable_standalone_shell_build) {
279 deps += [ ":standalone_shell" ]
280 }
Vivien Nicolas280d80f2020-11-06 22:56:40 +0100281 if (enable_linux_all_clusters_app_build) {
282 deps += [ ":linux_all_clusters_app" ]
283 }
Michael Spang7c8f19b2020-11-02 13:05:12 -0500284 if (enable_linux_lighting_app_build) {
285 deps += [ ":linux_lighting_app" ]
286 }
jepenven-silabscec75ca2020-08-04 09:38:48 -0400287 if (enable_efr32_lock_app_build) {
288 deps += [ ":efr32_lock_app" ]
289 }
doru9104ac26b2020-10-13 18:23:28 +0300290 if (enable_k32w_lock_app_build) {
291 deps += [ ":k32w_lock_app" ]
292 }
Michael Spangefa630b2020-07-08 22:23:08 -0400293 }
294
Michael Spangdf712982020-09-18 10:39:35 -0400295 group("check") {
296 deps = []
297 if (enable_host_clang_build) {
298 deps += [ ":check_host_clang" ]
299 }
300 if (enable_host_gcc_build) {
301 deps += [ ":check_host_gcc" ]
302 }
303 if (enable_host_gcc_mbedtls_build) {
304 deps += [ ":check_host_gcc_mbedtls" ]
Michael Spangefa630b2020-07-08 22:23:08 -0400305 }
306 }
307}