• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 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
15# TODO: https://pwbug.dev/258836641#comment4: Enabling bzlmod breaks the build.
16common --noenable_bzlmod
17
18# Improve debugability by printing all arguments for failing commands.
19common --verbose_failures
20
21# Silence all C/C++ warnings in external code.
22#
23# Note that this will not silence warnings from external headers #include'd in
24# first-party code.
25common --per_file_copt=external/.*@-w
26common --host_per_file_copt=external/.*@-w
27
28# Don't automatically create __init__.py files.
29#
30# This prevents spurious package name collisions at import time, and should be
31# the default (https://github.com/bazelbuild/bazel/issues/7386). It's
32# particularly helpful for Pigweed, because we have many potential package name
33# collisions due to a profusion of stuttering paths like
34# pw_transfer/py/pw_transfer.
35common --incompatible_default_to_explicit_init_py
36
37# Required for new toolchain resolution API.
38build --incompatible_enable_cc_toolchain_resolution
39
40# Skip building or testing C++20 targets by default
41# TODO: b/340568834 Remove when a proper solution is available.
42build --build_tag_filters=-requires_cxx_20
43# Also exclude integration tests from the default build. The test_tag_filters
44# flag doesn't accumulate (https://github.com/bazelbuild/bazel/issues/7322): we
45# have to specify it only once, setting all the exclusions in a comma-separated
46# list.
47test --test_tag_filters=-requires_cxx_20,-integration
48
49# Do not attempt to configure an autodetected (local) toolchain. We vendor all
50# our toolchains, and CI VMs may not have any local toolchain to detect.
51common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
52
53# Required for combined code coverage reports.
54coverage --experimental_generate_llvm_lcov
55coverage --combined_report=lcov
56
57# Suppress the DEBUG: log messages from bazel. We get lots of spammy DEBUG:
58# messages from our third-party dependencies.
59build --ui_event_filters=-debug
60
61# Enforces consistent action environment variables. This is important to
62# address Protobuf's rebuild sensitivity on changes to the environment
63# variables.
64build --incompatible_strict_action_env
65
66# Workaround for https://github.com/bazelbuild/rules_jvm_external/issues/445.
67build --java_language_version=11
68build --tool_java_language_version=11
69build --java_runtime_version=remotejdk_11
70build --repo_env=JAVA_HOME=../bazel_tools/jdk
71
72# Silence compiler warnings from external repositories.
73#
74# This is supported by Bazel's default C++ toolchain, but not yet by
75# rules_cc_toolchain
76# (https://github.com/bazelembedded/rules_cc_toolchain/issues/46).
77build --features=external_include_paths
78
79# This feature can't be enabled until __unordtf2 and __letf2 are implemented by
80# compiler-rt. See https://reviews.llvm.org/D53608.
81# build --features=fully_static_link
82
83build --@freertos//:freertos_config=//third_party/freertos:freertos_config
84build --@mbedtls//:mbedtls_config=//third_party/mbedtls:default_config
85
86common:asan --//pw_toolchain/host_clang:asan
87# TODO: https://github.com/bazelbuild/bazel/issues/7322 - We need to repeat the
88# -requires_cxx_20 and -integration because the test_tag_filters flag does not
89# accumulate.
90test:asan --test_tag_filters=-requires_cxx_20,-integration,-noasan
91
92# Define the --config=asan-libfuzzer configuration.
93build:asan-libfuzzer \
94    --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer
95build:asan-libfuzzer \
96    --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
97build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan
98
99# Include FuzzTest build configurations.
100try-import %workspace%/third_party/fuzztest/fuzztest.bazelrc
101build:fuzztest \
102    --//pw_fuzzer:fuzztest_backend=@com_google_fuzztest//fuzztest:fuzztest_core
103build:fuzztest \
104    --@pigweed//pw_unit_test:main=@com_google_fuzztest//fuzztest:fuzztest_gtest_main
105
106# We use non-default labels for the STM32Cube repositories upstream (to reserve
107# the option of building for more than one MCU family down the road), so need to
108# override the three labels below.
109common --//third_party/stm32cube:hal_driver=@stm32f4xx_hal_driver//:hal_driver
110common --@stm32f4xx_hal_driver//:cmsis_device=@cmsis_device_f4//:cmsis_device
111common --@stm32f4xx_hal_driver//:cmsis_init=@cmsis_device_f4//:default_cmsis_init
112
113common --//pw_env_setup/py:pigweed_json=//:pigweed.json
114
115
116# Config for the rp2040 platform.
117#
118# TODO: b/301334234 - Make the platform set the flags below.
119build:rp2040 --platforms=@pigweed//targets/rp2040
120build:rp2040 --//pw_log:backend=@pigweed//pw_log_tokenized
121build:rp2040 --//pw_log:backend_impl=@pigweed//pw_log_tokenized:impl
122build:rp2040 --//pw_log_tokenized:handler_backend=@pigweed//pw_system:log_backend
123build:rp2040 --//pw_system:extra_platform_libs=@pigweed//targets/rp2040:extra_platform_libs
124
125
126# Config for the stm32f429i_disc1_stm32cube platform.
127#
128# TODO: b/301334234 - Make the platform set the flags below.
129build:stm32f429i --platforms=//targets/stm32f429i_disc1_stm32cube:platform
130build:stm32f429i --copt="-DSTM32CUBE_HEADER=\"stm32f4xx.h\""
131build:stm32f429i --copt="-DSTM32F429xx"
132build:stm32f429i --@stm32f4xx_hal_driver//:hal_config=//targets/stm32f429i_disc1_stm32cube:hal_config
133build:stm32f429i --//pw_log:backend=@pigweed//pw_log_tokenized
134build:stm32f429i --//pw_log:backend_impl=@pigweed//pw_log_tokenized:impl
135build:stm32f429i --//pw_log_tokenized:handler_backend=@pigweed//pw_system:log_backend
136build:stm32f429i --//pw_malloc:backend=@pigweed//pw_malloc:bucket_block_allocator
137build:stm32f429i --//pw_system:extra_platform_libs=@pigweed//targets/stm32f429i_disc1_stm32cube:extra_platform_libs
138
139
140# Config for the lm3s6965evb platform, used to build pw_rust/examples.
141#
142# TODO: b/301334234 - Make the platform set the flags below.
143build:lm3s6965evb --platforms=//pw_build/platforms:lm3s6965evb
144build:lm3s6965evb --//pw_log/rust:pw_log_backend=//pw_rust/examples/tokenized_logging:pw_log_backend
145
146# Config for the microbit platform, used to build pw_rust/examples.
147#
148# TODO: b/301334234 - Make the platform set the flags below.
149build:microbit --platforms=//pw_build/platforms:lm3s6965evb
150build:microbit --//pw_log/rust:pw_log_backend=//pw_rust/examples/tokenized_logging:pw_log_backend
151
152# For some platforms i.e. google/oss-fuzz we need to use the system provided
153# rather than the hermetic toolchains. This allows oss-fuzz to override the
154# build with specialised compilers that are tightly coupled to the fuzzing
155# runtimes.
156# Detect toolchains
157common:non_hermetic --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0
158common:non_hermetic --extra_toolchains=@local_config_cc_toolchains//...
159
160# Use the remote cache. This will only work for users who have permission to access it.
161common:remote_cache --remote_cache=grpcs://remotebuildexecution.googleapis.com
162common:remote_cache --google_default_credentials=true
163common:remote_cache --remote_instance_name=projects/pigweed-rbe-open/instances/default-instance
164common:remote_cache --remote_upload_local_results=false
165
166# Specifies desired output mode for running tests.
167# Valid values are
168#   'summary' to output only test status summary
169#   'errors' to also print test logs for failed tests
170#   'all' to print logs for all tests
171#   'streamed' to output logs for all tests in real time
172#     (this will force tests to be executed locally one at a time regardless
173#     of --test_strategy value).
174test --test_output=errors
175
176# User bazelrc file; see
177# https://bazel.build/configure/best-practices#bazelrc-file
178#
179# Note: this should be at the bottom of the file, so that user-specified
180# options override anything in this file
181# (https://bazel.build/run/bazelrc#imports)
182try-import %workspace%/user.bazelrc
183