-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bazelrc
182 lines (151 loc) · 6.61 KB
/
.bazelrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Import Apsect bazelrc presets
# From https://docs.aspect.build/guides/bazelrc/
# & https://github.com/bazel-contrib/bazel-lib/tree/5853e2e441df850dc332910a0808e9dee2ed9e27/.aspect/bazelrc
import %workspace%/.aspect/bazelrc/bazel7.bazelrc
import %workspace%/.aspect/bazelrc/convenience.bazelrc
import %workspace%/.aspect/bazelrc/correctness.bazelrc
import %workspace%/.aspect/bazelrc/debug.bazelrc
import %workspace%/.aspect/bazelrc/java.bazelrc
import %workspace%/.aspect/bazelrc/javascript.bazelrc
import %workspace%/.aspect/bazelrc/performance.bazelrc
#
# NOTE for:
# build --incompatible_default_to_explicit_init_py
#
# This also prevents spurious package name collisions at import time, and
# should be the default (https://github.com/bazelbuild/bazel/issues/7386). It's
# particularly helpful for Pigweed, because we have many potential package name
# collisions due to a profusion of stuttering paths like
# pw_transfer/py/pw_transfer.
#
# NOTE for:
# build --incompatible_strict_action_env
#
# Don't inherit system PATH. Improves hermeticity and cache hit rates. Should
# be true by default one day (https://github.com/bazelbuild/bazel/issues/7026).
# My overrides of the above imports
# TODO(#172): Update these
#
# pw_protobuf/BUILD.bazel, llvm_toolchain
common --noincompatible_disallow_empty_glob
# No module named 'pw_protobuf_codegen_protos' in pw_protobuf options
build --legacy_external_runfiles
# See https://bazel.build/docs/user-manual for option definitions
#
# Standard Pigweed flags
# ======================
# All Pigweed projects are expected to set these flags. They mostly pre-adopt
# future Bazel settings.
#
# Do not attempt to configure an autodetected (local) toolchain. We vendor all
# our toolchains, and CI VMs may not have any local toolchain to detect.
common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
# Required for new toolchain resolution API.
build --incompatible_enable_cc_toolchain_resolution
# Don't propagate flags or defines to the exec config. This will become the
# default one day (https://github.com/bazelbuild/bazel/issues/22457) and will
# improve cache hit rates between builds targeting different platforms. This is
# especially impactful for large host tools like protoc, which will have its
# cache invalidated when your host C++ config changes.
common --experimental_exclude_defines_from_exec_config
common --experimental_exclude_starlark_flags_from_exec_config
# Expose exec toolchains for Python. We use these toolchains in some rule
# implementations (git grep for
# "@rules_python//python:exec_tools_toolchain_type").
build --@rules_python//python/config_settings:exec_tools_toolchain=enabled
# C++ toolchain configuration
# ===========================
# Ignore all warnings in third-party code.
common --per_file_copt=external/.*@-w
common --host_per_file_copt=external/.*@-w
# Picotool needs to build with exceptions and RTTI enabled.
common --per_file_copt=external.*picotool.*@-fexceptions,-frtti
common --host_per_file_copt=external.*picotool.*@-fexceptions,-frtti
# Keep debugging symbols, but don't send them when flashing.
build --strip=never
build --@pico-sdk//bazel/config:PICO_STDIO_USB=True
build --@pico-sdk//bazel/config:PICO_STDIO_UART=True
# UX settings
# ===========
# Error output settings.
common --verbose_failures
# Platform configuration
# ======================
common --custom_malloc=//targets:malloc
build --@pigweed//pw_build:default_module_config=//system:module_config
# Host platform default backends.
common --@pigweed//pw_log:backend=@pigweed//pw_log_string
common --@pigweed//pw_log:backend_impl=@pigweed//pw_log_string:impl
common --@pigweed//pw_log_string:handler_backend=@pigweed//pw_system:log_backend
common --@pigweed//pw_sys_io:backend=@pigweed//pw_sys_io_stdio
common --@pigweed//pw_system:io_backend=@pigweed//pw_system:socket_target_io
# My rules
# ========
#
# Avoid incompatible_sandbox_hermetic_tmp causing relative paths to change.
# https://github.com/aspect-build/gcc-toolchain/issues/161
build --noincompatible_sandbox_hermetic_tmp
# Prevent python use of ~/.local/lib
build --action_env=PYTHONNOUSERSITE=1
build --test_env=PYTHONNOUSERSITE=1
# C Compiler Options: https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html
# All Warnings and then some, mark em as errors too
build --copt -Wall
# Warnings are errors
build --copt -Werror
# Let's use the latest and greatest we can
# NOTE this should probably match //bzl:cc.bzl
build --cxxopt='-std=c++23'
build --host_cxxopt='-std=c++23'
# Note you can use //bzl:cc.bzl c_libary as well to define copts for use with
# all of our internal cc_libraries
# Only build tests when testing
test --build_tests_only
# Allow silent builds with --config=quiet
build:quiet --ui_event_filters=-info,-stdout,-stderr
build:quiet --noshow_progress
# Performance per #85
build --experimental_reuse_sandbox_directories
# Have rules_rust use the right hermetic toolchain sysroot, symlink folders
# into execution directory
build --@rules_rust//cargo/settings:experimental_symlink_execroot=True
# Must match PYTHON_VERSION in MODULE.bazel
# LINK(7e463bc3_e4d9_4464_ba39_3217c4a86004)
common --@aspect_rules_py//py:interpreter_version=3.11.9
# Reduce payload size of uploaded build event stream by eliminating duplicate
# file references
common --nolegacy_important_outputs
# For a more detailed timing profile
common --noslim_profile
common --experimental_profile_include_target_label
common --experimental_profile_include_primary_output
# Build Event Server & Remote Caching
# ==================
# TODO(#95): Reconsider nativelink remote caching
# TODO(#96): Consider only enabling BES for github jobs
build --bes_results_url=https://app.buildbuddy.io/invocation/
build --bes_backend=grpcs://remote.buildbuddy.io
build --remote_cache=grpcs://remote.buildbuddy.io
build --remote_download_toplevel # Helps remove network bottleneck if caching is enabled
build --remote_timeout=3600
# Specify this in your user.bazelrc
# build --remote_header=x-buildbuddy-api-key="$BUILDBUDDY_API_KEY"
# When my network is slow, I can build with --config local instead of
# commenting on/off
build:local --bes_backend=
build:local --remote_cache=
# Python Type Checking - mypy
#############################
# register mypy_aspect with Bazel
build --aspects //tools:aspects.bzl%mypy_aspect
# optionally, default enable the mypy checks
build --output_groups=+mypy
# Allow user to extend .bazelrc
# https://bazel.build/configure/best-practices#bazelrc-file
#
# note: this should be at the bottom of the file, so that user-specified
# options override anything in this file
# (https://bazel.build/run/bazelrc#imports)
#
# Note that ci configures this file to specify ci overrides, etc.
try-import %workspace%/user.bazelrc