-
Notifications
You must be signed in to change notification settings - Fork 533
Expand file tree
/
Copy path.bazelrc
More file actions
193 lines (162 loc) · 8.23 KB
/
.bazelrc
File metadata and controls
193 lines (162 loc) · 8.23 KB
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
183
184
185
186
187
188
189
190
191
192
193
# Use local registry to add local download mirrors
common --registry="file:///%workspace%/bazel/thirdparty"
common --registry=https://bcr.bazel.build
# Add git hash to workspace status
build --workspace_status_command=bazel/tools/workspace_status.sh
# Add mirrors for certain download URLs
common --downloader_config=bazel_downloader.cfg
# Limit JVM thread pools to match cgroup CPU limit (nproc reports host CPUs, not cgroup)
# --host_jvm_args is a startup option, see https://bazel.build/run/bazelrc
startup --host_jvm_args=-XX:ActiveProcessorCount=8
startup --host_jvm_args=-XX:ParallelGCThreads=4
startup --host_jvm_args=-XX:ConcGCThreads=2
# enable a local disk cache: this is especially relevant for local builds without an enabled bazel-remote
common:linux --disk_cache=~/.cache/bazel_disk_cache/
common:linux --experimental_disk_cache_gc_max_size=100G
# reading WORKSPACE is disabled by default for Bazel 8
common --enable_workspace
# enable visibility checking for config_settings
common --incompatible_enforce_config_setting_visibility
common --incompatible_config_setting_private_default_visibility
# Enable prebuilt protoc toolchain resolution.
# This will become the default in Bazel 9
# See: https://blog.aspect.build/bazel-9-protobuf
common --incompatible_enable_proto_toolchain_resolution
common --@protobuf//bazel/toolchains:prefer_prebuilt_protoc
# with rules_proto_grpc (5.0.1) we run into
# >>> Error in resolve_tools: Pass an executable or tools argument to ctx.actions.run
# without
common --noincompatible_disallow_ctx_resolve_tools
# default/common bazel args for all commands supporting it
common --experimental_ui_max_stdouterr_bytes=10000000
common --remote_cache_async
common --remote_cache_compression
# send pings after this time of no read operations on the connection, but only if there is at least one pending gRPC call
# only with this flag "grpc_keepalive_timeout" is enabled, defaults to 20s
common --grpc_keepalive_time=10s
# minimum blob size required to compress/decompress with zstd (1MB)
common --experimental_remote_cache_compression_threshold=1048576
common --remote_local_fallback
common --cycles
common --@cmk//distro="ubuntu-24.04"
# Enable Bzlmod for every Bazel command
common --enable_bzlmod
# Do not upload artifacts other than from CI, see below, CMK-18656
common --remote_upload_local_results=false
common --lockfile_mode=error
common --test_summary=detailed
# Required for tools using java such as plantuml
common --java_runtime_version=remotejdk_21
common --java_language_version=21
## For specific commands
# Always require debug info.
# common --copt="-g"
common --flag_alias=cmk_version=@cmk//version
common --flag_alias=cmk_edition=@cmk//edition
common --flag_alias=cmk_distro=@cmk//distro
# For some obscure reason, the re2 project made itself valgrind-dirty by default:
# https://github.com/google/re2/commit/ce6f2884c4b52509fd6c5d12b8f1c40587067784
# Defining the symbol below has a small performance hit, but makes our stuff
# valgrind-clean again, which is a crucial feature for debugging the NEB & CMC!
common --copt="-DRE2_ON_VALGRIND"
clean --async
# all bazel-created temporary and build output files
# clean --expunge
# run ...
common --test_output=all
# Try with our proxy first and fall back to public proxy when fetching go modules.
common --repo_env=GOPROXY="https://bazel-registry.lan.checkmk.net/proxy.golang.org/|https://proxy.golang.org|direct"
# Configure gazelle to use the ~/go/pkg/mod folder for downloaded artifacts.
common --repo_env=GO_REPOSITORY_USE_HOST_MODCACHE=1
# Flags for CI builds
# Definition of "bazel x --config=ci -- ..."
## Common
common:ci --color=no
common:ci --show_progress_rate_limit=0
common:ci --show_timestamps
common:ci --memory_profile=bazel-memory.profile
common:ci --generate_json_trace_profile
common:ci --profile=trace_profile.json
common:ci --//bazel/toolchains/cc/gcc/local:gcc_path=opt
# the onwards set jobs and CPU limits shall be aligned with the k8s pod limits
common:ci --jobs=6
common:ci --loading_phase_threads=4
# setting local_test_jobs to a value higher than specified at job has no effect
common:ci --local_test_jobs=6
common:ci --local_resources=cpu=6
common:ci --worker_max_instances=6
common:ci --local_resources=memory=HOST_RAM*.67
# Enables the experimental local execution scheduling based on CPU load, not estimation of actions one by one.
common:ci --experimental_cpu_load_scheduling
# the later flags will override the previous flags
# upload artifacts only from CI, CMK-18656
common:ci --remote_upload_local_results=true
common:ci --@cmk//distro=UNSET
# For better performance - passes an argument `--skipLibCheck` to *every* spawn of tsc
common --@aspect_rules_ts//ts:skipLibCheck=always
# For more correct typechecks - honor the setting of `skipLibCheck` in the tsconfig.json file
# common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
## For specific commands
# common:ci ...
# Don't require system python for bootstrapping
# See: https://github.com/bazelbuild/rules_python/commit/f5b19dce7bc0837396ac03a425cdb9b64643cf61
# TODO: should be dropped as soon as this becomes the default
# TODO: this should be the overall default, see discussions in
# https://tribe29.slack.com/archives/C03PW9280U9/p1728303949973099
common:ci --@rules_python//python/config_settings:bootstrap_impl=script
common:ci --noshow_progress
# clean:ci ...
# run:ci ...
# test:ci ...
# Flags for Debug builds
# Definition of "bazel x --config=debug -- ..."
## Common
common:debug --announce_rc
# gRPC errors provide stack trace as well
common:debug --verbose_failures
## For specific commands
################################################################################
# Example: bazel build --config=iwyu //non-free/packages/cmc:all
################################################################################
common:iwyu --aspects @bazel_iwyu//bazel/iwyu:iwyu.bzl%iwyu_aspect
common:iwyu --output_groups=report
common:iwyu --@bazel_iwyu//:iwyu_executable=//bazel/tools:iwyu_bin
common:iwyu --@bazel_iwyu//:iwyu_opts="--error"
common:iwyu --@bazel_iwyu//:iwyu_mappings=//bazel/tools:iwyu_mappings
################################################################################
# Example: bazel build --config=mypy //packages/cmk-agent-based:all
################################################################################
common:mypy --aspects //bazel/tools:aspects.bzl%mypy_aspect
common:mypy --output_groups=mypy
# Turn off automatic capturing of environmental stuff like PATH - those will be set explicitly
# (see https://blog.aspect.build/bazelrc-flags)
common --incompatible_strict_action_env
# Set PATH manually (see above) for both action_env and host_action_env
# Note: in the future PATH might not be needed at all as long as Bazel provides all the tools
# currently taken from system. For now we still need `/usr/bin` and `/bin` for stuff like
# `git`, etc.
# Also note that in some distro specific exceptions we force tools to be located in
# `/usr/bin` (by symlinking) when building the build images
common --enable_platform_specific_config
common --action_env=GOPROXY
common:linux --action_env=PATH="/usr/bin:/bin"
common:linux --host_action_env=PATH="/usr/bin:/bin"
common:windows --action_env=PATH="c:\\Windows;c:\\Windows\\system32;C:\\Program Files (x86)\\Windows Kits\\10\\App Certification Kit"
common:windows --host_action_env=PATH="c:\\Windows;c:\\Windows\\system32;C:\\Program Files (x86)\\Windows Kits\\10\\App Certification Kit"
# Default coverage configuration
coverage --keep_going
coverage --build_tests_only
coverage --combined_report=lcov
coverage --nocache_test_results
# The remote.bazelrc file contains the secrets for accessing the remote cache and must be added by the corresponding
# Jenkins job (or a user) in the form of:
# common --remote_cache=grpcs://${USER}:${PASSWORD}@{URL}
try-import %workspace%/remote.bazelrc
# ci.bazelrc can override all of the above (except explicit user-defined stuff)
try-import /etc/ci.bazelrc
# Import a (non-tracked) `user.bazelrc` if available - put worktree specific
# options here you don't want to accidentally submit
try-import %workspace%/user.bazelrc
# Note: unfortunately there is no way to `try-import %home%/user.bazelrc`,
# in order to set user specific options in a worktree-independent way, but
# you can create ~/.bazelrc and put your global stuff there.