1 # Copyright (c) 2020 Project CHIP Authors
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 import("//build_overrides/chip.gni")
18 import("//build_overrides/mbedtls.gni")
19 import("//build_overrides/nlassert.gni")
20 import("//build_overrides/nlio.gni")
21 import("//build_overrides/nlunit_test.gni")
22 import("//build_overrides/pigweed.gni")
24 # This build file should not be used in superproject builds.
25 assert(chip_root == "//")
27 import("${chip_root}/build/chip/tests.gni")
28 import("${chip_root}/build/chip/tools.gni")
30 if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
32 chip_enable_python_modules =
33 (current_os == "mac" || current_os == "linux") && host_cpu == "x64"
36 # This is a real toolchain. Build CHIP.
43 "${chip_root}/src/app",
44 "${chip_root}/src/ble",
45 "${chip_root}/src/controller",
46 "${chip_root}/src/crypto",
47 "${chip_root}/src/inet",
48 "${chip_root}/src/lib",
49 "${chip_root}/src/lib/asn1",
50 "${chip_root}/src/lib/core",
51 "${chip_root}/src/lib/shell",
52 "${chip_root}/src/lib/support",
53 "${chip_root}/src/lwip:all",
54 "${chip_root}/src/messaging",
55 "${chip_root}/src/protocols",
56 "${chip_root}/src/setup_payload",
57 "${chip_root}/src/system",
58 "${chip_root}/src/transport",
59 "${mbedtls_root}:mbedtls",
60 "${nlassert_root}:nlassert",
62 "${nlunit_test_root}:nlunit-test",
65 if (chip_build_tests) {
66 deps += [ "//src:tests" ]
69 if (chip_build_tools) {
71 "${chip_root}/examples/shell/standalone:chip-shell",
72 "${chip_root}/src/qrcodetool",
73 "${chip_root}/src/setup_payload",
75 if (chip_enable_python_modules) {
76 deps += [ "${chip_root}/src/controller/python" ]
80 if (current_os == "android") {
82 "${chip_root}/src/controller/java",
83 "${chip_root}/src/setup_payload/java",
88 "${chip_root}/examples/all-clusters-app/linux",
89 "${chip_root}/examples/lighting-app/linux",
90 "${chip_root}/examples/chip-tool",
91 "${chip_root}/examples/minimal-mdns:minimal-mdns-client",
92 "${chip_root}/examples/minimal-mdns:minimal-mdns-server",
93 "${chip_root}/examples/minimal-mdns:mdns-advertiser",
98 if (chip_link_tests) {
99 deps = [ "//src:tests_run" ]
103 # We don't always want to run happy tests, make them a seperate group.
104 if (chip_enable_happy_tests) {
105 group("happy_tests") {
106 if (chip_link_tests) {
107 deps = [ "//src:happy_tests" ]
112 # This is the unified build. Configure various real toolchains.
113 import("${chip_root}/build/chip/chip_build.gni")
115 # Set this to false to disable all builds by default.
116 enable_default_builds = true
118 # Enable building for Android.
119 enable_android_builds = false
121 # Set this to true to enable efr32 builds by default.
122 enable_efr32_builds = false
124 # Set this to true to enable qpg6100 builds by default.
125 enable_qpg6100_builds = false
127 # Set this to true to enable k32w builds by default.
128 enable_k32w_builds = false
132 # Enable building chip with clang.
133 enable_host_clang_build = enable_default_builds
135 # Enable building chip with gcc.
136 enable_host_gcc_build = enable_default_builds
138 # Enable building chip with gcc & mbedtls.
139 enable_host_gcc_mbedtls_build = enable_default_builds
141 # Build the chip-tool example.
142 enable_standalone_chip_tool_build = enable_default_builds
144 # Build the shell example.
145 enable_standalone_shell_build = enable_default_builds
147 # Build the Linux all clusters app example.
148 enable_linux_all_clusters_app_build =
149 enable_default_builds && host_os == "linux"
151 # Build the Linux lighting app example.
152 enable_linux_lighting_app_build =
153 enable_default_builds && host_os == "linux"
155 # Build the efr32 lock app example.
156 enable_efr32_lock_app_build = enable_efr32_builds
158 # Build the qpg6100 lock app example.
159 enable_qpg6100_lock_app_build = enable_qpg6100_builds
161 # Build the efr32 lighting app example.
162 enable_efr32_lighting_app_build = enable_efr32_builds
164 # Build the k32w lock app example.
165 enable_k32w_lock_app_build = enable_k32w_builds
168 if (enable_host_clang_build) {
169 chip_build("host_clang") {
170 toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang"
174 if (enable_host_gcc_build) {
175 chip_build("host_gcc") {
176 toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc"
180 if (enable_host_gcc_mbedtls_build) {
181 chip_build("host_gcc_mbedtls") {
182 toolchain = "${chip_root}/config/mbedtls/toolchain:${host_os}_${host_cpu}_gcc_mbedtls"
186 if (enable_android_builds) {
187 chip_build("android_arm") {
188 toolchain = "//build/toolchain/android:android_arm"
191 chip_build("android_arm64") {
192 toolchain = "//build/toolchain/android:android_arm64"
195 chip_build("android_x64") {
196 toolchain = "//build/toolchain/android:android_x64"
199 chip_build("android_x86") {
200 toolchain = "//build/toolchain/android:android_x86"
204 standalone_toolchain = "${chip_root}/config/standalone/toolchain:standalone"
206 if (enable_standalone_chip_tool_build) {
207 group("standalone_chip_tool") {
208 deps = [ "${chip_root}/examples/chip-tool(${standalone_toolchain})" ]
212 if (enable_standalone_shell_build) {
213 group("standalone_shell") {
215 [ "${chip_root}/examples/shell/standalone(${standalone_toolchain})" ]
219 if (enable_linux_all_clusters_app_build) {
220 group("linux_all_clusters_app") {
222 "${chip_root}/examples/all-clusters-app/linux(${standalone_toolchain})",
227 if (enable_linux_lighting_app_build) {
228 group("linux_lighting_app") {
230 "${chip_root}/examples/lighting-app/linux(${standalone_toolchain})",
235 if (enable_efr32_lock_app_build) {
236 group("efr32_lock_app") {
237 deps = [ "${chip_root}/examples/lock-app/efr32(${chip_root}/config/efr32/toolchain:efr32_lock_app)" ]
241 if (enable_qpg6100_lock_app_build) {
242 group("qpg6100_lock_app") {
243 deps = [ "${chip_root}/examples/lock-app/qpg6100(${chip_root}/config/qpg6100/toolchain:qpg6100_lock_app)" ]
247 if (enable_efr32_lighting_app_build) {
248 group("efr32_lighting_app") {
249 deps = [ "${chip_root}/examples/lighting-app/efr32(${chip_root}/config/efr32/toolchain:efr32_lighting_app)" ]
253 if (enable_k32w_lock_app_build) {
254 group("k32w_lock_app") {
255 deps = [ "${chip_root}/examples/lock-app/k32w(${chip_root}/config/k32w/toolchain:k32w_lock_app)" ]
261 if (enable_host_clang_build) {
262 deps += [ ":all_host_clang" ]
264 if (enable_host_gcc_build) {
265 deps += [ ":all_host_gcc" ]
267 if (enable_host_gcc_mbedtls_build) {
268 deps += [ ":all_host_gcc_mbedtls" ]
270 if (enable_android_builds) {
273 ":all_android_arm64",
278 if (enable_standalone_chip_tool_build) {
279 deps += [ ":standalone_chip_tool" ]
281 if (enable_standalone_shell_build) {
282 deps += [ ":standalone_shell" ]
284 if (enable_linux_all_clusters_app_build) {
285 deps += [ ":linux_all_clusters_app" ]
287 if (enable_linux_lighting_app_build) {
288 deps += [ ":linux_lighting_app" ]
290 if (enable_efr32_lock_app_build) {
291 deps += [ ":efr32_lock_app" ]
293 if (enable_k32w_lock_app_build) {
294 deps += [ ":k32w_lock_app" ]
300 if (enable_host_clang_build) {
301 deps += [ ":check_host_clang" ]
303 if (enable_host_gcc_build) {
304 deps += [ ":check_host_gcc" ]
306 if (enable_host_gcc_mbedtls_build) {
307 deps += [ ":check_host_gcc_mbedtls" ]