Merge pull request #4 from jh8801-jung/master
[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 =
33         (current_os == "mac" || current_os == "linux") && host_cpu == "x64"
34   }
35
36   # This is a real toolchain. Build CHIP.
37   group("default") {
38     deps = [ ":all" ]
39   }
40
41   group("all") {
42     deps = [
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",
61       "${nlio_root}:nlio",
62       "${nlunit_test_root}:nlunit-test",
63     ]
64
65     if (chip_build_tests) {
66       deps += [ "//src:tests" ]
67     }
68
69     if (chip_build_tools) {
70       deps += [
71         "${chip_root}/examples/shell/standalone:chip-shell",
72         "${chip_root}/src/qrcodetool",
73         "${chip_root}/src/setup_payload",
74       ]
75       if (chip_enable_python_modules) {
76         deps += [ "${chip_root}/src/controller/python" ]
77       }
78     }
79
80     if (current_os == "android") {
81       deps += [
82         "${chip_root}/src/controller/java",
83         "${chip_root}/src/setup_payload/java",
84       ]
85     }
86
87     deps += [
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",
94     ]
95   }
96
97   group("check") {
98     if (chip_link_tests) {
99       deps = [ "//src:tests_run" ]
100     }
101   }
102
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" ]
108       }
109     }
110   }
111 } else {
112   # This is the unified build. Configure various real toolchains.
113   import("${chip_root}/build/chip/chip_build.gni")
114   declare_args() {
115     # Set this to false to disable all builds by default.
116     enable_default_builds = true
117
118     # Enable building for Android.
119     enable_android_builds = false
120
121     # Set this to true to enable efr32 builds by default.
122     enable_efr32_builds = false
123
124     # Set this to true to enable qpg6100 builds by default.
125     enable_qpg6100_builds = false
126
127     # Set this to true to enable k32w builds by default.
128     enable_k32w_builds = false
129   }
130
131   declare_args() {
132     # Enable building chip with clang.
133     enable_host_clang_build = enable_default_builds
134
135     # Enable building chip with gcc.
136     enable_host_gcc_build = enable_default_builds
137
138     # Enable building chip with gcc & mbedtls.
139     enable_host_gcc_mbedtls_build = enable_default_builds
140
141     # Build the chip-tool example.
142     enable_standalone_chip_tool_build = enable_default_builds
143
144     # Build the shell example.
145     enable_standalone_shell_build = enable_default_builds
146
147     # Build the Linux all clusters app example.
148     enable_linux_all_clusters_app_build =
149         enable_default_builds && host_os == "linux"
150
151     # Build the Linux lighting app example.
152     enable_linux_lighting_app_build =
153         enable_default_builds && host_os == "linux"
154
155     # Build the efr32 lock app example.
156     enable_efr32_lock_app_build = enable_efr32_builds
157
158     # Build the qpg6100 lock app example.
159     enable_qpg6100_lock_app_build = enable_qpg6100_builds
160
161     # Build the efr32 lighting app example.
162     enable_efr32_lighting_app_build = enable_efr32_builds
163
164     # Build the k32w lock app example.
165     enable_k32w_lock_app_build = enable_k32w_builds
166   }
167
168   if (enable_host_clang_build) {
169     chip_build("host_clang") {
170       toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang"
171     }
172   }
173
174   if (enable_host_gcc_build) {
175     chip_build("host_gcc") {
176       toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc"
177     }
178   }
179
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"
183     }
184   }
185
186   if (enable_android_builds) {
187     chip_build("android_arm") {
188       toolchain = "//build/toolchain/android:android_arm"
189     }
190
191     chip_build("android_arm64") {
192       toolchain = "//build/toolchain/android:android_arm64"
193     }
194
195     chip_build("android_x64") {
196       toolchain = "//build/toolchain/android:android_x64"
197     }
198
199     chip_build("android_x86") {
200       toolchain = "//build/toolchain/android:android_x86"
201     }
202   }
203
204   standalone_toolchain = "${chip_root}/config/standalone/toolchain:standalone"
205
206   if (enable_standalone_chip_tool_build) {
207     group("standalone_chip_tool") {
208       deps = [ "${chip_root}/examples/chip-tool(${standalone_toolchain})" ]
209     }
210   }
211
212   if (enable_standalone_shell_build) {
213     group("standalone_shell") {
214       deps =
215           [ "${chip_root}/examples/shell/standalone(${standalone_toolchain})" ]
216     }
217   }
218
219   if (enable_linux_all_clusters_app_build) {
220     group("linux_all_clusters_app") {
221       deps = [
222         "${chip_root}/examples/all-clusters-app/linux(${standalone_toolchain})",
223       ]
224     }
225   }
226
227   if (enable_linux_lighting_app_build) {
228     group("linux_lighting_app") {
229       deps = [
230         "${chip_root}/examples/lighting-app/linux(${standalone_toolchain})",
231       ]
232     }
233   }
234
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)" ]
238     }
239   }
240
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)" ]
244     }
245   }
246
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)" ]
250     }
251   }
252
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)" ]
256     }
257   }
258
259   group("default") {
260     deps = []
261     if (enable_host_clang_build) {
262       deps += [ ":all_host_clang" ]
263     }
264     if (enable_host_gcc_build) {
265       deps += [ ":all_host_gcc" ]
266     }
267     if (enable_host_gcc_mbedtls_build) {
268       deps += [ ":all_host_gcc_mbedtls" ]
269     }
270     if (enable_android_builds) {
271       deps += [
272         ":all_android_arm",
273         ":all_android_arm64",
274         ":all_android_x64",
275         ":all_android_x86",
276       ]
277     }
278     if (enable_standalone_chip_tool_build) {
279       deps += [ ":standalone_chip_tool" ]
280     }
281     if (enable_standalone_shell_build) {
282       deps += [ ":standalone_shell" ]
283     }
284     if (enable_linux_all_clusters_app_build) {
285       deps += [ ":linux_all_clusters_app" ]
286     }
287     if (enable_linux_lighting_app_build) {
288       deps += [ ":linux_lighting_app" ]
289     }
290     if (enable_efr32_lock_app_build) {
291       deps += [ ":efr32_lock_app" ]
292     }
293     if (enable_k32w_lock_app_build) {
294       deps += [ ":k32w_lock_app" ]
295     }
296   }
297
298   group("check") {
299     deps = []
300     if (enable_host_clang_build) {
301       deps += [ ":check_host_clang" ]
302     }
303     if (enable_host_gcc_build) {
304       deps += [ ":check_host_gcc" ]
305     }
306     if (enable_host_gcc_mbedtls_build) {
307       deps += [ ":check_host_gcc_mbedtls" ]
308     }
309   }
310 }