blob: d389987140676e37c27aca931247dd01f24eb844 [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")
21
22# This build file should not be used in superproject builds.
23assert(chip_root == "//")
24
25import("${chip_root}/gn/chip/tests.gni")
26import("${chip_root}/gn/chip/tools.gni")
27
28if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
29 # This is a real toolchain. Build CHIP.
30 group("default") {
31 deps = [ ":all" ]
32 }
33
34 group("all") {
35 deps = [
36 "${chip_root}/src/app",
37 "${chip_root}/src/ble",
38 "${chip_root}/src/controller",
39 "${chip_root}/src/crypto",
40 "${chip_root}/src/inet",
41 "${chip_root}/src/lib",
42 "${chip_root}/src/lib/core",
Michael Spang8d085b32020-07-10 10:26:23 -040043 "${chip_root}/src/lib/shell",
Michael Spangefa630b2020-07-08 22:23:08 -040044 "${chip_root}/src/lib/support",
45 "${chip_root}/src/lwip:all",
46 "${chip_root}/src/system",
47 "${chip_root}/src/transport",
48 "${mbedtls_root}:mbedtls",
49 "${nlassert_root}:nlassert",
50 "${nlio_root}:nlio",
51 "${nlunit_test_root}:nlunit-test",
52 ]
53
54 if (chip_build_tests) {
55 deps += [ ":tests" ]
56 }
57
58 if (chip_build_tools) {
59 deps += [
Michael Spangefa630b2020-07-08 22:23:08 -040060 "${chip_root}/src/qrcodetool",
61 "${chip_root}/src/setup_payload",
62 ]
63 }
64 }
65
66 if (chip_build_tests) {
67 import("${chip_root}/gn/chip/chip_test_group.gni")
68
69 chip_test_group("tests") {
70 deps = [
71 "${chip_root}/src/app/plugin/tests",
72 "${chip_root}/src/ble/tests",
73 "${chip_root}/src/crypto/tests",
74 "${chip_root}/src/inet/tests",
75 "${chip_root}/src/lib/core/tests",
76 "${chip_root}/src/lib/support/tests",
77 "${chip_root}/src/lwip/tests",
Michael Spang8d085b32020-07-10 10:26:23 -040078 "${chip_root}/src/platform/tests",
Michael Spangefa630b2020-07-08 22:23:08 -040079 "${chip_root}/src/setup_payload/tests",
80 "${chip_root}/src/system/tests",
81 "${chip_root}/src/transport/tests",
82 ]
83 }
84
85 group("check") {
86 deps = [ ":tests_run" ]
87 }
88 }
89} else {
90 # This is the dummy toolchain. Configure various real toolchains.
91 import("${chip_root}/gn/chip/chip_build.gni")
92 declare_args() {
93 # Set this to false to disable all builds by default.
94 enable_default_builds = true
Michael Spang8d085b32020-07-10 10:26:23 -040095
96 # Set this to true to enable nRF5 builds by default.
97 enable_nrf5_builds = false
Michael Spangefa630b2020-07-08 22:23:08 -040098 }
99
100 declare_args() {
101 # Enable building chip with clang.
102 enable_host_clang_build = enable_default_builds
103
104 # Enable building chip with gcc.
105 enable_host_gcc_build = enable_default_builds
106
107 # Build building chip with gcc & mbedtls.
108 enable_host_gcc_mbdtls_build = enable_default_builds
109
Michael Spang8d085b32020-07-10 10:26:23 -0400110 # Build the chip-tool example.
111 enable_standalone_chip_tool_build = enable_default_builds
112
113 # Build the shell example.
114 enable_standalone_shell_build = enable_default_builds
115
Michael Spangefa630b2020-07-08 22:23:08 -0400116 # Build the nRF5 lock app example.
Michael Spang8d085b32020-07-10 10:26:23 -0400117 enable_nrf5_lock_app_build = enable_nrf5_builds
118
119 # Build the nRF5 lighting app example.
120 enable_nrf5_lighting_app_build = enable_nrf5_builds
Michael Spangefa630b2020-07-08 22:23:08 -0400121 }
122
Michael Spangefa630b2020-07-08 22:23:08 -0400123 chip_build("host_clang") {
Michael Spang8d085b32020-07-10 10:26:23 -0400124 toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang"
Michael Spangefa630b2020-07-08 22:23:08 -0400125 }
126
127 chip_build("host_gcc") {
Michael Spang8d085b32020-07-10 10:26:23 -0400128 toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc"
Michael Spangefa630b2020-07-08 22:23:08 -0400129 }
130
131 chip_build("host_gcc_mbedtls") {
Michael Spang8d085b32020-07-10 10:26:23 -0400132 toolchain = "${chip_root}/config/mbedtls/toolchain:${host_os}_${host_cpu}_gcc_mbedtls"
133 }
134
135 standalone_toolchain = "${chip_root}/config/standalone/toolchain:standalone"
136
137 group("standalone_chip_tool") {
138 deps = [ "${chip_root}/examples/chip-tool(${standalone_toolchain})" ]
139 }
140
141 group("standalone_shell") {
142 deps = [ "${chip_root}/examples/shell(${standalone_toolchain})" ]
143 }
144
145 if (enable_nrf5_lock_app_build) {
146 group("nrf5_lock_app") {
147 deps = [ "${chip_root}/examples/lock-app/nrf5(${chip_root}/config/nrf5/toolchain:nrf5_lock_app)" ]
148 }
149 }
150
151 if (enable_nrf5_lighting_app_build) {
152 group("nrf5_lighting_app") {
153 deps = [ "${chip_root}/examples/lighting-app/nrf5(${chip_root}/config/nrf5/toolchain:nrf5_lighting_app)" ]
154 }
Michael Spangefa630b2020-07-08 22:23:08 -0400155 }
156
157 group("default") {
158 deps = []
159 if (enable_host_clang_build) {
160 deps += [ ":all_host_clang" ]
161 }
162 if (enable_host_gcc_build) {
163 deps += [ ":all_host_gcc" ]
164 }
165 if (enable_host_gcc_mbdtls_build) {
166 deps += [ ":all_host_gcc_mbedtls" ]
167 }
Michael Spang8d085b32020-07-10 10:26:23 -0400168 if (enable_standalone_chip_tool_build) {
169 deps += [ ":standalone_chip_tool" ]
170 }
171 if (enable_standalone_shell_build) {
172 deps += [ ":standalone_shell" ]
173 }
Michael Spangefa630b2020-07-08 22:23:08 -0400174 if (enable_nrf5_lock_app_build) {
Michael Spang8d085b32020-07-10 10:26:23 -0400175 deps += [ ":nrf5_lock_app" ]
176 }
177 if (enable_nrf5_lighting_app_build) {
178 deps += [ ":nrf5_lighting_app" ]
Michael Spangefa630b2020-07-08 22:23:08 -0400179 }
180 }
181
182 if (chip_build_tests) {
183 group("check") {
184 deps = []
185 if (enable_host_clang_build) {
186 deps += [ ":check_host_clang" ]
187 }
188 if (enable_host_gcc_build) {
189 deps += [ ":check_host_gcc" ]
190 }
191 if (enable_host_gcc_mbdtls_build) {
192 deps += [ ":check_host_gcc_mbedtls" ]
193 }
Michael Spangefa630b2020-07-08 22:23:08 -0400194 }
195 }
196}