Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / BUILD.gn
1 # 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
15 # TIZEN_CHIP_MODIFY
16
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")
23
24 # This build file should not be used in superproject builds.
25 assert(chip_root == "//")
26
27 import("${chip_root}/build/chip/tests.gni")
28 import("${chip_root}/build/chip/tools.gni")
29
30 if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
31   declare_args() {
32     chip_enable_python_modules = false
33   }
34
35   # This is a real toolchain. Build CHIP.
36   group("default") {
37     deps = [ ":all" ]
38   }
39
40   group("all") {
41     deps = [
42       "${chip_root}/src/app",
43       "${chip_root}/src/ble",
44       "${chip_root}/src/controller",
45       "${chip_root}/src/crypto",
46       "${chip_root}/src/inet",
47       "${chip_root}/src/lib",
48       "${chip_root}/src/lib/asn1",
49       "${chip_root}/src/lib/core",
50       "${chip_root}/src/lib/shell",
51       "${chip_root}/src/lib/support",
52       "${chip_root}/src/lwip:all",
53       "${chip_root}/src/messaging",
54       "${chip_root}/src/protocols",
55       "${chip_root}/src/setup_payload",
56       "${chip_root}/src/system",
57       "${chip_root}/src/transport",
58       "${mbedtls_root}:mbedtls",
59       "${nlassert_root}:nlassert",
60       "${nlio_root}:nlio",
61       "${nlunit_test_root}:nlunit-test",
62     ]
63
64     if (chip_build_tests) {
65       deps += [ "//src:tests" ]
66     }
67
68     if (chip_build_tools) {
69       deps += [
70         "${chip_root}/examples/shell/standalone:chip-shell",
71         "${chip_root}/src/qrcodetool",
72         "${chip_root}/src/setup_payload",
73       ]
74       if (chip_enable_python_modules) {
75         deps += [ "${chip_root}/src/controller/python" ]
76       }
77     }
78
79     if (current_os == "android") {
80       deps += [
81         "${chip_root}/src/controller/java",
82         "${chip_root}/src/setup_payload/java",
83       ]
84     }
85
86     deps += [
87       "${chip_root}/examples/all-clusters-app/linux",
88       "${chip_root}/examples/lighting-app/linux",
89       "${chip_root}/examples/chip-tool",
90       "${chip_root}/examples/minimal-mdns:minimal-mdns-client",
91       "${chip_root}/examples/minimal-mdns:minimal-mdns-server",
92       "${chip_root}/examples/minimal-mdns:mdns-advertiser",
93     ]
94   }
95
96   group("check") {
97     if (chip_link_tests) {
98       deps = [ "//src:tests_run" ]
99     }
100   }
101
102   # We don't always want to run happy tests, make them a seperate group.
103   if (chip_enable_happy_tests) {
104     group("happy_tests") {
105       if (chip_link_tests) {
106         deps = [ "//src:happy_tests" ]
107       }
108     }
109   }
110 } else {
111   # This is the unified build. Configure various real toolchains.
112   import("${chip_root}/build/chip/chip_build.gni")
113   declare_args() {
114     # Set this to false to disable all builds by default.
115     enable_default_builds = true
116
117     # Enable building for Android.
118     enable_android_builds = false
119
120     # Set this to true to enable efr32 builds by default.
121     enable_efr32_builds = false
122
123     # Set this to true to enable qpg6100 builds by default.
124     enable_qpg6100_builds = false
125
126     # Set this to true to enable k32w builds by default.
127     enable_k32w_builds = false
128   }
129
130   declare_args() {
131     # Enable building chip with clang.
132     enable_host_clang_build = enable_default_builds
133
134     # Enable building chip with gcc.
135     enable_host_gcc_build = enable_default_builds
136
137     # Enable building chip with gcc & mbedtls.
138     enable_host_gcc_mbedtls_build = enable_default_builds
139
140     # Build the chip-tool example.
141     enable_standalone_chip_tool_build = enable_default_builds
142
143     # Build the shell example.
144     enable_standalone_shell_build = enable_default_builds
145
146     # Build the Linux all clusters app example.
147     enable_linux_all_clusters_app_build =
148         enable_default_builds && host_os == "linux"
149
150     # Build the Linux lighting app example.
151     enable_linux_lighting_app_build =
152         enable_default_builds && host_os == "linux"
153
154     # Build the efr32 lock app example.
155     enable_efr32_lock_app_build = enable_efr32_builds
156
157     # Build the qpg6100 lock app example.
158     enable_qpg6100_lock_app_build = enable_qpg6100_builds
159
160     # Build the efr32 lighting app example.
161     enable_efr32_lighting_app_build = enable_efr32_builds
162
163     # Build the k32w lock app example.
164     enable_k32w_lock_app_build = enable_k32w_builds
165   }
166
167   if (enable_host_clang_build) {
168     chip_build("host_clang") {
169       toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang"
170     }
171   }
172
173   if (enable_host_gcc_build) {
174     chip_build("host_gcc") {
175       toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc"
176     }
177   }
178
179   if (enable_host_gcc_mbedtls_build) {
180     chip_build("host_gcc_mbedtls") {
181       toolchain = "${chip_root}/config/mbedtls/toolchain:${host_os}_${host_cpu}_gcc_mbedtls"
182     }
183   }
184
185   if (enable_android_builds) {
186     chip_build("android_arm") {
187       toolchain = "//build/toolchain/android:android_arm"
188     }
189
190     chip_build("android_arm64") {
191       toolchain = "//build/toolchain/android:android_arm64"
192     }
193
194     chip_build("android_x64") {
195       toolchain = "//build/toolchain/android:android_x64"
196     }
197
198     chip_build("android_x86") {
199       toolchain = "//build/toolchain/android:android_x86"
200     }
201   }
202
203   standalone_toolchain = "${chip_root}/config/standalone/toolchain:standalone"
204
205   if (enable_standalone_chip_tool_build) {
206     group("standalone_chip_tool") {
207       deps = [ "${chip_root}/examples/chip-tool(${standalone_toolchain})" ]
208     }
209   }
210
211   if (enable_standalone_shell_build) {
212     group("standalone_shell") {
213       deps =
214           [ "${chip_root}/examples/shell/standalone(${standalone_toolchain})" ]
215     }
216   }
217
218   if (enable_linux_all_clusters_app_build) {
219     group("linux_all_clusters_app") {
220       deps = [
221         "${chip_root}/examples/all-clusters-app/linux(${standalone_toolchain})",
222       ]
223     }
224   }
225
226   if (enable_linux_lighting_app_build) {
227     group("linux_lighting_app") {
228       deps = [
229         "${chip_root}/examples/lighting-app/linux(${standalone_toolchain})",
230       ]
231     }
232   }
233
234   if (enable_efr32_lock_app_build) {
235     group("efr32_lock_app") {
236       deps = [ "${chip_root}/examples/lock-app/efr32(${chip_root}/config/efr32/toolchain:efr32_lock_app)" ]
237     }
238   }
239
240   if (enable_qpg6100_lock_app_build) {
241     group("qpg6100_lock_app") {
242       deps = [ "${chip_root}/examples/lock-app/qpg6100(${chip_root}/config/qpg6100/toolchain:qpg6100_lock_app)" ]
243     }
244   }
245
246   if (enable_efr32_lighting_app_build) {
247     group("efr32_lighting_app") {
248       deps = [ "${chip_root}/examples/lighting-app/efr32(${chip_root}/config/efr32/toolchain:efr32_lighting_app)" ]
249     }
250   }
251
252   if (enable_k32w_lock_app_build) {
253     group("k32w_lock_app") {
254       deps = [ "${chip_root}/examples/lock-app/k32w(${chip_root}/config/k32w/toolchain:k32w_lock_app)" ]
255     }
256   }
257
258   group("default") {
259     deps = []
260     if (enable_host_clang_build) {
261       deps += [ ":all_host_clang" ]
262     }
263     if (enable_host_gcc_build) {
264       deps += [ ":all_host_gcc" ]
265     }
266     if (enable_host_gcc_mbedtls_build) {
267       deps += [ ":all_host_gcc_mbedtls" ]
268     }
269     if (enable_android_builds) {
270       deps += [
271         ":all_android_arm",
272         ":all_android_arm64",
273         ":all_android_x64",
274         ":all_android_x86",
275       ]
276     }
277     if (enable_standalone_chip_tool_build) {
278       deps += [ ":standalone_chip_tool" ]
279     }
280     if (enable_standalone_shell_build) {
281       deps += [ ":standalone_shell" ]
282     }
283     if (enable_linux_all_clusters_app_build) {
284       deps += [ ":linux_all_clusters_app" ]
285     }
286     if (enable_linux_lighting_app_build) {
287       deps += [ ":linux_lighting_app" ]
288     }
289     if (enable_efr32_lock_app_build) {
290       deps += [ ":efr32_lock_app" ]
291     }
292     if (enable_k32w_lock_app_build) {
293       deps += [ ":k32w_lock_app" ]
294     }
295   }
296
297   group("check") {
298     deps = []
299     if (enable_host_clang_build) {
300       deps += [ ":check_host_clang" ]
301     }
302     if (enable_host_gcc_build) {
303       deps += [ ":check_host_gcc" ]
304     }
305     if (enable_host_gcc_mbedtls_build) {
306       deps += [ ":check_host_gcc_mbedtls" ]
307     }
308   }
309 }