Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 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 | import("//build_overrides/chip.gni") |
| 16 | import("//build_overrides/mbedtls.gni") |
| 17 | import("//build_overrides/nlassert.gni") |
| 18 | import("//build_overrides/nlio.gni") |
| 19 | import("//build_overrides/nlunit_test.gni") |
| 20 | import("//build_overrides/pigweed.gni") |
szatmz | 2244db6 | 2020-12-04 14:42:01 -0500 | [diff] [blame] | 21 | import("$dir_pw_build/python.gni") |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 22 | |
| 23 | # This build file should not be used in superproject builds. |
| 24 | assert(chip_root == "//") |
| 25 | |
Michael Spang | 55d6a5f | 2020-10-07 00:43:56 -0400 | [diff] [blame] | 26 | import("${chip_root}/build/chip/tests.gni") |
| 27 | import("${chip_root}/build/chip/tools.gni") |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 28 | |
| 29 | if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { |
Andrei Litvin | 2d86349 | 2020-10-02 17:28:58 -0400 | [diff] [blame] | 30 | declare_args() { |
Michael Spang | 4833d9c | 2020-10-09 09:33:02 -0400 | [diff] [blame] | 31 | chip_enable_python_modules = |
Song Guo | d652be4 | 2020-11-11 00:34:35 +0800 | [diff] [blame] | 32 | (current_os == "mac" || current_os == "linux") && |
| 33 | (host_cpu == "x64" || host_cpu == "arm64") |
Andrei Litvin | 2d86349 | 2020-10-02 17:28:58 -0400 | [diff] [blame] | 34 | } |
| 35 | |
szatmz | 2244db6 | 2020-12-04 14:42:01 -0500 | [diff] [blame] | 36 | # 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 Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 44 | # This is a real toolchain. Build CHIP. |
| 45 | group("default") { |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 46 | 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 Margolis | df86212 | 2020-10-22 07:47:27 -0700 | [diff] [blame] | 53 | "${chip_root}/src/lib/asn1", |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 54 | "${chip_root}/src/lib/core", |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 55 | "${chip_root}/src/lib/shell", |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 56 | "${chip_root}/src/lib/support", |
| 57 | "${chip_root}/src/lwip:all", |
Yufeng Wang | 4fc19f1 | 2020-10-22 16:14:32 -0700 | [diff] [blame] | 58 | "${chip_root}/src/messaging", |
Yufeng Wang | a3d4054 | 2020-11-04 13:12:48 -0800 | [diff] [blame] | 59 | "${chip_root}/src/protocols", |
Rob Walker | b14e3e3 | 2020-08-20 13:59:22 -0700 | [diff] [blame] | 60 | "${chip_root}/src/setup_payload", |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 61 | "${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źnia | 6b3ee1a | 2020-09-04 03:08:16 +0200 | [diff] [blame] | 70 | deps += [ "//src:tests" ] |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | if (chip_build_tools) { |
| 74 | deps += [ |
Timothy Maes | 9e1ac48 | 2020-10-29 17:59:49 +0100 | [diff] [blame] | 75 | "${chip_root}/examples/shell/standalone:chip-shell", |
Yufeng Wang | 4282a07 | 2020-12-08 08:58:46 -0800 | [diff] [blame^] | 76 | "${chip_root}/src/messaging/tests/echo:chip-echo-requester", |
| 77 | "${chip_root}/src/messaging/tests/echo:chip-echo-responder", |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 78 | "${chip_root}/src/qrcodetool", |
| 79 | "${chip_root}/src/setup_payload", |
| 80 | ] |
Andrei Litvin | 2d86349 | 2020-10-02 17:28:58 -0400 | [diff] [blame] | 81 | if (chip_enable_python_modules) { |
yunhanw-google | 90ea314 | 2020-10-01 13:53:26 -0700 | [diff] [blame] | 82 | deps += [ "${chip_root}/src/controller/python" ] |
| 83 | } |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 84 | } |
Andrei Litvin | d74a0b6 | 2020-08-30 19:58:00 -0400 | [diff] [blame] | 85 | |
| 86 | if (current_os == "android") { |
| 87 | deps += [ |
| 88 | "${chip_root}/src/controller/java", |
| 89 | "${chip_root}/src/setup_payload/java", |
| 90 | ] |
| 91 | } |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 92 | } |
| 93 | |
Michael Spang | df71298 | 2020-09-18 10:39:35 -0400 | [diff] [blame] | 94 | group("check") { |
| 95 | if (chip_link_tests) { |
Rafał Kuźnia | 6b3ee1a | 2020-09-04 03:08:16 +0200 | [diff] [blame] | 96 | deps = [ "//src:tests_run" ] |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 97 | } |
| 98 | } |
Song Guo | 30123da | 2020-10-13 19:30:39 +0800 | [diff] [blame] | 99 | |
| 100 | # We don't always want to run happy tests, make them a seperate group. |
Michael Spang | 60a2807 | 2020-10-13 11:03:21 -0400 | [diff] [blame] | 101 | if (chip_enable_happy_tests) { |
| 102 | group("happy_tests") { |
| 103 | if (chip_link_tests) { |
| 104 | deps = [ "//src:happy_tests" ] |
| 105 | } |
Song Guo | 30123da | 2020-10-13 19:30:39 +0800 | [diff] [blame] | 106 | } |
| 107 | } |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 108 | } else { |
Michael Spang | f1af8fc | 2020-07-29 14:25:47 -0400 | [diff] [blame] | 109 | # This is the unified build. Configure various real toolchains. |
Michael Spang | 55d6a5f | 2020-10-07 00:43:56 -0400 | [diff] [blame] | 110 | import("${chip_root}/build/chip/chip_build.gni") |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 111 | declare_args() { |
| 112 | # Set this to false to disable all builds by default. |
| 113 | enable_default_builds = true |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 114 | |
Michael Spang | fdc49a3 | 2020-09-03 18:33:20 -0400 | [diff] [blame] | 115 | # Enable building for Android. |
| 116 | enable_android_builds = false |
| 117 | |
jepenven-silabs | cec75ca | 2020-08-04 09:38:48 -0400 | [diff] [blame] | 118 | # Set this to true to enable efr32 builds by default. |
| 119 | enable_efr32_builds = false |
Timothy Maes | b5b3d38 | 2020-10-05 16:59:21 +0200 | [diff] [blame] | 120 | |
| 121 | # Set this to true to enable qpg6100 builds by default. |
| 122 | enable_qpg6100_builds = false |
doru91 | 04ac26b | 2020-10-13 18:23:28 +0300 | [diff] [blame] | 123 | |
| 124 | # Set this to true to enable k32w builds by default. |
| 125 | enable_k32w_builds = false |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 126 | } |
| 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 Spang | a964fad | 2020-07-13 09:36:00 -0400 | [diff] [blame] | 135 | # Enable building chip with gcc & mbedtls. |
| 136 | enable_host_gcc_mbedtls_build = enable_default_builds |
| 137 | |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 138 | # 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 Nicolas | 280d80f | 2020-11-06 22:56:40 +0100 | [diff] [blame] | 144 | # Build the Linux all clusters app example. |
| 145 | enable_linux_all_clusters_app_build = |
Vivien Nicolas | 1b29655 | 2020-12-07 18:24:57 +0100 | [diff] [blame] | 146 | enable_default_builds && (host_os == "linux" || host_os == "mac") |
Vivien Nicolas | 280d80f | 2020-11-06 22:56:40 +0100 | [diff] [blame] | 147 | |
Michael Spang | 7c8f19b | 2020-11-02 13:05:12 -0500 | [diff] [blame] | 148 | # Build the Linux lighting app example. |
| 149 | enable_linux_lighting_app_build = |
Vivien Nicolas | 1b29655 | 2020-12-07 18:24:57 +0100 | [diff] [blame] | 150 | enable_default_builds && (host_os == "linux" || host_os == "mac") |
Michael Spang | 7c8f19b | 2020-11-02 13:05:12 -0500 | [diff] [blame] | 151 | |
jepenven-silabs | cec75ca | 2020-08-04 09:38:48 -0400 | [diff] [blame] | 152 | # Build the efr32 lock app example. |
| 153 | enable_efr32_lock_app_build = enable_efr32_builds |
Michael Spang | 0241373 | 2020-09-24 09:45:17 -0400 | [diff] [blame] | 154 | |
Timothy Maes | b5b3d38 | 2020-10-05 16:59:21 +0200 | [diff] [blame] | 155 | # Build the qpg6100 lock app example. |
| 156 | enable_qpg6100_lock_app_build = enable_qpg6100_builds |
| 157 | |
Michael Spang | 0241373 | 2020-09-24 09:45:17 -0400 | [diff] [blame] | 158 | # Build the efr32 lighting app example. |
| 159 | enable_efr32_lighting_app_build = enable_efr32_builds |
doru91 | 04ac26b | 2020-10-13 18:23:28 +0300 | [diff] [blame] | 160 | |
| 161 | # Build the k32w lock app example. |
| 162 | enable_k32w_lock_app_build = enable_k32w_builds |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 163 | } |
| 164 | |
Michael Spang | 7c8f19b | 2020-11-02 13:05:12 -0500 | [diff] [blame] | 165 | if (enable_host_clang_build) { |
| 166 | chip_build("host_clang") { |
| 167 | toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang" |
| 168 | } |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 169 | } |
| 170 | |
Michael Spang | 7c8f19b | 2020-11-02 13:05:12 -0500 | [diff] [blame] | 171 | if (enable_host_gcc_build) { |
| 172 | chip_build("host_gcc") { |
| 173 | toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc" |
| 174 | } |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 175 | } |
| 176 | |
Michael Spang | 7c8f19b | 2020-11-02 13:05:12 -0500 | [diff] [blame] | 177 | 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 Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 181 | } |
| 182 | |
Michael Spang | fdc49a3 | 2020-09-03 18:33:20 -0400 | [diff] [blame] | 183 | 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 Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 201 | standalone_toolchain = "${chip_root}/config/standalone/toolchain:standalone" |
| 202 | |
Michael Spang | 7c8f19b | 2020-11-02 13:05:12 -0500 | [diff] [blame] | 203 | if (enable_standalone_chip_tool_build) { |
| 204 | group("standalone_chip_tool") { |
| 205 | deps = [ "${chip_root}/examples/chip-tool(${standalone_toolchain})" ] |
| 206 | } |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 207 | } |
| 208 | |
Michael Spang | 7c8f19b | 2020-11-02 13:05:12 -0500 | [diff] [blame] | 209 | if (enable_standalone_shell_build) { |
| 210 | group("standalone_shell") { |
| 211 | deps = |
| 212 | [ "${chip_root}/examples/shell/standalone(${standalone_toolchain})" ] |
| 213 | } |
| 214 | } |
| 215 | |
Vivien Nicolas | 280d80f | 2020-11-06 22:56:40 +0100 | [diff] [blame] | 216 | 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 Spang | 7c8f19b | 2020-11-02 13:05:12 -0500 | [diff] [blame] | 224 | 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 Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 230 | } |
| 231 | |
jepenven-silabs | cec75ca | 2020-08-04 09:38:48 -0400 | [diff] [blame] | 232 | 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 Maes | b5b3d38 | 2020-10-05 16:59:21 +0200 | [diff] [blame] | 238 | 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 Spang | 0241373 | 2020-09-24 09:45:17 -0400 | [diff] [blame] | 244 | 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 | |
doru91 | 04ac26b | 2020-10-13 18:23:28 +0300 | [diff] [blame] | 250 | 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 Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 256 | group("default") { |
| 257 | deps = [] |
| 258 | if (enable_host_clang_build) { |
Michael Spang | b1139f7 | 2020-12-01 16:06:36 -0500 | [diff] [blame] | 259 | deps += [ ":host_clang" ] |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 260 | } |
| 261 | if (enable_host_gcc_build) { |
Michael Spang | b1139f7 | 2020-12-01 16:06:36 -0500 | [diff] [blame] | 262 | deps += [ ":host_gcc" ] |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 263 | } |
Michael Spang | a964fad | 2020-07-13 09:36:00 -0400 | [diff] [blame] | 264 | if (enable_host_gcc_mbedtls_build) { |
Michael Spang | b1139f7 | 2020-12-01 16:06:36 -0500 | [diff] [blame] | 265 | deps += [ ":host_gcc_mbedtls" ] |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 266 | } |
Michael Spang | fdc49a3 | 2020-09-03 18:33:20 -0400 | [diff] [blame] | 267 | if (enable_android_builds) { |
| 268 | deps += [ |
Michael Spang | b1139f7 | 2020-12-01 16:06:36 -0500 | [diff] [blame] | 269 | ":android_arm", |
| 270 | ":android_arm64", |
| 271 | ":android_x64", |
| 272 | ":android_x86", |
Michael Spang | fdc49a3 | 2020-09-03 18:33:20 -0400 | [diff] [blame] | 273 | ] |
| 274 | } |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 275 | if (enable_standalone_chip_tool_build) { |
| 276 | deps += [ ":standalone_chip_tool" ] |
| 277 | } |
| 278 | if (enable_standalone_shell_build) { |
| 279 | deps += [ ":standalone_shell" ] |
| 280 | } |
Vivien Nicolas | 280d80f | 2020-11-06 22:56:40 +0100 | [diff] [blame] | 281 | if (enable_linux_all_clusters_app_build) { |
| 282 | deps += [ ":linux_all_clusters_app" ] |
| 283 | } |
Michael Spang | 7c8f19b | 2020-11-02 13:05:12 -0500 | [diff] [blame] | 284 | if (enable_linux_lighting_app_build) { |
| 285 | deps += [ ":linux_lighting_app" ] |
| 286 | } |
jepenven-silabs | cec75ca | 2020-08-04 09:38:48 -0400 | [diff] [blame] | 287 | if (enable_efr32_lock_app_build) { |
| 288 | deps += [ ":efr32_lock_app" ] |
| 289 | } |
doru91 | 04ac26b | 2020-10-13 18:23:28 +0300 | [diff] [blame] | 290 | if (enable_k32w_lock_app_build) { |
| 291 | deps += [ ":k32w_lock_app" ] |
| 292 | } |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 293 | } |
| 294 | |
Michael Spang | df71298 | 2020-09-18 10:39:35 -0400 | [diff] [blame] | 295 | 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 Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 305 | } |
| 306 | } |
| 307 | } |