1*61c4878aSAndroid Build Coastguard Worker# Copyright 2020 The Pigweed Authors 2*61c4878aSAndroid Build Coastguard Worker# 3*61c4878aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4*61c4878aSAndroid Build Coastguard Worker# use this file except in compliance with the License. You may obtain a copy of 5*61c4878aSAndroid Build Coastguard Worker# the License at 6*61c4878aSAndroid Build Coastguard Worker# 7*61c4878aSAndroid Build Coastguard Worker# https://www.apache.org/licenses/LICENSE-2.0 8*61c4878aSAndroid Build Coastguard Worker# 9*61c4878aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*61c4878aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11*61c4878aSAndroid Build Coastguard Worker# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12*61c4878aSAndroid Build Coastguard Worker# License for the specific language governing permissions and limitations under 13*61c4878aSAndroid Build Coastguard Worker# the License. 14*61c4878aSAndroid Build Coastguard Worker 15*61c4878aSAndroid Build Coastguard Workerimport("//build_overrides/pi_pico.gni") 16*61c4878aSAndroid Build Coastguard Workerimport("//build_overrides/pigweed.gni") 17*61c4878aSAndroid Build Coastguard Worker 18*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_android_toolchain/android.gni") 19*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_arduino_build/arduino.gni") 20*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_build/coverage_report.gni") 21*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_build/host_tool.gni") 22*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_build/python.gni") 23*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_docgen/docs.gni") 24*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_perf_test/perf_test.gni") 25*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_rpc/config.gni") 26*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_rust/rust.gni") 27*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_third_party/ambiq/ambiq.gni") 28*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_third_party/fuzztest/fuzztest.gni") 29*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_third_party/mcuxpresso/mcuxpresso.gni") 30*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_toolchain/c_optimization.gni") 31*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_toolchain/generate_toolchain.gni") 32*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_toolchain/non_c_toolchain.gni") 33*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_trace/backend.gni") 34*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_unit_test/test.gni") 35*61c4878aSAndroid Build Coastguard Worker 36*61c4878aSAndroid Build Coastguard Worker# Main build file for upstream Pigweed. 37*61c4878aSAndroid Build Coastguard Worker 38*61c4878aSAndroid Build Coastguard Workerdeclare_args() { 39*61c4878aSAndroid Build Coastguard Worker # The default C++ optimization level for building upstream Pigweed targets. 40*61c4878aSAndroid Build Coastguard Worker # 41*61c4878aSAndroid Build Coastguard Worker # Must be one of "debug", "size_optimized", or "speed_optimized". 42*61c4878aSAndroid Build Coastguard Worker pw_DEFAULT_C_OPTIMIZATION_LEVEL = "debug" 43*61c4878aSAndroid Build Coastguard Worker 44*61c4878aSAndroid Build Coastguard Worker # The C++ optimization levels for which to generate targets. 45*61c4878aSAndroid Build Coastguard Worker # 46*61c4878aSAndroid Build Coastguard Worker # Supported levels are "debug", "size_optimized", or "speed_optimized". 47*61c4878aSAndroid Build Coastguard Worker pw_C_OPTIMIZATION_LEVELS = [ 48*61c4878aSAndroid Build Coastguard Worker "debug", 49*61c4878aSAndroid Build Coastguard Worker "size_optimized", 50*61c4878aSAndroid Build Coastguard Worker ] 51*61c4878aSAndroid Build Coastguard Worker 52*61c4878aSAndroid Build Coastguard Worker # List of application image GN targets specific to the Pigweed target. 53*61c4878aSAndroid Build Coastguard Worker pw_TARGET_APPLICATIONS = [] 54*61c4878aSAndroid Build Coastguard Worker 55*61c4878aSAndroid Build Coastguard Worker # Gates known broken configurations from building. This is what allows the 56*61c4878aSAndroid Build Coastguard Worker # implicit `all` target to work even though there are known broken targets. 57*61c4878aSAndroid Build Coastguard Worker pw_BUILD_BROKEN_GROUPS = false 58*61c4878aSAndroid Build Coastguard Worker} 59*61c4878aSAndroid Build Coastguard Worker 60*61c4878aSAndroid Build Coastguard Worker# This toolchain is used to force some dependencies to not be parsed by the 61*61c4878aSAndroid Build Coastguard Worker# default toolchain. This is desirable because the default toolchain generates 62*61c4878aSAndroid Build Coastguard Worker# build steps for all parsed targets, not just desired dependencies. 63*61c4878aSAndroid Build Coastguard Workerif (current_toolchain == default_toolchain) { 64*61c4878aSAndroid Build Coastguard Worker pw_non_c_toolchain("non_default_toolchain") { 65*61c4878aSAndroid Build Coastguard Worker } 66*61c4878aSAndroid Build Coastguard Worker} 67*61c4878aSAndroid Build Coastguard Worker 68*61c4878aSAndroid Build Coastguard Worker# List any optimization levels in pw_C_OPTIMIZATION_LEVELS that are not in 69*61c4878aSAndroid Build Coastguard Worker# pw_toolchain_SUPPORTED_C_OPTIMIZATION_LEVELS. This is accomplished by adding 70*61c4878aSAndroid Build Coastguard Worker# all supported levels to the selected levels, then removing all supported 71*61c4878aSAndroid Build Coastguard Worker# levels. The remaining list contains only the unsupported levels. 72*61c4878aSAndroid Build Coastguard Worker_unknown_optimization_levels = 73*61c4878aSAndroid Build Coastguard Worker pw_C_OPTIMIZATION_LEVELS + pw_toolchain_SUPPORTED_C_OPTIMIZATION_LEVELS - 74*61c4878aSAndroid Build Coastguard Worker pw_toolchain_SUPPORTED_C_OPTIMIZATION_LEVELS 75*61c4878aSAndroid Build Coastguard Worker 76*61c4878aSAndroid Build Coastguard Workerassert(_unknown_optimization_levels == [], 77*61c4878aSAndroid Build Coastguard Worker "pw_C_OPTIMIZATION_LEVELS includes unsupported optimization levels: " + 78*61c4878aSAndroid Build Coastguard Worker "$_unknown_optimization_levels") 79*61c4878aSAndroid Build Coastguard Worker 80*61c4878aSAndroid Build Coastguard Worker# Assert that the selected pw_DEFAULT_C_OPTIMIZATION_LEVEL is in the 81*61c4878aSAndroid Build Coastguard Worker# pw_toolchain_SUPPORTED_C_OPTIMIZATION_LEVELS list. This is done by adding then 82*61c4878aSAndroid Build Coastguard Worker# removing all instances of the selected levels from the supported levels list. 83*61c4878aSAndroid Build Coastguard Worker# If the resulting list did not change, then no supported levels were removed, 84*61c4878aSAndroid Build Coastguard Worker# indicating that pw_DEFAULT_C_OPTIMIZATION_LEVEL is not a supported value. 85*61c4878aSAndroid Build Coastguard Workerassert(pw_toolchain_SUPPORTED_C_OPTIMIZATION_LEVELS + 86*61c4878aSAndroid Build Coastguard Worker [ pw_DEFAULT_C_OPTIMIZATION_LEVEL ] - 87*61c4878aSAndroid Build Coastguard Worker [ pw_DEFAULT_C_OPTIMIZATION_LEVEL ] != 88*61c4878aSAndroid Build Coastguard Worker pw_toolchain_SUPPORTED_C_OPTIMIZATION_LEVELS, 89*61c4878aSAndroid Build Coastguard Worker "pw_DEFAULT_C_OPTIMIZATION_LEVEL (\"$pw_DEFAULT_C_OPTIMIZATION_LEVEL" + 90*61c4878aSAndroid Build Coastguard Worker "\") must be one of the supported values: " + 91*61c4878aSAndroid Build Coastguard Worker "$pw_toolchain_SUPPORTED_C_OPTIMIZATION_LEVELS") 92*61c4878aSAndroid Build Coastguard Worker 93*61c4878aSAndroid Build Coastguard Worker# Enumerate all of the different targets that upstream Pigweed will build by 94*61c4878aSAndroid Build Coastguard Worker# default. Downstream projects should not depend on this target; this target is 95*61c4878aSAndroid Build Coastguard Worker# exclusively to facilitate easy upstream development and testing. 96*61c4878aSAndroid Build Coastguard Workergroup("default") { 97*61c4878aSAndroid Build Coastguard Worker deps = [ 98*61c4878aSAndroid Build Coastguard Worker ":docs", 99*61c4878aSAndroid Build Coastguard Worker ":host", 100*61c4878aSAndroid Build Coastguard Worker ":pi_pico", 101*61c4878aSAndroid Build Coastguard Worker ":python.install", 102*61c4878aSAndroid Build Coastguard Worker ":python.lint", 103*61c4878aSAndroid Build Coastguard Worker ":python.tests", 104*61c4878aSAndroid Build Coastguard Worker ":static_analysis", 105*61c4878aSAndroid Build Coastguard Worker ":stm32f429i", 106*61c4878aSAndroid Build Coastguard Worker ":warn_if_modules_out_of_date", 107*61c4878aSAndroid Build Coastguard Worker ] 108*61c4878aSAndroid Build Coastguard Worker} 109*61c4878aSAndroid Build Coastguard Worker 110*61c4878aSAndroid Build Coastguard Worker# This group tries to collect together most build steps in Pigweed's build. 111*61c4878aSAndroid Build Coastguard Worker# Some targets in this group are not included in the main build to keep the 112*61c4878aSAndroid Build Coastguard Worker# default build time down, while others are excluded from the main build because 113*61c4878aSAndroid Build Coastguard Worker# they require additional configuration or don't work on every OS. 114*61c4878aSAndroid Build Coastguard Worker# 115*61c4878aSAndroid Build Coastguard Worker# To increase coverage, use `pw package` to install these packages: 116*61c4878aSAndroid Build Coastguard Worker# boringssl 117*61c4878aSAndroid Build Coastguard Worker# freertos 118*61c4878aSAndroid Build Coastguard Worker# mbedtls 119*61c4878aSAndroid Build Coastguard Worker# micro-ecc 120*61c4878aSAndroid Build Coastguard Worker# nanopb 121*61c4878aSAndroid Build Coastguard Worker# pico_sdk 122*61c4878aSAndroid Build Coastguard Worker# protobuf 123*61c4878aSAndroid Build Coastguard Worker# stm32cube_f4 124*61c4878aSAndroid Build Coastguard Worker# teensy 125*61c4878aSAndroid Build Coastguard Workergroup("extended_default") { 126*61c4878aSAndroid Build Coastguard Worker deps = [ 127*61c4878aSAndroid Build Coastguard Worker ":cpp20_compatibility", 128*61c4878aSAndroid Build Coastguard Worker ":default", 129*61c4878aSAndroid Build Coastguard Worker ":host_clang_debug_dynamic_allocation", 130*61c4878aSAndroid Build Coastguard Worker ":pw_system_demo", 131*61c4878aSAndroid Build Coastguard Worker ":stm32f429i", 132*61c4878aSAndroid Build Coastguard Worker ] 133*61c4878aSAndroid Build Coastguard Worker 134*61c4878aSAndroid Build Coastguard Worker if (host_os != "win") { 135*61c4878aSAndroid Build Coastguard Worker deps += [ 136*61c4878aSAndroid Build Coastguard Worker ":qemu_clang", 137*61c4878aSAndroid Build Coastguard Worker ":qemu_gcc", 138*61c4878aSAndroid Build Coastguard Worker ] 139*61c4878aSAndroid Build Coastguard Worker } 140*61c4878aSAndroid Build Coastguard Worker 141*61c4878aSAndroid Build Coastguard Worker if (host_os == "linux") { 142*61c4878aSAndroid Build Coastguard Worker deps += [ 143*61c4878aSAndroid Build Coastguard Worker ":integration_tests", 144*61c4878aSAndroid Build Coastguard Worker ":runtime_sanitizers", 145*61c4878aSAndroid Build Coastguard Worker ] 146*61c4878aSAndroid Build Coastguard Worker } 147*61c4878aSAndroid Build Coastguard Worker 148*61c4878aSAndroid Build Coastguard Worker # Requires setting pw_arduino_build_CORE_PATH. 149*61c4878aSAndroid Build Coastguard Worker if (pw_arduino_build_CORE_PATH != "") { 150*61c4878aSAndroid Build Coastguard Worker deps += [ ":arduino" ] 151*61c4878aSAndroid Build Coastguard Worker } 152*61c4878aSAndroid Build Coastguard Worker 153*61c4878aSAndroid Build Coastguard Worker # Requires setting pw_third_party_mcuxpresso_SDK. 154*61c4878aSAndroid Build Coastguard Worker if (pw_third_party_mcuxpresso_SDK != "") { 155*61c4878aSAndroid Build Coastguard Worker deps += [ ":mimxrt595" ] 156*61c4878aSAndroid Build Coastguard Worker } 157*61c4878aSAndroid Build Coastguard Worker} 158*61c4878aSAndroid Build Coastguard Worker 159*61c4878aSAndroid Build Coastguard Worker# Verify that this BUILD.gn file is only used by Pigweed itself. 160*61c4878aSAndroid Build Coastguard Workerassert(get_path_info("//", "abspath") == get_path_info(".", "abspath"), 161*61c4878aSAndroid Build Coastguard Worker "Pigweed's top-level BUILD.gn may only be used when building upstream " + 162*61c4878aSAndroid Build Coastguard Worker "Pigweed. To pull all Pigweed code into your build, import " + 163*61c4878aSAndroid Build Coastguard Worker "\$dir_pigweed/modules.gni and create a top-level pw_test_group " + 164*61c4878aSAndroid Build Coastguard Worker "that depends on the tests in pw_module_tests. See " + 165*61c4878aSAndroid Build Coastguard Worker "https://pigweed.dev/build_system.html for details.") 166*61c4878aSAndroid Build Coastguard Worker 167*61c4878aSAndroid Build Coastguard Worker_update_or_check_modules_lists = { 168*61c4878aSAndroid Build Coastguard Worker script = "$dir_pw_build/py/pw_build/generate_modules_lists.py" 169*61c4878aSAndroid Build Coastguard Worker args = [ 170*61c4878aSAndroid Build Coastguard Worker rebase_path(".", root_build_dir), 171*61c4878aSAndroid Build Coastguard Worker rebase_path("PIGWEED_MODULES", root_build_dir), 172*61c4878aSAndroid Build Coastguard Worker rebase_path("$dir_pw_build/generated_pigweed_modules_lists.gni", 173*61c4878aSAndroid Build Coastguard Worker root_build_dir), 174*61c4878aSAndroid Build Coastguard Worker ] 175*61c4878aSAndroid Build Coastguard Worker inputs = [ 176*61c4878aSAndroid Build Coastguard Worker "$dir_pw_build/generated_pigweed_modules_lists.gni", 177*61c4878aSAndroid Build Coastguard Worker "PIGWEED_MODULES", 178*61c4878aSAndroid Build Coastguard Worker ] 179*61c4878aSAndroid Build Coastguard Worker} 180*61c4878aSAndroid Build Coastguard Worker 181*61c4878aSAndroid Build Coastguard Worker# There are races if the module check and module file update are run at the same 182*61c4878aSAndroid Build Coastguard Worker# time. Force them to be serialized to prevent races. As long as the generated 183*61c4878aSAndroid Build Coastguard Worker# module file is up to date, they'll pass. 184*61c4878aSAndroid Build Coastguard Workerpool("module_check_pool") { 185*61c4878aSAndroid Build Coastguard Worker depth = 1 186*61c4878aSAndroid Build Coastguard Worker} 187*61c4878aSAndroid Build Coastguard Worker 188*61c4878aSAndroid Build Coastguard Worker# Warns if PIGWEED_MODULES is not up-to-date and sorted. 189*61c4878aSAndroid Build Coastguard Workeraction("warn_if_modules_out_of_date") { 190*61c4878aSAndroid Build Coastguard Worker forward_variables_from(_update_or_check_modules_lists, "*") 191*61c4878aSAndroid Build Coastguard Worker outputs = [ "$target_gen_dir/$target_name.passed" ] 192*61c4878aSAndroid Build Coastguard Worker args += [ 193*61c4878aSAndroid Build Coastguard Worker "--mode=WARN", 194*61c4878aSAndroid Build Coastguard Worker "--stamp", 195*61c4878aSAndroid Build Coastguard Worker ] + rebase_path(outputs, root_build_dir) 196*61c4878aSAndroid Build Coastguard Worker pool = ":module_check_pool" 197*61c4878aSAndroid Build Coastguard Worker} 198*61c4878aSAndroid Build Coastguard Worker 199*61c4878aSAndroid Build Coastguard Worker# Fails if PIGWEED_MODULES is not up-to-date and sorted. 200*61c4878aSAndroid Build Coastguard Workeraction("check_modules") { 201*61c4878aSAndroid Build Coastguard Worker forward_variables_from(_update_or_check_modules_lists, "*") 202*61c4878aSAndroid Build Coastguard Worker outputs = [ "$target_gen_dir/$target_name.ALWAYS_RERUN" ] # Never created 203*61c4878aSAndroid Build Coastguard Worker args += [ "--mode=CHECK" ] 204*61c4878aSAndroid Build Coastguard Worker pool = ":module_check_pool" 205*61c4878aSAndroid Build Coastguard Worker} 206*61c4878aSAndroid Build Coastguard Worker 207*61c4878aSAndroid Build Coastguard Worker# Run this command after adding an item to PIGWEED_MODULES to update the 208*61c4878aSAndroid Build Coastguard Worker# generated .gni with Pigweed modules lists. 209*61c4878aSAndroid Build Coastguard Workeraction("update_modules") { 210*61c4878aSAndroid Build Coastguard Worker forward_variables_from(_update_or_check_modules_lists, "*") 211*61c4878aSAndroid Build Coastguard Worker outputs = [ "$target_gen_dir/$target_name.ALWAYS_RERUN" ] # Never created 212*61c4878aSAndroid Build Coastguard Worker args += [ "--mode=UPDATE" ] 213*61c4878aSAndroid Build Coastguard Worker pool = ":module_check_pool" 214*61c4878aSAndroid Build Coastguard Worker} 215*61c4878aSAndroid Build Coastguard Worker 216*61c4878aSAndroid Build Coastguard Workergroup("pw_system_demo") { 217*61c4878aSAndroid Build Coastguard Worker deps = [ "$dir_pw_system:system_examples(:non_default_toolchain)" ] 218*61c4878aSAndroid Build Coastguard Worker} 219*61c4878aSAndroid Build Coastguard Worker 220*61c4878aSAndroid Build Coastguard Workergroup("pi_pico") { 221*61c4878aSAndroid Build Coastguard Worker if (PICO_SRC_DIR != "") { 222*61c4878aSAndroid Build Coastguard Worker deps = [ ":pigweed_default(targets/rp2040:rp2040.size_optimized)" ] 223*61c4878aSAndroid Build Coastguard Worker } 224*61c4878aSAndroid Build Coastguard Worker} 225*61c4878aSAndroid Build Coastguard Worker 226*61c4878aSAndroid Build Coastguard Worker_internal_toolchains = "$dir_pigweed/targets/host/pigweed_internal" 227*61c4878aSAndroid Build Coastguard Worker 228*61c4878aSAndroid Build Coastguard Worker# This template generates a group that builds pigweed_default with a particular 229*61c4878aSAndroid Build Coastguard Worker# toolchain. 230*61c4878aSAndroid Build Coastguard Workertemplate("_build_pigweed_default_at_all_optimization_levels") { 231*61c4878aSAndroid Build Coastguard Worker _toolchain_prefix = invoker.toolchain_prefix 232*61c4878aSAndroid Build Coastguard Worker 233*61c4878aSAndroid Build Coastguard Worker group(target_name) { 234*61c4878aSAndroid Build Coastguard Worker deps = [ 235*61c4878aSAndroid Build Coastguard Worker ":pigweed_default(${_toolchain_prefix}$pw_DEFAULT_C_OPTIMIZATION_LEVEL)", 236*61c4878aSAndroid Build Coastguard Worker ] 237*61c4878aSAndroid Build Coastguard Worker } 238*61c4878aSAndroid Build Coastguard Worker 239*61c4878aSAndroid Build Coastguard Worker foreach(optimization, pw_C_OPTIMIZATION_LEVELS) { 240*61c4878aSAndroid Build Coastguard Worker group(target_name + "_$optimization") { 241*61c4878aSAndroid Build Coastguard Worker deps = [ ":pigweed_default($_toolchain_prefix$optimization)" ] 242*61c4878aSAndroid Build Coastguard Worker } 243*61c4878aSAndroid Build Coastguard Worker } 244*61c4878aSAndroid Build Coastguard Worker} 245*61c4878aSAndroid Build Coastguard Worker 246*61c4878aSAndroid Build Coastguard Worker# Select a default toolchain based on host OS. 247*61c4878aSAndroid Build Coastguard Workerif (host_os == "linux") { 248*61c4878aSAndroid Build Coastguard Worker _default_toolchain_prefix = "$_internal_toolchains:pw_strict_host_clang_" 249*61c4878aSAndroid Build Coastguard Worker} else if (host_os == "mac") { 250*61c4878aSAndroid Build Coastguard Worker _default_toolchain_prefix = "$_internal_toolchains:pw_strict_host_clang_" 251*61c4878aSAndroid Build Coastguard Worker} else if (host_os == "win") { 252*61c4878aSAndroid Build Coastguard Worker _default_toolchain_prefix = "$_internal_toolchains:pw_strict_host_gcc_" 253*61c4878aSAndroid Build Coastguard Worker} else { 254*61c4878aSAndroid Build Coastguard Worker assert(false, "Please define a host config for your system: $host_os") 255*61c4878aSAndroid Build Coastguard Worker} 256*61c4878aSAndroid Build Coastguard Worker 257*61c4878aSAndroid Build Coastguard Worker# Below are a list of GN targets you can build to force Pigweed to build for a 258*61c4878aSAndroid Build Coastguard Worker# specific Pigweed target. 259*61c4878aSAndroid Build Coastguard Worker_build_pigweed_default_at_all_optimization_levels("host") { 260*61c4878aSAndroid Build Coastguard Worker toolchain_prefix = _default_toolchain_prefix 261*61c4878aSAndroid Build Coastguard Worker} 262*61c4878aSAndroid Build Coastguard Worker 263*61c4878aSAndroid Build Coastguard Worker_build_pigweed_default_at_all_optimization_levels("host_clang") { 264*61c4878aSAndroid Build Coastguard Worker toolchain_prefix = "$_internal_toolchains:pw_strict_host_clang_" 265*61c4878aSAndroid Build Coastguard Worker} 266*61c4878aSAndroid Build Coastguard Worker 267*61c4878aSAndroid Build Coastguard Worker# GCC is only supported for Windows. Pigweed doesn't yet provide a Windows 268*61c4878aSAndroid Build Coastguard Worker# clang toolchain, and Pigweed does not provide gcc toolchains for macOS and 269*61c4878aSAndroid Build Coastguard Worker# Linux. 270*61c4878aSAndroid Build Coastguard Workerif (host_os == "win") { 271*61c4878aSAndroid Build Coastguard Worker _build_pigweed_default_at_all_optimization_levels("host_gcc") { 272*61c4878aSAndroid Build Coastguard Worker toolchain_prefix = "$_internal_toolchains:pw_strict_host_gcc_" 273*61c4878aSAndroid Build Coastguard Worker } 274*61c4878aSAndroid Build Coastguard Worker} 275*61c4878aSAndroid Build Coastguard Worker 276*61c4878aSAndroid Build Coastguard Workerif (pw_third_party_mcuxpresso_SDK != "") { 277*61c4878aSAndroid Build Coastguard Worker _build_pigweed_default_at_all_optimization_levels("mimxrt595") { 278*61c4878aSAndroid Build Coastguard Worker toolchain_prefix = "$dir_pigweed/targets/mimxrt595_evk:mimxrt595_evk_" 279*61c4878aSAndroid Build Coastguard Worker } 280*61c4878aSAndroid Build Coastguard Worker 281*61c4878aSAndroid Build Coastguard Worker _build_pigweed_default_at_all_optimization_levels("mimxrt595_freertos") { 282*61c4878aSAndroid Build Coastguard Worker toolchain_prefix = 283*61c4878aSAndroid Build Coastguard Worker "$dir_pigweed/targets/mimxrt595_evk_freertos:mimxrt595_evk_freertos_" 284*61c4878aSAndroid Build Coastguard Worker } 285*61c4878aSAndroid Build Coastguard Worker} 286*61c4878aSAndroid Build Coastguard Worker 287*61c4878aSAndroid Build Coastguard Workerif (dir_pw_third_party_ambiq_SDK != "") { 288*61c4878aSAndroid Build Coastguard Worker _build_pigweed_default_at_all_optimization_levels("apollo4") { 289*61c4878aSAndroid Build Coastguard Worker toolchain_prefix = "$dir_pigweed/targets/apollo4:apollo4_" 290*61c4878aSAndroid Build Coastguard Worker } 291*61c4878aSAndroid Build Coastguard Worker} 292*61c4878aSAndroid Build Coastguard Worker 293*61c4878aSAndroid Build Coastguard Worker_build_pigweed_default_at_all_optimization_levels("stm32f429i") { 294*61c4878aSAndroid Build Coastguard Worker toolchain_prefix = "$dir_pigweed/targets/stm32f429i_disc1:stm32f429i_disc1_" 295*61c4878aSAndroid Build Coastguard Worker} 296*61c4878aSAndroid Build Coastguard Worker 297*61c4878aSAndroid Build Coastguard Workerif (pw_arduino_build_CORE_PATH != "") { 298*61c4878aSAndroid Build Coastguard Worker _build_pigweed_default_at_all_optimization_levels("arduino") { 299*61c4878aSAndroid Build Coastguard Worker toolchain_prefix = "$dir_pigweed/targets/arduino:arduino_" 300*61c4878aSAndroid Build Coastguard Worker } 301*61c4878aSAndroid Build Coastguard Worker} 302*61c4878aSAndroid Build Coastguard Worker 303*61c4878aSAndroid Build Coastguard Worker# TODO: b/244604080 - Inline string tests are too big to fit in the QEMU firmware 304*61c4878aSAndroid Build Coastguard Worker# except under a size-optimized build. For now, only build size-optimized. 305*61c4878aSAndroid Build Coastguard Workerif (pw_BUILD_BROKEN_GROUPS) { 306*61c4878aSAndroid Build Coastguard Worker _build_pigweed_default_at_all_optimization_levels("qemu_gcc") { 307*61c4878aSAndroid Build Coastguard Worker toolchain_prefix = 308*61c4878aSAndroid Build Coastguard Worker "$dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_gcc_" 309*61c4878aSAndroid Build Coastguard Worker } 310*61c4878aSAndroid Build Coastguard Worker _build_pigweed_default_at_all_optimization_levels("qemu_clang") { 311*61c4878aSAndroid Build Coastguard Worker toolchain_prefix = 312*61c4878aSAndroid Build Coastguard Worker "$dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_clang_" 313*61c4878aSAndroid Build Coastguard Worker } 314*61c4878aSAndroid Build Coastguard Worker} else { 315*61c4878aSAndroid Build Coastguard Worker group("qemu_gcc_size_optimized") { 316*61c4878aSAndroid Build Coastguard Worker deps = [ ":pigweed_default($dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_gcc_size_optimized)" ] 317*61c4878aSAndroid Build Coastguard Worker } 318*61c4878aSAndroid Build Coastguard Worker group("qemu_gcc") { 319*61c4878aSAndroid Build Coastguard Worker deps = [ ":qemu_gcc_size_optimized" ] 320*61c4878aSAndroid Build Coastguard Worker } 321*61c4878aSAndroid Build Coastguard Worker group("qemu_clang_size_optimized") { 322*61c4878aSAndroid Build Coastguard Worker deps = [ ":pigweed_default($dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_clang_size_optimized)" ] 323*61c4878aSAndroid Build Coastguard Worker 324*61c4878aSAndroid Build Coastguard Worker if (pw_rust_ENABLE_EXPERIMENTAL_BUILD) { 325*61c4878aSAndroid Build Coastguard Worker deps += [ "$dir_pw_rust/examples/basic_executable:basic_executable($dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_clang_debug)" ] 326*61c4878aSAndroid Build Coastguard Worker deps += [ "$dir_pw_rust/examples/basic_executable:basic_executable($dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_clang_size_optimized)" ] 327*61c4878aSAndroid Build Coastguard Worker deps += [ "$dir_pw_rust/examples/basic_executable:basic_executable($dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_clang_speed_optimized)" ] 328*61c4878aSAndroid Build Coastguard Worker } 329*61c4878aSAndroid Build Coastguard Worker } 330*61c4878aSAndroid Build Coastguard Worker group("qemu_clang") { 331*61c4878aSAndroid Build Coastguard Worker deps = [ ":qemu_clang_size_optimized" ] 332*61c4878aSAndroid Build Coastguard Worker } 333*61c4878aSAndroid Build Coastguard Worker} 334*61c4878aSAndroid Build Coastguard Worker 335*61c4878aSAndroid Build Coastguard Worker# Run clang-tidy on pigweed_default with pw_strict_host_clang_debug toolchain options. 336*61c4878aSAndroid Build Coastguard Worker# Make sure to invoke gn clean out when any relevant .clang-tidy 337*61c4878aSAndroid Build Coastguard Worker# file is updated. 338*61c4878aSAndroid Build Coastguard Workergroup("static_analysis") { 339*61c4878aSAndroid Build Coastguard Worker # Static analysis is only supported on Linux and macOS using clang-tidy. 340*61c4878aSAndroid Build Coastguard Worker if (host_os != "win") { 341*61c4878aSAndroid Build Coastguard Worker _toolchain = "$_internal_toolchains:pw_strict_host_clang_debug" 342*61c4878aSAndroid Build Coastguard Worker deps = [ ":pigweed_default($_toolchain.static_analysis)" ] 343*61c4878aSAndroid Build Coastguard Worker } 344*61c4878aSAndroid Build Coastguard Worker} 345*61c4878aSAndroid Build Coastguard Worker 346*61c4878aSAndroid Build Coastguard Workerif (pw_android_toolchain_NDK_PATH != "") { 347*61c4878aSAndroid Build Coastguard Worker group("android") { 348*61c4878aSAndroid Build Coastguard Worker deps = [] 349*61c4878aSAndroid Build Coastguard Worker foreach(_cpu, pw_android_toolchain_cpu_targets) { 350*61c4878aSAndroid Build Coastguard Worker _toolchain_prefix = "$dir_pigweed/targets/android:${_cpu}_android_" 351*61c4878aSAndroid Build Coastguard Worker deps += [ 352*61c4878aSAndroid Build Coastguard Worker ":pigweed_default($_toolchain_prefix$pw_DEFAULT_C_OPTIMIZATION_LEVEL)", 353*61c4878aSAndroid Build Coastguard Worker ] 354*61c4878aSAndroid Build Coastguard Worker } 355*61c4878aSAndroid Build Coastguard Worker } 356*61c4878aSAndroid Build Coastguard Worker 357*61c4878aSAndroid Build Coastguard Worker foreach(_cpu, pw_android_toolchain_cpu_targets) { 358*61c4878aSAndroid Build Coastguard Worker _build_pigweed_default_at_all_optimization_levels("${_cpu}_android") { 359*61c4878aSAndroid Build Coastguard Worker toolchain_prefix = "$dir_pigweed/targets/android:${_cpu}_android_" 360*61c4878aSAndroid Build Coastguard Worker } 361*61c4878aSAndroid Build Coastguard Worker } 362*61c4878aSAndroid Build Coastguard Worker} 363*61c4878aSAndroid Build Coastguard Worker 364*61c4878aSAndroid Build Coastguard Workergroup("docs") { 365*61c4878aSAndroid Build Coastguard Worker deps = [ "$dir_pigweed/docs($dir_pigweed/targets/docs)" ] 366*61c4878aSAndroid Build Coastguard Worker} 367*61c4878aSAndroid Build Coastguard Worker 368*61c4878aSAndroid Build Coastguard Worker# Tests that are run as host actions, such as tests of the build system. 369*61c4878aSAndroid Build Coastguard Worker# 370*61c4878aSAndroid Build Coastguard Worker# These are distinguished from `integration_tests` in that they are short 371*61c4878aSAndroid Build Coastguard Worker# unit tests of specific functionality that should be tested in the default 372*61c4878aSAndroid Build Coastguard Worker# build. 373*61c4878aSAndroid Build Coastguard Workergroup("action_tests") { 374*61c4878aSAndroid Build Coastguard Worker _default_tc = _default_toolchain_prefix + pw_DEFAULT_C_OPTIMIZATION_LEVEL 375*61c4878aSAndroid Build Coastguard Worker deps = [ ":pw_action_tests.run($_default_tc)" ] 376*61c4878aSAndroid Build Coastguard Worker} 377*61c4878aSAndroid Build Coastguard Worker 378*61c4878aSAndroid Build Coastguard Worker# Tests larger than unit tests, typically run in a specific configuration. 379*61c4878aSAndroid Build Coastguard Workergroup("integration_tests") { 380*61c4878aSAndroid Build Coastguard Worker _default_tc = _default_toolchain_prefix + pw_DEFAULT_C_OPTIMIZATION_LEVEL 381*61c4878aSAndroid Build Coastguard Worker deps = [ ":pw_integration_tests.run($_default_tc)" ] 382*61c4878aSAndroid Build Coastguard Worker} 383*61c4878aSAndroid Build Coastguard Worker 384*61c4878aSAndroid Build Coastguard Workergroup("pip_constraint_update") { 385*61c4878aSAndroid Build Coastguard Worker public_deps = [] 386*61c4878aSAndroid Build Coastguard Worker 387*61c4878aSAndroid Build Coastguard Worker if (current_toolchain == pw_build_PYTHON_TOOLCHAIN) { 388*61c4878aSAndroid Build Coastguard Worker public_deps += [ "$dir_pw_env_setup:pigweed_build_venv._compile_requirements($pw_build_PYTHON_TOOLCHAIN)" ] 389*61c4878aSAndroid Build Coastguard Worker } else { 390*61c4878aSAndroid Build Coastguard Worker public_deps = [ ":${target_name}($pw_build_PYTHON_TOOLCHAIN)" ] 391*61c4878aSAndroid Build Coastguard Worker } 392*61c4878aSAndroid Build Coastguard Worker} 393*61c4878aSAndroid Build Coastguard Worker 394*61c4878aSAndroid Build Coastguard Workergroup("pip_vendor_wheels") { 395*61c4878aSAndroid Build Coastguard Worker public_deps = [] 396*61c4878aSAndroid Build Coastguard Worker 397*61c4878aSAndroid Build Coastguard Worker if (current_toolchain == pw_build_PYTHON_TOOLCHAIN) { 398*61c4878aSAndroid Build Coastguard Worker public_deps += [ "$dir_pw_env_setup:pigweed_build_venv.vendor_wheels($pw_build_PYTHON_TOOLCHAIN)" ] 399*61c4878aSAndroid Build Coastguard Worker } else { 400*61c4878aSAndroid Build Coastguard Worker public_deps = [ ":${target_name}($pw_build_PYTHON_TOOLCHAIN)" ] 401*61c4878aSAndroid Build Coastguard Worker } 402*61c4878aSAndroid Build Coastguard Worker} 403*61c4878aSAndroid Build Coastguard Worker 404*61c4878aSAndroid Build Coastguard Workergroup("fuzzers") { 405*61c4878aSAndroid Build Coastguard Worker deps = [] 406*61c4878aSAndroid Build Coastguard Worker 407*61c4878aSAndroid Build Coastguard Worker if (host_os != "win" && dir_pw_third_party_fuzztest != "") { 408*61c4878aSAndroid Build Coastguard Worker # Coverage-guided fuzzing is only supported on Linux and MacOS using clang. 409*61c4878aSAndroid Build Coastguard Worker # Fuzztest-based fuzzers will run in unit test mode. libFuzzer-based fuzzers 410*61c4878aSAndroid Build Coastguard Worker # will only build. 411*61c4878aSAndroid Build Coastguard Worker _clang_fuzz_tc = _default_toolchain_prefix + "fuzz" 412*61c4878aSAndroid Build Coastguard Worker deps += [ ":pw_module_tests.run($_clang_fuzz_tc)" ] 413*61c4878aSAndroid Build Coastguard Worker } 414*61c4878aSAndroid Build Coastguard Worker 415*61c4878aSAndroid Build Coastguard Worker # Also build (but do not run) bespoke fuzzers. 416*61c4878aSAndroid Build Coastguard Worker if (!pw_toolchain_OSS_FUZZ_ENABLED) { 417*61c4878aSAndroid Build Coastguard Worker _default_tc = _default_toolchain_prefix + pw_DEFAULT_C_OPTIMIZATION_LEVEL 418*61c4878aSAndroid Build Coastguard Worker deps += [ ":pw_custom_fuzzers($_default_tc)" ] 419*61c4878aSAndroid Build Coastguard Worker } 420*61c4878aSAndroid Build Coastguard Worker} 421*61c4878aSAndroid Build Coastguard Worker 422*61c4878aSAndroid Build Coastguard Worker# Build-only target for OSS-Fuzz. No-op unless OSS-Fuzz is enabled. 423*61c4878aSAndroid Build Coastguard Workergroup("oss_fuzz") { 424*61c4878aSAndroid Build Coastguard Worker if (pw_toolchain_OSS_FUZZ_ENABLED) { 425*61c4878aSAndroid Build Coastguard Worker _clang_fuzz_tc = _default_toolchain_prefix + "fuzz" 426*61c4878aSAndroid Build Coastguard Worker deps = [ ":pw_module_tests($_clang_fuzz_tc)" ] 427*61c4878aSAndroid Build Coastguard Worker } 428*61c4878aSAndroid Build Coastguard Worker} 429*61c4878aSAndroid Build Coastguard Worker 430*61c4878aSAndroid Build Coastguard Workergroup("asan") { 431*61c4878aSAndroid Build Coastguard Worker # TODO: b/302181521 - asan doesn't work on Windows yet. 432*61c4878aSAndroid Build Coastguard Worker if (host_os != "win") { 433*61c4878aSAndroid Build Coastguard Worker deps = [ ":pw_module_tests.run($dir_pigweed/targets/host:host_clang_asan)" ] 434*61c4878aSAndroid Build Coastguard Worker } 435*61c4878aSAndroid Build Coastguard Worker} 436*61c4878aSAndroid Build Coastguard Worker 437*61c4878aSAndroid Build Coastguard Worker# TODO: b/234876100 - msan will not work without false positives until the C++ 438*61c4878aSAndroid Build Coastguard Worker# standard library included in the sysroot has a variant built with msan. 439*61c4878aSAndroid Build Coastguard Workergroup("msan") { 440*61c4878aSAndroid Build Coastguard Worker # TODO: b/259695498 - msan doesn't work on macOS yet. 441*61c4878aSAndroid Build Coastguard Worker # TODO: b/302181521 - msan doesn't work on Windows yet. 442*61c4878aSAndroid Build Coastguard Worker if (pw_BUILD_BROKEN_GROUPS) { 443*61c4878aSAndroid Build Coastguard Worker deps = [ ":pw_module_tests.run($dir_pigweed/targets/host:host_clang_msan)" ] 444*61c4878aSAndroid Build Coastguard Worker } 445*61c4878aSAndroid Build Coastguard Worker} 446*61c4878aSAndroid Build Coastguard Worker 447*61c4878aSAndroid Build Coastguard Workergroup("tsan") { 448*61c4878aSAndroid Build Coastguard Worker # TODO: b/302181521 - tsan doesn't work on Windows yet. 449*61c4878aSAndroid Build Coastguard Worker if (host_os != "win") { 450*61c4878aSAndroid Build Coastguard Worker deps = [ ":pw_module_tests.run($dir_pigweed/targets/host:host_clang_tsan)" ] 451*61c4878aSAndroid Build Coastguard Worker } 452*61c4878aSAndroid Build Coastguard Worker} 453*61c4878aSAndroid Build Coastguard Worker 454*61c4878aSAndroid Build Coastguard Workergroup("ubsan") { 455*61c4878aSAndroid Build Coastguard Worker # TODO: b/259695498 - ubsan doesn't work on macOS yet. 456*61c4878aSAndroid Build Coastguard Worker # TODO: b/302181521 - ubsan doesn't work on Windows yet. 457*61c4878aSAndroid Build Coastguard Worker if ((host_os != "win" && host_os != "mac") || pw_BUILD_BROKEN_GROUPS) { 458*61c4878aSAndroid Build Coastguard Worker deps = 459*61c4878aSAndroid Build Coastguard Worker [ ":pw_module_tests.run($dir_pigweed/targets/host:host_clang_ubsan)" ] 460*61c4878aSAndroid Build Coastguard Worker } 461*61c4878aSAndroid Build Coastguard Worker} 462*61c4878aSAndroid Build Coastguard Worker 463*61c4878aSAndroid Build Coastguard Workergroup("ubsan_heuristic") { 464*61c4878aSAndroid Build Coastguard Worker # TODO: b/259695498 - ubsan_heuristic doesn't work on macOS yet. 465*61c4878aSAndroid Build Coastguard Worker # TODO: b/302181521 - ubsan doesn't work on Windows yet. 466*61c4878aSAndroid Build Coastguard Worker if ((host_os != "win" && host_os != "mac") || pw_BUILD_BROKEN_GROUPS) { 467*61c4878aSAndroid Build Coastguard Worker deps = [ ":pw_module_tests.run($dir_pigweed/targets/host:host_clang_ubsan_heuristic)" ] 468*61c4878aSAndroid Build Coastguard Worker } 469*61c4878aSAndroid Build Coastguard Worker} 470*61c4878aSAndroid Build Coastguard Worker 471*61c4878aSAndroid Build Coastguard Workergroup("runtime_sanitizers") { 472*61c4878aSAndroid Build Coastguard Worker if (host_os != "win" || pw_BUILD_BROKEN_GROUPS) { 473*61c4878aSAndroid Build Coastguard Worker deps = [ 474*61c4878aSAndroid Build Coastguard Worker ":asan", 475*61c4878aSAndroid Build Coastguard Worker ":tsan", 476*61c4878aSAndroid Build Coastguard Worker ":ubsan", 477*61c4878aSAndroid Build Coastguard Worker ] 478*61c4878aSAndroid Build Coastguard Worker 479*61c4878aSAndroid Build Coastguard Worker if (pw_BUILD_BROKEN_GROUPS) { 480*61c4878aSAndroid Build Coastguard Worker # TODO: b/234876100 - msan will not work until the C++ standard library 481*61c4878aSAndroid Build Coastguard Worker # included in the sysroot has a variant built with msan. 482*61c4878aSAndroid Build Coastguard Worker deps += [ ":msan" ] 483*61c4878aSAndroid Build Coastguard Worker 484*61c4878aSAndroid Build Coastguard Worker # No ubsan_heuristic, which may have false positives. 485*61c4878aSAndroid Build Coastguard Worker deps += [ ":ubsan_heuristic" ] 486*61c4878aSAndroid Build Coastguard Worker } 487*61c4878aSAndroid Build Coastguard Worker } 488*61c4878aSAndroid Build Coastguard Worker} 489*61c4878aSAndroid Build Coastguard Worker 490*61c4878aSAndroid Build Coastguard Workergroup("coverage") { 491*61c4878aSAndroid Build Coastguard Worker if (host_os == "linux") { 492*61c4878aSAndroid Build Coastguard Worker deps = [ ":coverage_report($dir_pigweed/targets/host:host_clang_coverage)" ] 493*61c4878aSAndroid Build Coastguard Worker } 494*61c4878aSAndroid Build Coastguard Worker} 495*61c4878aSAndroid Build Coastguard Worker 496*61c4878aSAndroid Build Coastguard Workerpw_python_group("python") { 497*61c4878aSAndroid Build Coastguard Worker python_deps = [ 498*61c4878aSAndroid Build Coastguard Worker "$dir_pw_env_setup:python($pw_build_PYTHON_TOOLCHAIN)", 499*61c4878aSAndroid Build Coastguard Worker "$dir_pw_env_setup:sample_project_action($pw_build_PYTHON_TOOLCHAIN)", 500*61c4878aSAndroid Build Coastguard Worker "$dir_pw_env_setup:target_support_packages($pw_build_PYTHON_TOOLCHAIN)", 501*61c4878aSAndroid Build Coastguard Worker ] 502*61c4878aSAndroid Build Coastguard Worker} 503*61c4878aSAndroid Build Coastguard Worker 504*61c4878aSAndroid Build Coastguard Workergroup("pigweed_pypi_distribution") { 505*61c4878aSAndroid Build Coastguard Worker deps = [ 506*61c4878aSAndroid Build Coastguard Worker "$dir_pw_env_setup:generate_hdlc_proto_rpc_tokenizer_distribution.wheel($pw_build_PYTHON_TOOLCHAIN)", 507*61c4878aSAndroid Build Coastguard Worker "$dir_pw_env_setup:pypi_pigweed_python_source_tree.wheel($pw_build_PYTHON_TOOLCHAIN)", 508*61c4878aSAndroid Build Coastguard Worker ] 509*61c4878aSAndroid Build Coastguard Worker} 510*61c4878aSAndroid Build Coastguard Worker 511*61c4878aSAndroid Build Coastguard Worker# Build host-only tooling. 512*61c4878aSAndroid Build Coastguard Workergroup("host_tools") { 513*61c4878aSAndroid Build Coastguard Worker deps = [] 514*61c4878aSAndroid Build Coastguard Worker 515*61c4878aSAndroid Build Coastguard Worker if (pw_rust_ENABLE_EXPERIMENTAL_BUILD) { 516*61c4878aSAndroid Build Coastguard Worker deps += [ "$dir_pw_rust/examples/basic_executable:basic_executable($dir_pigweed/targets/host:host_clang_debug)" ] 517*61c4878aSAndroid Build Coastguard Worker deps += [ "$dir_pw_rust/examples/basic_executable:basic_executable($dir_pigweed/targets/host:host_clang_speed_optimized)" ] 518*61c4878aSAndroid Build Coastguard Worker deps += [ "$dir_pw_rust/examples/basic_executable:basic_executable($dir_pigweed/targets/host:host_clang_size_optimized)" ] 519*61c4878aSAndroid Build Coastguard Worker deps += [ "$dir_pw_rust/examples/bindgen:test_add($dir_pigweed/targets/host:host_clang_debug)" ] 520*61c4878aSAndroid Build Coastguard Worker } 521*61c4878aSAndroid Build Coastguard Worker} 522*61c4878aSAndroid Build Coastguard Worker 523*61c4878aSAndroid Build Coastguard Worker# By default, Pigweed will build this target when invoking ninja. 524*61c4878aSAndroid Build Coastguard Workergroup("pigweed_default") { 525*61c4878aSAndroid Build Coastguard Worker deps = [] 526*61c4878aSAndroid Build Coastguard Worker 527*61c4878aSAndroid Build Coastguard Worker # Prevent the default toolchain from parsing any other BUILD.gn files. 528*61c4878aSAndroid Build Coastguard Worker if (current_toolchain != default_toolchain) { 529*61c4878aSAndroid Build Coastguard Worker _is_host_toolchain = defined(pw_toolchain_SCOPE.is_host_toolchain) && 530*61c4878aSAndroid Build Coastguard Worker pw_toolchain_SCOPE.is_host_toolchain 531*61c4878aSAndroid Build Coastguard Worker 532*61c4878aSAndroid Build Coastguard Worker deps = [ ":apps" ] 533*61c4878aSAndroid Build Coastguard Worker 534*61c4878aSAndroid Build Coastguard Worker # Upstream GoogleTest assumes the presence of a POSIX filesystem. If an 535*61c4878aSAndroid Build Coastguard Worker # external gtest backend has been provided, limit the tests to host-only. 536*61c4878aSAndroid Build Coastguard Worker if (pw_unit_test_BACKEND == "$dir_pw_unit_test:light" || 537*61c4878aSAndroid Build Coastguard Worker _is_host_toolchain) { 538*61c4878aSAndroid Build Coastguard Worker if (pw_unit_test_AUTOMATIC_RUNNER == "") { 539*61c4878aSAndroid Build Coastguard Worker # Without a test runner defined, build the tests but don't run them. 540*61c4878aSAndroid Build Coastguard Worker deps += [ ":pw_module_tests" ] 541*61c4878aSAndroid Build Coastguard Worker } else { 542*61c4878aSAndroid Build Coastguard Worker # With a test runner, depend on the run targets so they run with the 543*61c4878aSAndroid Build Coastguard Worker # build. 544*61c4878aSAndroid Build Coastguard Worker deps += [ ":pw_module_tests.run" ] 545*61c4878aSAndroid Build Coastguard Worker } 546*61c4878aSAndroid Build Coastguard Worker 547*61c4878aSAndroid Build Coastguard Worker # Add performance tests to the automatic build 548*61c4878aSAndroid Build Coastguard Worker deps += [ ":pw_perf_tests" ] 549*61c4878aSAndroid Build Coastguard Worker } 550*61c4878aSAndroid Build Coastguard Worker 551*61c4878aSAndroid Build Coastguard Worker # Add action tests to the automatic build 552*61c4878aSAndroid Build Coastguard Worker if (_is_host_toolchain) { 553*61c4878aSAndroid Build Coastguard Worker deps += [ ":pw_action_tests.run" ] 554*61c4878aSAndroid Build Coastguard Worker } 555*61c4878aSAndroid Build Coastguard Worker 556*61c4878aSAndroid Build Coastguard Worker # Trace examples currently only support running on non-windows host 557*61c4878aSAndroid Build Coastguard Worker if (_is_host_toolchain && host_os != "win") { 558*61c4878aSAndroid Build Coastguard Worker deps += [ "$dir_pw_trace:trace_example_basic" ] 559*61c4878aSAndroid Build Coastguard Worker 560*61c4878aSAndroid Build Coastguard Worker if (get_label_info(pw_trace_BACKEND, "label_no_toolchain") == 561*61c4878aSAndroid Build Coastguard Worker get_label_info(":pw_trace_tokenized", "label_no_toolchain")) { 562*61c4878aSAndroid Build Coastguard Worker deps += [ 563*61c4878aSAndroid Build Coastguard Worker "$dir_pw_trace_tokenized:trace_tokenized_example_basic", 564*61c4878aSAndroid Build Coastguard Worker "$dir_pw_trace_tokenized:trace_tokenized_example_filter", 565*61c4878aSAndroid Build Coastguard Worker "$dir_pw_trace_tokenized:trace_tokenized_example_linux_group_by_tid", 566*61c4878aSAndroid Build Coastguard Worker "$dir_pw_trace_tokenized:trace_tokenized_example_rpc", 567*61c4878aSAndroid Build Coastguard Worker "$dir_pw_trace_tokenized:trace_tokenized_example_trigger", 568*61c4878aSAndroid Build Coastguard Worker ] 569*61c4878aSAndroid Build Coastguard Worker } 570*61c4878aSAndroid Build Coastguard Worker } 571*61c4878aSAndroid Build Coastguard Worker } 572*61c4878aSAndroid Build Coastguard Worker} 573*61c4878aSAndroid Build Coastguard Worker 574*61c4878aSAndroid Build Coastguard Worker# Build Pigweed with -std=c++20 to ensure compatibility. Compile with 575*61c4878aSAndroid Build Coastguard Worker# optimizations since the compiler tends to catch more errors with optimizations 576*61c4878aSAndroid Build Coastguard Worker# enabled than without. 577*61c4878aSAndroid Build Coastguard Workergroup("cpp20_compatibility") { 578*61c4878aSAndroid Build Coastguard Worker _cpp20_tc = "$_internal_toolchains:pw_strict_host_clang_size_optimized_cpp20" 579*61c4878aSAndroid Build Coastguard Worker deps = [ ":pigweed_default($_cpp20_tc)" ] 580*61c4878aSAndroid Build Coastguard Worker} 581*61c4878aSAndroid Build Coastguard Worker 582*61c4878aSAndroid Build Coastguard Workergroup("build_with_pw_minimal_cpp_stdlib") { 583*61c4878aSAndroid Build Coastguard Worker _toolchain = "$_internal_toolchains:pw_strict_host_clang_size_optimized_minimal_cpp_stdlib" 584*61c4878aSAndroid Build Coastguard Worker 585*61c4878aSAndroid Build Coastguard Worker # This list of supported modules is incomplete. 586*61c4878aSAndroid Build Coastguard Worker deps = [ 587*61c4878aSAndroid Build Coastguard Worker "$dir_pw_base64($_toolchain)", 588*61c4878aSAndroid Build Coastguard Worker "$dir_pw_containers:inline_var_len_entry_queue($_toolchain)", 589*61c4878aSAndroid Build Coastguard Worker "$dir_pw_status($_toolchain)", 590*61c4878aSAndroid Build Coastguard Worker "$dir_pw_tokenizer:base64($_toolchain)", 591*61c4878aSAndroid Build Coastguard Worker "$dir_pw_tokenizer($_toolchain)", 592*61c4878aSAndroid Build Coastguard Worker "$dir_pw_varint($_toolchain)", 593*61c4878aSAndroid Build Coastguard Worker ] 594*61c4878aSAndroid Build Coastguard Worker} 595*61c4878aSAndroid Build Coastguard Worker 596*61c4878aSAndroid Build Coastguard Workergroup("host_clang_debug_dynamic_allocation") { 597*61c4878aSAndroid Build Coastguard Worker _toolchain = 598*61c4878aSAndroid Build Coastguard Worker "$_internal_toolchains:pw_strict_host_clang_debug_dynamic_allocation" 599*61c4878aSAndroid Build Coastguard Worker deps = [ ":pigweed_default($_toolchain)" ] 600*61c4878aSAndroid Build Coastguard Worker} 601*61c4878aSAndroid Build Coastguard Worker 602*61c4878aSAndroid Build Coastguard Worker# The default toolchain is not used for compiling C/C++ code. 603*61c4878aSAndroid Build Coastguard Workerif (current_toolchain != default_toolchain) { 604*61c4878aSAndroid Build Coastguard Worker group("apps") { 605*61c4878aSAndroid Build Coastguard Worker # Application images built for all targets. 606*61c4878aSAndroid Build Coastguard Worker deps = [ "$dir_pw_hdlc/rpc_example" ] 607*61c4878aSAndroid Build Coastguard Worker 608*61c4878aSAndroid Build Coastguard Worker # Add target-specific images. 609*61c4878aSAndroid Build Coastguard Worker deps += pw_TARGET_APPLICATIONS 610*61c4878aSAndroid Build Coastguard Worker 611*61c4878aSAndroid Build Coastguard Worker # Add host-only targets to the build. 612*61c4878aSAndroid Build Coastguard Worker if (defined(pw_toolchain_SCOPE.is_host_toolchain) && 613*61c4878aSAndroid Build Coastguard Worker pw_toolchain_SCOPE.is_host_toolchain) { 614*61c4878aSAndroid Build Coastguard Worker # TODO: b/240982565 - Build integration tests on Windows and macOS when 615*61c4878aSAndroid Build Coastguard Worker # SocketStream supports those platforms. 616*61c4878aSAndroid Build Coastguard Worker if (host_os == "linux") { 617*61c4878aSAndroid Build Coastguard Worker # Build the integration test binaries, but don't run them by default. 618*61c4878aSAndroid Build Coastguard Worker deps += [ 619*61c4878aSAndroid Build Coastguard Worker "$dir_pw_rpc:client_integration_test", 620*61c4878aSAndroid Build Coastguard Worker "$dir_pw_rpc:test_rpc_server", 621*61c4878aSAndroid Build Coastguard Worker "$dir_pw_unit_test:test_rpc_server", 622*61c4878aSAndroid Build Coastguard Worker ] 623*61c4878aSAndroid Build Coastguard Worker 624*61c4878aSAndroid Build Coastguard Worker # Build the benchmarks, but don't run them by default. 625*61c4878aSAndroid Build Coastguard Worker deps += [ ":pw_benchmarks" ] 626*61c4878aSAndroid Build Coastguard Worker } 627*61c4878aSAndroid Build Coastguard Worker } 628*61c4878aSAndroid Build Coastguard Worker 629*61c4878aSAndroid Build Coastguard Worker if (current_os == "linux") { 630*61c4878aSAndroid Build Coastguard Worker deps += [ 631*61c4878aSAndroid Build Coastguard Worker "$dir_pw_digital_io_linux:pw_digital_io_linux_cli", 632*61c4878aSAndroid Build Coastguard Worker "$dir_pw_spi_linux:pw_spi_linux_cli", 633*61c4878aSAndroid Build Coastguard Worker ] 634*61c4878aSAndroid Build Coastguard Worker } 635*61c4878aSAndroid Build Coastguard Worker } 636*61c4878aSAndroid Build Coastguard Worker 637*61c4878aSAndroid Build Coastguard Worker # All Pigweed modules that can be built using gn. Not built by default. 638*61c4878aSAndroid Build Coastguard Worker group("pw_modules") { 639*61c4878aSAndroid Build Coastguard Worker deps = pw_modules 640*61c4878aSAndroid Build Coastguard Worker } 641*61c4878aSAndroid Build Coastguard Worker 642*61c4878aSAndroid Build Coastguard Worker # Targets for all module unit test groups. 643*61c4878aSAndroid Build Coastguard Worker pw_test_group("pw_module_tests") { 644*61c4878aSAndroid Build Coastguard Worker group_deps = pw_module_tests 645*61c4878aSAndroid Build Coastguard Worker output_metadata = true 646*61c4878aSAndroid Build Coastguard Worker } 647*61c4878aSAndroid Build Coastguard Worker 648*61c4878aSAndroid Build Coastguard Worker pw_test_group("pw_action_tests") { 649*61c4878aSAndroid Build Coastguard Worker tests = [ "$dir_pw_unit_test:test_group_metadata_test" ] 650*61c4878aSAndroid Build Coastguard Worker } 651*61c4878aSAndroid Build Coastguard Worker 652*61c4878aSAndroid Build Coastguard Worker pw_test_group("pw_integration_tests") { 653*61c4878aSAndroid Build Coastguard Worker tests = [ 654*61c4878aSAndroid Build Coastguard Worker "$dir_pw_build/py/gn_tests:python_package_integration_tests", 655*61c4878aSAndroid Build Coastguard Worker "$dir_pw_cli/py:process_integration_test", 656*61c4878aSAndroid Build Coastguard Worker "$dir_pw_rpc:cpp_client_server_integration_test", 657*61c4878aSAndroid Build Coastguard Worker "$dir_pw_rpc/py:python_client_cpp_server_test", 658*61c4878aSAndroid Build Coastguard Worker "$dir_pw_unit_test/py:rpc_service_test", 659*61c4878aSAndroid Build Coastguard Worker ] 660*61c4878aSAndroid Build Coastguard Worker 661*61c4878aSAndroid Build Coastguard Worker output_metadata = true 662*61c4878aSAndroid Build Coastguard Worker } 663*61c4878aSAndroid Build Coastguard Worker 664*61c4878aSAndroid Build Coastguard Worker pw_test_group("pw_perf_tests") { 665*61c4878aSAndroid Build Coastguard Worker tests = [ 666*61c4878aSAndroid Build Coastguard Worker "$dir_pw_checksum:perf_tests", 667*61c4878aSAndroid Build Coastguard Worker "$dir_pw_perf_test:examples", 668*61c4878aSAndroid Build Coastguard Worker "$dir_pw_protobuf:perf_tests", 669*61c4878aSAndroid Build Coastguard Worker ] 670*61c4878aSAndroid Build Coastguard Worker output_metadata = true 671*61c4878aSAndroid Build Coastguard Worker } 672*61c4878aSAndroid Build Coastguard Worker 673*61c4878aSAndroid Build Coastguard Worker # TODO(b/369853273): Merge benchmarks and perf tests 674*61c4878aSAndroid Build Coastguard Worker group("pw_benchmarks") { 675*61c4878aSAndroid Build Coastguard Worker deps = [ "$dir_pw_allocator/benchmarks" ] 676*61c4878aSAndroid Build Coastguard Worker } 677*61c4878aSAndroid Build Coastguard Worker 678*61c4878aSAndroid Build Coastguard Worker # Fuzzers not based on a fuzzing engine. Engine-based fuzzers should be 679*61c4878aSAndroid Build Coastguard Worker # included in `pw_module_tests`. 680*61c4878aSAndroid Build Coastguard Worker pw_test_group("pw_custom_fuzzers") { 681*61c4878aSAndroid Build Coastguard Worker # TODO: b/274437709 - The RPC client_fuzzer encounters build errors on macos. 682*61c4878aSAndroid Build Coastguard Worker # Limit it to Linux hosts for now. 683*61c4878aSAndroid Build Coastguard Worker if (host_os == "linux") { 684*61c4878aSAndroid Build Coastguard Worker tests = [ "$dir_pw_rpc/fuzz:client_fuzzer" ] 685*61c4878aSAndroid Build Coastguard Worker } 686*61c4878aSAndroid Build Coastguard Worker output_metadata = true 687*61c4878aSAndroid Build Coastguard Worker } 688*61c4878aSAndroid Build Coastguard Worker 689*61c4878aSAndroid Build Coastguard Worker pw_coverage_report("coverage_report") { 690*61c4878aSAndroid Build Coastguard Worker filter_paths = [] 691*61c4878aSAndroid Build Coastguard Worker ignore_filename_patterns = [ 692*61c4878aSAndroid Build Coastguard Worker "third_party", 693*61c4878aSAndroid Build Coastguard Worker "protocol_buffer/gen", 694*61c4878aSAndroid Build Coastguard Worker ] 695*61c4878aSAndroid Build Coastguard Worker group_deps = [ ":pw_module_tests" ] 696*61c4878aSAndroid Build Coastguard Worker } 697*61c4878aSAndroid Build Coastguard Worker} 698