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") |
| 21 | |
| 22 | # This build file should not be used in superproject builds. |
| 23 | assert(chip_root == "//") |
| 24 | |
| 25 | import("${chip_root}/gn/chip/tests.gni") |
| 26 | import("${chip_root}/gn/chip/tools.gni") |
| 27 | |
| 28 | if (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 Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 43 | "${chip_root}/src/lib/shell", |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 44 | "${chip_root}/src/lib/support", |
| 45 | "${chip_root}/src/lwip:all", |
Rob Walker | b14e3e3 | 2020-08-20 13:59:22 -0700 | [diff] [blame] | 46 | "${chip_root}/src/setup_payload", |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 47 | "${chip_root}/src/system", |
| 48 | "${chip_root}/src/transport", |
| 49 | "${mbedtls_root}:mbedtls", |
| 50 | "${nlassert_root}:nlassert", |
| 51 | "${nlio_root}:nlio", |
| 52 | "${nlunit_test_root}:nlunit-test", |
| 53 | ] |
| 54 | |
randyrossi | 90988b6 | 2020-08-19 13:39:57 -0400 | [diff] [blame] | 55 | # Temporary until RNG issue sorted out |
| 56 | if (current_os != "android") { |
Michael Spang | 3afd993 | 2020-08-20 14:00:46 -0400 | [diff] [blame] | 57 | deps += [ "${chip_root}/src/lib/message" ] |
randyrossi | 90988b6 | 2020-08-19 13:39:57 -0400 | [diff] [blame] | 58 | } |
| 59 | |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 60 | if (chip_build_tests) { |
| 61 | deps += [ ":tests" ] |
| 62 | } |
| 63 | |
| 64 | if (chip_build_tools) { |
| 65 | deps += [ |
Michael Spang | fa6b522 | 2020-08-17 12:54:40 -0400 | [diff] [blame] | 66 | "${chip_root}/examples/shell", |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 67 | "${chip_root}/src/qrcodetool", |
| 68 | "${chip_root}/src/setup_payload", |
| 69 | ] |
| 70 | } |
Andrei Litvin | d74a0b6 | 2020-08-30 19:58:00 -0400 | [diff] [blame] | 71 | |
| 72 | if (current_os == "android") { |
| 73 | deps += [ |
| 74 | "${chip_root}/src/controller/java", |
| 75 | "${chip_root}/src/setup_payload/java", |
| 76 | ] |
| 77 | } |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | if (chip_build_tests) { |
| 81 | import("${chip_root}/gn/chip/chip_test_group.gni") |
| 82 | |
| 83 | chip_test_group("tests") { |
| 84 | deps = [ |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 85 | "${chip_root}/src/ble/tests", |
| 86 | "${chip_root}/src/crypto/tests", |
| 87 | "${chip_root}/src/inet/tests", |
| 88 | "${chip_root}/src/lib/core/tests", |
Martin Turon | f3d80ff | 2020-07-20 11:10:38 -0700 | [diff] [blame] | 89 | "${chip_root}/src/lib/shell/tests", |
Michael Spang | fa6b522 | 2020-08-17 12:54:40 -0400 | [diff] [blame] | 90 | "${chip_root}/src/lib/support/tests", |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 91 | "${chip_root}/src/lwip/tests", |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 92 | "${chip_root}/src/platform/tests", |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 93 | "${chip_root}/src/setup_payload/tests", |
| 94 | "${chip_root}/src/system/tests", |
| 95 | "${chip_root}/src/transport/tests", |
| 96 | ] |
| 97 | } |
| 98 | |
| 99 | group("check") { |
| 100 | deps = [ ":tests_run" ] |
| 101 | } |
| 102 | } |
| 103 | } else { |
Michael Spang | f1af8fc | 2020-07-29 14:25:47 -0400 | [diff] [blame] | 104 | # This is the unified build. Configure various real toolchains. |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 105 | import("${chip_root}/gn/chip/chip_build.gni") |
| 106 | declare_args() { |
| 107 | # Set this to false to disable all builds by default. |
| 108 | enable_default_builds = true |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 109 | |
Michael Spang | fdc49a3 | 2020-09-03 18:33:20 -0400 | [diff] [blame^] | 110 | # Enable building for Android. |
| 111 | enable_android_builds = false |
| 112 | |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 113 | # Set this to true to enable nRF5 builds by default. |
| 114 | enable_nrf5_builds = false |
jepenven-silabs | cec75ca | 2020-08-04 09:38:48 -0400 | [diff] [blame] | 115 | |
| 116 | # Set this to true to enable efr32 builds by default. |
| 117 | enable_efr32_builds = false |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | declare_args() { |
| 121 | # Enable building chip with clang. |
| 122 | enable_host_clang_build = enable_default_builds |
| 123 | |
| 124 | # Enable building chip with gcc. |
| 125 | enable_host_gcc_build = enable_default_builds |
| 126 | |
Michael Spang | a964fad | 2020-07-13 09:36:00 -0400 | [diff] [blame] | 127 | # Enable building chip with gcc & mbedtls. |
| 128 | enable_host_gcc_mbedtls_build = enable_default_builds |
| 129 | |
| 130 | # Enable building chip for linux embedded. |
| 131 | enable_linux_embedded_build = enable_default_builds && host_os == "linux" |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 132 | |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 133 | # Build the chip-tool example. |
| 134 | enable_standalone_chip_tool_build = enable_default_builds |
| 135 | |
| 136 | # Build the shell example. |
| 137 | enable_standalone_shell_build = enable_default_builds |
| 138 | |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 139 | # Build the nRF5 lock app example. |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 140 | enable_nrf5_lock_app_build = enable_nrf5_builds |
| 141 | |
| 142 | # Build the nRF5 lighting app example. |
| 143 | enable_nrf5_lighting_app_build = enable_nrf5_builds |
jepenven-silabs | cec75ca | 2020-08-04 09:38:48 -0400 | [diff] [blame] | 144 | |
| 145 | # Build the efr32 lock app example. |
| 146 | enable_efr32_lock_app_build = enable_efr32_builds |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 147 | } |
| 148 | |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 149 | chip_build("host_clang") { |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 150 | toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang" |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | chip_build("host_gcc") { |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 154 | toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc" |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | chip_build("host_gcc_mbedtls") { |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 158 | toolchain = "${chip_root}/config/mbedtls/toolchain:${host_os}_${host_cpu}_gcc_mbedtls" |
| 159 | } |
| 160 | |
Michael Spang | fdc49a3 | 2020-09-03 18:33:20 -0400 | [diff] [blame^] | 161 | if (enable_android_builds) { |
| 162 | chip_build("android_arm") { |
| 163 | toolchain = "//build/toolchain/android:android_arm" |
| 164 | } |
| 165 | |
| 166 | chip_build("android_arm64") { |
| 167 | toolchain = "//build/toolchain/android:android_arm64" |
| 168 | } |
| 169 | |
| 170 | chip_build("android_x64") { |
| 171 | toolchain = "//build/toolchain/android:android_x64" |
| 172 | } |
| 173 | |
| 174 | chip_build("android_x86") { |
| 175 | toolchain = "//build/toolchain/android:android_x86" |
| 176 | } |
| 177 | } |
| 178 | |
Michael Spang | a964fad | 2020-07-13 09:36:00 -0400 | [diff] [blame] | 179 | if (host_os == "linux") { |
| 180 | chip_build("linux_embedded") { |
| 181 | toolchain = |
| 182 | "${chip_root}/config/linux/toolchain:linux_${host_cpu}_gcc_embedded" |
| 183 | } |
| 184 | } |
| 185 | |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 186 | standalone_toolchain = "${chip_root}/config/standalone/toolchain:standalone" |
| 187 | |
| 188 | group("standalone_chip_tool") { |
| 189 | deps = [ "${chip_root}/examples/chip-tool(${standalone_toolchain})" ] |
| 190 | } |
| 191 | |
| 192 | group("standalone_shell") { |
| 193 | deps = [ "${chip_root}/examples/shell(${standalone_toolchain})" ] |
| 194 | } |
| 195 | |
| 196 | if (enable_nrf5_lock_app_build) { |
| 197 | group("nrf5_lock_app") { |
| 198 | deps = [ "${chip_root}/examples/lock-app/nrf5(${chip_root}/config/nrf5/toolchain:nrf5_lock_app)" ] |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | if (enable_nrf5_lighting_app_build) { |
| 203 | group("nrf5_lighting_app") { |
| 204 | deps = [ "${chip_root}/examples/lighting-app/nrf5(${chip_root}/config/nrf5/toolchain:nrf5_lighting_app)" ] |
| 205 | } |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 206 | } |
| 207 | |
jepenven-silabs | cec75ca | 2020-08-04 09:38:48 -0400 | [diff] [blame] | 208 | if (enable_efr32_lock_app_build) { |
| 209 | group("efr32_lock_app") { |
| 210 | deps = [ "${chip_root}/examples/lock-app/efr32(${chip_root}/config/efr32/toolchain:efr32_lock_app)" ] |
| 211 | } |
| 212 | } |
| 213 | |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 214 | group("default") { |
| 215 | deps = [] |
| 216 | if (enable_host_clang_build) { |
| 217 | deps += [ ":all_host_clang" ] |
| 218 | } |
| 219 | if (enable_host_gcc_build) { |
| 220 | deps += [ ":all_host_gcc" ] |
| 221 | } |
Michael Spang | a964fad | 2020-07-13 09:36:00 -0400 | [diff] [blame] | 222 | if (enable_host_gcc_mbedtls_build) { |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 223 | deps += [ ":all_host_gcc_mbedtls" ] |
| 224 | } |
Michael Spang | fdc49a3 | 2020-09-03 18:33:20 -0400 | [diff] [blame^] | 225 | if (enable_android_builds) { |
| 226 | deps += [ |
| 227 | ":all_android_arm", |
| 228 | ":all_android_arm64", |
| 229 | ":all_android_x64", |
| 230 | ":all_android_x86", |
| 231 | ] |
| 232 | } |
Michael Spang | a964fad | 2020-07-13 09:36:00 -0400 | [diff] [blame] | 233 | if (enable_linux_embedded_build) { |
| 234 | deps += [ ":all_linux_embedded" ] |
| 235 | } |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 236 | if (enable_standalone_chip_tool_build) { |
| 237 | deps += [ ":standalone_chip_tool" ] |
| 238 | } |
| 239 | if (enable_standalone_shell_build) { |
| 240 | deps += [ ":standalone_shell" ] |
| 241 | } |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 242 | if (enable_nrf5_lock_app_build) { |
Michael Spang | 8d085b3 | 2020-07-10 10:26:23 -0400 | [diff] [blame] | 243 | deps += [ ":nrf5_lock_app" ] |
| 244 | } |
| 245 | if (enable_nrf5_lighting_app_build) { |
| 246 | deps += [ ":nrf5_lighting_app" ] |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 247 | } |
jepenven-silabs | cec75ca | 2020-08-04 09:38:48 -0400 | [diff] [blame] | 248 | if (enable_efr32_lock_app_build) { |
| 249 | deps += [ ":efr32_lock_app" ] |
| 250 | } |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | if (chip_build_tests) { |
| 254 | group("check") { |
| 255 | deps = [] |
| 256 | if (enable_host_clang_build) { |
| 257 | deps += [ ":check_host_clang" ] |
| 258 | } |
| 259 | if (enable_host_gcc_build) { |
| 260 | deps += [ ":check_host_gcc" ] |
| 261 | } |
Michael Spang | a964fad | 2020-07-13 09:36:00 -0400 | [diff] [blame] | 262 | if (enable_host_gcc_mbedtls_build) { |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 263 | deps += [ ":check_host_gcc_mbedtls" ] |
| 264 | } |
Michael Spang | a964fad | 2020-07-13 09:36:00 -0400 | [diff] [blame] | 265 | if (enable_linux_embedded_build) { |
| 266 | deps += [ ":check_linux_embedded" ] |
| 267 | } |
Michael Spang | efa630b | 2020-07-08 22:23:08 -0400 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | } |