aboutsummaryrefslogtreecommitdiff
path: root/BUILD.gn
diff options
context:
space:
mode:
Diffstat (limited to 'BUILD.gn')
-rw-r--r--BUILD.gn362
1 files changed, 260 insertions, 102 deletions
diff --git a/BUILD.gn b/BUILD.gn
index aa97568b9..6a9a23145 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -15,17 +15,22 @@
import("//build_overrides/pi_pico.gni")
import("//build_overrides/pigweed.gni")
+import("$dir_pw_android_toolchain/android.gni")
import("$dir_pw_arduino_build/arduino.gni")
+import("$dir_pw_build/coverage_report.gni")
import("$dir_pw_build/host_tool.gni")
import("$dir_pw_build/python.gni")
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_perf_test/perf_test.gni")
import("$dir_pw_rpc/config.gni")
import("$dir_pw_rust/rust.gni")
+import("$dir_pw_third_party/ambiq/ambiq.gni")
+import("$dir_pw_third_party/fuzztest/fuzztest.gni")
import("$dir_pw_third_party/mcuxpresso/mcuxpresso.gni")
import("$dir_pw_toolchain/c_optimization.gni")
import("$dir_pw_toolchain/generate_toolchain.gni")
import("$dir_pw_toolchain/non_c_toolchain.gni")
+import("$dir_pw_trace/backend.gni")
import("$dir_pw_unit_test/test.gni")
# Main build file for upstream Pigweed.
@@ -46,6 +51,10 @@ declare_args() {
# List of application image GN targets specific to the Pigweed target.
pw_TARGET_APPLICATIONS = []
+
+ # Gates known broken configurations from building. This is what allows the
+ # implicit `all` target to work even though there are known broken targets.
+ pw_BUILD_BROKEN_GROUPS = false
}
# This toolchain is used to force some dependencies to not be parsed by the
@@ -97,6 +106,55 @@ group("default") {
]
}
+# This group tries to collect together most build steps in Pigweed's build.
+# Some targets in this group are not included in the main build to keep the
+# default build time down, while others are excluded from the main build because
+# they require additional configuration or don't work on every OS.
+#
+# To increase coverage, use `pw package` to install these packages:
+# boringssl
+# freertos
+# mbedtls
+# micro-ecc
+# nanopb
+# pico_sdk
+# protobuf
+# stm32cube_f4
+# teensy
+group("extended_default") {
+ deps = [
+ ":cpp20_compatibility",
+ ":default",
+ ":host_clang_debug_dynamic_allocation",
+ ":pw_system_demo",
+ ":stm32f429i",
+ ]
+
+ if (host_os != "win") {
+ deps += [
+ ":qemu_clang",
+ ":qemu_gcc",
+ ]
+ }
+
+ if (host_os == "linux") {
+ deps += [
+ ":integration_tests",
+ ":runtime_sanitizers",
+ ]
+ }
+
+ # Requires setting pw_arduino_build_CORE_PATH.
+ if (pw_arduino_build_CORE_PATH != "") {
+ deps += [ ":arduino" ]
+ }
+
+ # Requires setting pw_third_party_mcuxpresso_SDK.
+ if (pw_third_party_mcuxpresso_SDK != "") {
+ deps += [ ":mimxrt595" ]
+ }
+}
+
# Verify that this BUILD.gn file is only used by Pigweed itself.
assert(get_path_info("//", "abspath") == get_path_info(".", "abspath"),
"Pigweed's top-level BUILD.gn may only be used when building upstream " +
@@ -160,7 +218,7 @@ group("pw_system_demo") {
group("pi_pico") {
if (PICO_SRC_DIR != "") {
- deps = [ ":pw_module_tests(targets/rp2040)" ]
+ deps = [ ":pigweed_default(targets/rp2040)" ]
}
}
@@ -218,6 +276,17 @@ if (pw_third_party_mcuxpresso_SDK != "") {
_build_pigweed_default_at_all_optimization_levels("mimxrt595") {
toolchain_prefix = "$dir_pigweed/targets/mimxrt595_evk:mimxrt595_evk_"
}
+
+ _build_pigweed_default_at_all_optimization_levels("mimxrt595_freertos") {
+ toolchain_prefix =
+ "$dir_pigweed/targets/mimxrt595_evk_freertos:mimxrt595_evk_freertos_"
+ }
+}
+
+if (dir_pw_third_party_ambiq_SDK != "") {
+ _build_pigweed_default_at_all_optimization_levels("apollo4") {
+ toolchain_prefix = "$dir_pigweed/targets/apollo4:apollo4_"
+ }
}
_build_pigweed_default_at_all_optimization_levels("stm32f429i") {
@@ -230,23 +299,30 @@ if (pw_arduino_build_CORE_PATH != "") {
}
}
-_build_pigweed_default_at_all_optimization_levels("qemu_gcc") {
- toolchain_prefix =
- "$dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_gcc_"
-}
-
-# TODO(b/244604080): Inline string tests are too big to fit in the QEMU firmware
+# TODO: b/244604080 - Inline string tests are too big to fit in the QEMU firmware
# except under a size-optimized build. For now, only build size-optimized.
-#
-# _build_pigweed_default_at_all_optimization_levels("qemu_clang") {
-# toolchain_prefix =
-# "$dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_clang_"
-# }
-group("qemu_clang_size_optimized") {
- deps = [ ":pigweed_default($dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_clang_size_optimized)" ]
-}
-group("qemu_clang") {
- deps = [ ":qemu_clang_size_optimized" ]
+if (pw_BUILD_BROKEN_GROUPS) {
+ _build_pigweed_default_at_all_optimization_levels("qemu_gcc") {
+ toolchain_prefix =
+ "$dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_gcc_"
+ }
+ _build_pigweed_default_at_all_optimization_levels("qemu_clang") {
+ toolchain_prefix =
+ "$dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_clang_"
+ }
+} else {
+ group("qemu_gcc_size_optimized") {
+ deps = [ ":pigweed_default($dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_gcc_size_optimized)" ]
+ }
+ group("qemu_gcc") {
+ deps = [ ":qemu_gcc_size_optimized" ]
+ }
+ group("qemu_clang_size_optimized") {
+ deps = [ ":pigweed_default($dir_pigweed/targets/lm3s6965evb_qemu:lm3s6965evb_qemu_clang_size_optimized)" ]
+ }
+ group("qemu_clang") {
+ deps = [ ":qemu_clang_size_optimized" ]
+ }
}
# Run clang-tidy on pigweed_default with pw_strict_host_clang_debug toolchain options.
@@ -260,6 +336,24 @@ group("static_analysis") {
}
}
+if (pw_android_toolchain_NDK_PATH != "") {
+ group("android") {
+ deps = []
+ foreach(_cpu, pw_android_toolchain_cpu_targets) {
+ _toolchain_prefix = "$dir_pigweed/targets/android:${_cpu}_android_"
+ deps += [
+ ":pigweed_default($_toolchain_prefix$pw_DEFAULT_C_OPTIMIZATION_LEVEL)",
+ ]
+ }
+ }
+
+ foreach(_cpu, pw_android_toolchain_cpu_targets) {
+ _build_pigweed_default_at_all_optimization_levels("${_cpu}_android") {
+ toolchain_prefix = "$dir_pigweed/targets/android:${_cpu}_android_"
+ }
+ }
+}
+
group("docs") {
deps = [ "$dir_pigweed/docs($dir_pigweed/targets/docs)" ]
}
@@ -271,98 +365,131 @@ group("docs") {
# build.
group("action_tests") {
_default_tc = _default_toolchain_prefix + pw_DEFAULT_C_OPTIMIZATION_LEVEL
- deps = [ "$dir_pw_unit_test:test_group_metadata_test.action($_default_tc)" ]
+ deps = [ ":pw_action_tests.run($_default_tc)" ]
}
# Tests larger than unit tests, typically run in a specific configuration.
group("integration_tests") {
_default_tc = _default_toolchain_prefix + pw_DEFAULT_C_OPTIMIZATION_LEVEL
- deps = [
- "$dir_pw_cli/py:process_integration_test.action($_default_tc)",
- "$dir_pw_rpc:cpp_client_server_integration_test($_default_tc)",
- "$dir_pw_rpc/py:python_client_cpp_server_test.action($_default_tc)",
- "$dir_pw_unit_test/py:rpc_service_test.action($_default_tc)",
- ]
+ deps = [ ":pw_integration_tests.run($_default_tc)" ]
+}
+
+group("pip_constraint_update") {
+ public_deps = []
+
+ if (current_toolchain == pw_build_PYTHON_TOOLCHAIN) {
+ public_deps += [ "$dir_pw_env_setup:pigweed_build_venv._compile_requirements($pw_build_PYTHON_TOOLCHAIN)" ]
+ } else {
+ public_deps = [ ":${target_name}($pw_build_PYTHON_TOOLCHAIN)" ]
+ }
+}
+
+group("pip_vendor_wheels") {
+ public_deps = []
+
+ if (current_toolchain == pw_build_PYTHON_TOOLCHAIN) {
+ public_deps += [ "$dir_pw_env_setup:pigweed_build_venv.vendor_wheels($pw_build_PYTHON_TOOLCHAIN)" ]
+ } else {
+ public_deps = [ ":${target_name}($pw_build_PYTHON_TOOLCHAIN)" ]
+ }
}
-# Build-only target for fuzzers.
group("fuzzers") {
deps = []
- # TODO(b/274437709): The client_fuzzer encounters build errors on macos. Limit
- # it to Linux hosts for now.
- if (host_os == "linux") {
+ if (host_os != "win" && dir_pw_third_party_fuzztest != "") {
+ # Coverage-guided fuzzing is only supported on Linux and MacOS using clang.
+ # Fuzztest-based fuzzers will run in unit test mode. libFuzzer-based fuzzers
+ # will only build.
+ _clang_fuzz_tc = _default_toolchain_prefix + "fuzz"
+ deps += [ ":pw_module_tests.run($_clang_fuzz_tc)" ]
+ }
+
+ # Also build (but do not run) bespoke fuzzers.
+ if (!pw_toolchain_OSS_FUZZ_ENABLED) {
_default_tc = _default_toolchain_prefix + pw_DEFAULT_C_OPTIMIZATION_LEVEL
- deps += [ "$dir_pw_rpc/fuzz:client_fuzzer($_default_tc)" ]
+ deps += [ ":pw_custom_fuzzers($_default_tc)" ]
}
+}
- if (host_os != "win") {
- # Coverage-guided fuzzing is only supported on Linux and MacOS using clang.
- deps += [
- "$dir_pw_bluetooth_hci:fuzzers($dir_pigweed/targets/host:host_clang_fuzz)",
- "$dir_pw_fuzzer:fuzzers($dir_pigweed/targets/host:host_clang_fuzz)",
- "$dir_pw_protobuf:fuzzers($dir_pigweed/targets/host:host_clang_fuzz)",
- "$dir_pw_random:fuzzers($dir_pigweed/targets/host:host_clang_fuzz)",
- "$dir_pw_tokenizer:fuzzers($dir_pigweed/targets/host:host_clang_fuzz)",
- ]
+# Build-only target for OSS-Fuzz. No-op unless OSS-Fuzz is enabled.
+group("oss_fuzz") {
+ if (pw_toolchain_OSS_FUZZ_ENABLED) {
+ _clang_fuzz_tc = _default_toolchain_prefix + "fuzz"
+ deps = [ ":pw_module_tests($_clang_fuzz_tc)" ]
}
}
group("asan") {
+ # TODO: b/302181521 - asan doesn't work on Windows yet.
if (host_os != "win") {
deps = [ ":pw_module_tests.run($dir_pigweed/targets/host:host_clang_asan)" ]
}
}
-# TODO(b/234876100): msan will not work until the C++ standard library included
-# in the sysroot has a variant built with msan.
+# TODO: b/234876100 - msan will not work without false positives until the C++
+# standard library included in the sysroot has a variant built with msan.
group("msan") {
- # TODO(b/259695498): msan doesn't work on macOS yet.
- if (host_os != "win" && host_os != "mac" && host_os != "linux") {
+ # TODO: b/259695498 - msan doesn't work on macOS yet.
+ # TODO: b/302181521 - msan doesn't work on Windows yet.
+ if (pw_BUILD_BROKEN_GROUPS) {
deps = [ ":pw_module_tests.run($dir_pigweed/targets/host:host_clang_msan)" ]
}
}
group("tsan") {
+ # TODO: b/302181521 - tsan doesn't work on Windows yet.
if (host_os != "win") {
deps = [ ":pw_module_tests.run($dir_pigweed/targets/host:host_clang_tsan)" ]
}
}
group("ubsan") {
- # TODO(b/259695498): ubsan doesn't work on macOS yet.
- if (host_os != "win" && host_os != "mac") {
+ # TODO: b/259695498 - ubsan doesn't work on macOS yet.
+ # TODO: b/302181521 - ubsan doesn't work on Windows yet.
+ if ((host_os != "win" && host_os != "mac") || pw_BUILD_BROKEN_GROUPS) {
deps =
[ ":pw_module_tests.run($dir_pigweed/targets/host:host_clang_ubsan)" ]
}
}
group("ubsan_heuristic") {
- # TODO(b/259695498): ubsan_heuristic doesn't work on macOS yet.
- if (host_os != "win" && host_os != "mac") {
+ # TODO: b/259695498 - ubsan_heuristic doesn't work on macOS yet.
+ # TODO: b/302181521 - ubsan doesn't work on Windows yet.
+ if ((host_os != "win" && host_os != "mac") || pw_BUILD_BROKEN_GROUPS) {
deps = [ ":pw_module_tests.run($dir_pigweed/targets/host:host_clang_ubsan_heuristic)" ]
}
}
group("runtime_sanitizers") {
- if (host_os != "win") {
+ if (host_os != "win" || pw_BUILD_BROKEN_GROUPS) {
deps = [
":asan",
":tsan",
":ubsan",
+ ]
- # TODO(b/234876100): msan will not work until the C++ standard library
+ if (pw_BUILD_BROKEN_GROUPS) {
+ # TODO: b/234876100 - msan will not work until the C++ standard library
# included in the sysroot has a variant built with msan.
- # ":msan",
+ deps += [ ":msan" ]
# No ubsan_heuristic, which may have false positives.
- ]
+ deps += [ ":ubsan_heuristic" ]
+ }
+ }
+}
+
+group("coverage") {
+ if (host_os == "linux") {
+ deps = [ ":coverage_report($dir_pigweed/targets/host:host_clang_coverage)" ]
}
}
pw_python_group("python") {
python_deps = [
"$dir_pw_env_setup:python($pw_build_PYTHON_TOOLCHAIN)",
+ "$dir_pw_env_setup:sample_project_action($pw_build_PYTHON_TOOLCHAIN)",
"$dir_pw_env_setup:target_support_packages($pw_build_PYTHON_TOOLCHAIN)",
]
}
@@ -379,7 +506,7 @@ group("host_tools") {
]
if (pw_rust_ENABLE_EXPERIMENTAL_BUILD) {
- deps += [ "$dir_pw_rust/examples/host_executable:hello($dir_pigweed/targets/host:host_clang_debug)" ]
+ deps += [ "$dir_pw_rust/examples/host_executable:host_executable($dir_pigweed/targets/host:host_clang_debug)" ]
}
}
@@ -389,44 +516,51 @@ group("pigweed_default") {
# Prevent the default toolchain from parsing any other BUILD.gn files.
if (current_toolchain != default_toolchain) {
+ _is_host_toolchain = defined(pw_toolchain_SCOPE.is_host_toolchain) &&
+ pw_toolchain_SCOPE.is_host_toolchain
+
deps = [ ":apps" ]
- if (pw_unit_test_AUTOMATIC_RUNNER == "") {
- # Without a test runner defined, build the tests but don't run them.
- deps += [ ":pw_module_tests" ]
- } else {
- # With a test runner, depend on the run targets so they run with the
- # build.
- deps += [ ":pw_module_tests.run" ]
- }
- # Add performance tests to the automatic build
- deps += [ ":pw_perf_tests" ]
+ # Upstream GoogleTest assumes the presence of a POSIX filesystem. If an
+ # external gtest backend has been provided, limit the tests to host-only.
+ if (pw_unit_test_GOOGLETEST_BACKEND == "$dir_pw_unit_test:light" ||
+ _is_host_toolchain) {
+ if (pw_unit_test_AUTOMATIC_RUNNER == "") {
+ # Without a test runner defined, build the tests but don't run them.
+ deps += [ ":pw_module_tests" ]
+ } else {
+ # With a test runner, depend on the run targets so they run with the
+ # build.
+ deps += [ ":pw_module_tests.run" ]
+ }
+
+ # Add performance tests to the automatic build
+ deps += [ ":pw_perf_tests" ]
+ }
# Add action tests to the automatic build
- deps += [ ":action_tests" ]
+ if (_is_host_toolchain) {
+ deps += [ ":pw_action_tests.run" ]
+ }
# Trace examples currently only support running on non-windows host
- if (defined(pw_toolchain_SCOPE.is_host_toolchain) &&
- pw_toolchain_SCOPE.is_host_toolchain && host_os != "win") {
- deps += [
- "$dir_pw_trace:trace_example_basic",
- "$dir_pw_trace_tokenized:trace_tokenized_example_basic",
- "$dir_pw_trace_tokenized:trace_tokenized_example_filter",
- "$dir_pw_trace_tokenized:trace_tokenized_example_rpc",
- "$dir_pw_trace_tokenized:trace_tokenized_example_trigger",
- ]
+ if (_is_host_toolchain && host_os != "win") {
+ deps += [ "$dir_pw_trace:trace_example_basic" ]
+
+ if (get_label_info(pw_trace_BACKEND, "label_no_toolchain") ==
+ get_label_info(":pw_trace_tokenized", "label_no_toolchain")) {
+ deps += [
+ "$dir_pw_trace_tokenized:trace_tokenized_example_basic",
+ "$dir_pw_trace_tokenized:trace_tokenized_example_filter",
+ "$dir_pw_trace_tokenized:trace_tokenized_example_linux_group_by_tid",
+ "$dir_pw_trace_tokenized:trace_tokenized_example_rpc",
+ "$dir_pw_trace_tokenized:trace_tokenized_example_trigger",
+ ]
+ }
}
}
}
-group("cpp14_compatibility") {
- _cpp14_toolchain = "$_internal_toolchains:pw_strict_host_clang_debug_cpp14"
- deps = [
- ":cpp14_modules($_cpp14_toolchain)",
- ":cpp14_tests.run($_cpp14_toolchain)",
- ]
-}
-
# Build Pigweed with -std=c++20 to ensure compatibility. Compile with
# optimizations since the compiler tends to catch more errors with optimizations
# enabled than without.
@@ -440,11 +574,21 @@ group("build_with_pw_minimal_cpp_stdlib") {
# This list of supported modules is incomplete.
deps = [
+ "$dir_pw_base64($_toolchain)",
+ "$dir_pw_containers:variable_length_entry_queue($_toolchain)",
"$dir_pw_status($_toolchain)",
+ "$dir_pw_tokenizer:base64($_toolchain)",
"$dir_pw_tokenizer($_toolchain)",
+ "$dir_pw_varint($_toolchain)",
]
}
+group("host_clang_debug_dynamic_allocation") {
+ _toolchain =
+ "$_internal_toolchains:pw_strict_host_clang_debug_dynamic_allocation"
+ deps = [ ":pigweed_default($_toolchain)" ]
+}
+
# The default toolchain is not used for compiling C/C++ code.
if (current_toolchain != default_toolchain) {
group("apps") {
@@ -459,7 +603,7 @@ if (current_toolchain != default_toolchain) {
pw_toolchain_SCOPE.is_host_toolchain) {
deps += [ "$dir_pw_tool" ]
- # TODO(b/240982565): Build integration tests on Windows and macOS when
+ # TODO: b/240982565 - Build integration tests on Windows and macOS when
# SocketStream supports those platforms.
if (host_os == "linux") {
# Build the integration test binaries, but don't run them by default.
@@ -480,37 +624,51 @@ if (current_toolchain != default_toolchain) {
# Targets for all module unit test groups.
pw_test_group("pw_module_tests") {
group_deps = pw_module_tests
+ output_metadata = true
}
- group("pw_perf_tests") {
- deps = [
+ pw_test_group("pw_action_tests") {
+ tests = [ "$dir_pw_unit_test:test_group_metadata_test" ]
+ }
+
+ pw_test_group("pw_integration_tests") {
+ tests = [
+ "$dir_pw_build/py/gn_tests:python_package_integration_tests",
+ "$dir_pw_cli/py:process_integration_test",
+ "$dir_pw_rpc:cpp_client_server_integration_test",
+ "$dir_pw_rpc/py:python_client_cpp_server_test",
+ "$dir_pw_unit_test/py:rpc_service_test",
+ ]
+
+ output_metadata = true
+ }
+
+ pw_test_group("pw_perf_tests") {
+ tests = [
"$dir_pw_checksum:perf_tests",
- "$dir_pw_perf_test:perf_test_tests_test",
+ "$dir_pw_perf_test:examples",
"$dir_pw_protobuf:perf_tests",
]
+ output_metadata = true
}
- # Modules that support C++14.
- # TODO(hepler): pw_kvs is supposed to compile as C++14, but does not.
- group("cpp14_modules") {
- public_deps = [
- dir_pw_polyfill,
- dir_pw_preprocessor,
- dir_pw_tokenizer,
- dir_pw_varint,
- ]
+ # Fuzzers not based on a fuzzing engine. Engine-based fuzzers should be
+ # included in `pw_module_tests`.
+ pw_test_group("pw_custom_fuzzers") {
+ # TODO: b/274437709 - The RPC client_fuzzer encounters build errors on macos.
+ # Limit it to Linux hosts for now.
+ if (host_os == "linux") {
+ tests = [ "$dir_pw_rpc/fuzz:client_fuzzer" ]
+ }
+ output_metadata = true
}
- # Tests that support C++14.
- pw_test_group("cpp14_tests") {
- group_deps = [
- "$dir_pw_polyfill:tests",
- "$dir_pw_span:tests",
- ]
- tests = [
- "$dir_pw_tokenizer:simple_tokenize_test",
- "$dir_pw_containers:to_array_test",
- "$dir_pw_string:string_test",
+ pw_coverage_report("coverage_report") {
+ filter_paths = []
+ ignore_filename_patterns = [
+ "third_party",
+ "protocol_buffer/gen",
]
+ group_deps = [ ":pw_module_tests" ]
}
}