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