-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Expand file tree
/
Copy pathcommon.bazelrc
More file actions
182 lines (141 loc) · 8.78 KB
/
common.bazelrc
File metadata and controls
182 lines (141 loc) · 8.78 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
# Common bazel settings between open source community repository and the monorepo
### Profiles ###
# ci — configuration tailored for CI
### --- ###
# Limit the server memory usage as per https://youtrack.jetbrains.com/issue/IJI-3103#focus=Comments-27-12862178.0-0
startup --host_jvm_args=-Xmx12g
# IJI-2767 Bazel: move bazel output root to a standard location
startup:macos --output_user_root=~/Library/Caches/JetBrains/MonorepoBazel
startup:linux --output_user_root=~/.cache/JetBrains/MonorepoBazel
startup:windows --output_user_root=~/AppData/Local/JetBrains/MonorepoBazel
# Use low-latency ZGC to prevent overflow when watching local filesystem for changes on Windows
#
# G1GC pauses the sun.nio.fs.WindowsWatchService.Poller's thread, delaying asynchronous callback processing long enough
# that ReadDirectoryChangesW returns zero bytes transferred (aka StandardWatchEventKinds.OVERFLOW):
# https://github.com/openjdk/jdk/blob/6705a9255d28f351950e7fbca9d05e73942a4e27/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java#L630
startup:windows --host_jvm_args=-XX:+UseZGC
# Increase file watch service queue maximum size to prevent overflow when watching local filesystem for changes on Windows
# https://github.com/openjdk/jdk/blob/6705a9255d28f351950e7fbca9d05e73942a4e27/src/java.base/share/classes/sun/nio/fs/AbstractWatchKey.java#L39
startup:windows --host_jvm_args=-Djdk.nio.file.WatchService.maxEventsPerPoll=1000000 # 1M
# Increase size of per-directory buffer for events to prevent overflow when watching local filesystem for changes on Windows
# https://github.com/JetBrains/JetBrainsRuntime/blob/d7e087876fa0326af082e705483a079b919242bc/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java#L290
startup:windows --host_jvm_args=-Djdk.nio.file.WatchService.bufferSizeToRetrieveEventsPerDirectory=524288 # 512K
# Disk cache
common --experimental_disk_cache_gc_max_size=32G --experimental_disk_cache_gc_max_age=28d
common:macos --disk_cache=~/Library/Caches/JetBrains/monorepo-bazel-cache
common:linux --disk_cache=~/.cache/JetBrains/monorepo-bazel-cache
common:windows --disk_cache=~/AppData/Local/Temp/JetBrains/monorepo-bazel-cache
### NOTE on --experimental_sibling_repository_layout
### The option was removed due to https://github.com/bazelbuild/bazel/issues/26361
### One experimental option less and also it looks like it won't enabled by default in the future
common --@rules_jvm//:default-javac-opts=@community//:default-javac-opts
common --@rules_jvm//:default-kotlinc-opts=@community//:k21
common --@rules_jvm//:koltin_inc_threshold=0 --@rules_jvm//:java_inc_threshold=0
# configure resources
common --local_resources=memory=HOST_RAM*.77 --local_resources=cpu=HOST_CPUS*2
common --jobs=HOST_CPUS*2 --worker_max_multiplex_instances=JvmCompile=HOST_CPUS*2
# Force all workers to quit after the build to prevent excessive memory usage when idle
common --worker_quit_after_build
# hide Java 8 deprecation warnings
common --javacopt=-Xlint:-options
# https://bazel.build/docs/bazel-and-java#hermetic-testing
# The code is compiled for, executed, and tested on this JVM.
common --java_language_version=21
common --java_runtime_version=remotejbr_21
# see https://bazel.build/external/lockfile
# use `bazel mod deps --lockfile_mode=refresh` to update lock file
common --lockfile_mode=error
common:windows --lockfile_mode=off # todo: https://youtrack.jetbrains.com/issue/DPE-59
common --noenable_workspace
common --nolegacy_external_runfiles
# rules_kotlin Compiling Kotlin on Windows appears to require --legacy_external_runfiles https://github.com/bazelbuild/rules_kotlin/issues/1309
# Otherwise it fails with
# LAUNCHER ERROR: Rlocation failed on _main/external/rules_kotlin++rules_kotlin_extensions+com_github_jetbrains_kotlin_git/lib/annotations-13.0.jar, path doesn't exist in MANIFEST file
# also see
# https://github.com/bazelbuild/rules_kotlin/issues/1300
common:windows --legacy_external_runfiles
# Without it it fails in Windows Sandbox with:
# ERROR: C:/users/wdagutilityaccount/desktop/bazel/BUILD.bazel:24:15: JdepsMerge //:jps_to_bazel-lib { jdeps: 1 } failed: Worker process did not return a WorkResponse:
# ---8<---8<--- Start of log, file at C:/users/wdagutilityaccount/_bazel_wdagutilityaccount/ilgdy3ge/bazel-workers/worker-7-JdepsMerge.log ---8<---8<---
# LAUNCHER ERROR: Rlocation failed on rules_kotlin++rules_kotlin_extensions+com_github_jetbrains_kotlin_git/lib/annotations-13.0.jar, path doesn't exist in MANIFEST file
# ---8<---8<--- End of log ---8<---8<---
# also see
# https://github.com/bazelbuild/rules_kotlin/issues/1309
# https://github.com/bazelbuild/rules_kotlin/issues/1300
#
# jdeps is used to check that there are no unused dependencies for target
# which is we don't need for generator
build:windows --@rules_kotlin//kotlin/settings:jvm_emit_jdeps=False
# https://bazel.build/docs/bazel-and-java#config-build-tools-java
# A second pair of JDK and JVM used to build and execute tools, which are used in the build process, but are not in the build results.
# That JDK and JVM are controlled using --tool_java_language_version and --tool_java_runtime_version
common --tool_java_language_version=21
# Java runtime the tools should use
common --tool_java_runtime_version=remotejbr_21
# make sure you don't need to open file to read compilation errors
common --experimental_ui_max_stdouterr_bytes=-1
common --experimental_ui_max_stdouterr_bytes=-1
# IDEA do not handle symlinks efficiently (freeze due to modal non-cancellable dialog) and no way to exclude directories by pattern bazel-
common --symlink_prefix=out/bazel-
# FS Watch
common --watchfs
common --experimental_windows_watchfs
common:linux --nowatchfs
common:ci --nowatchfs
common --enable_platform_specific_config
common --incompatible_strict_action_env=true
# Use target platform short name (not CPU) in the output directory
common --experimental_platform_in_output_dir
# Do not depend on external environment
common --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
common --action_env BAZEL_NO_APPLE_CPP_TOOLCHAIN=1
startup --noautodetect_server_javabase
# Clear PATH environment variable to enable remote cache hits on Windows
#
# rules_java uses use_default_shell_env=True leading to different PATH values in actions:
# C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32;C:\\Windows\\System32\\WindowsPowerShell\\v1.0
# C:\\Users\\Ilia.Kirianovskii\\AppData\\Local\\Microsoft\\WindowsApps;C:\\WINDOWS;C:\\WINDOWS\\System32;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0
# https://github.com/bazelbuild/bazel/blob/93cde47ab3236b3b7124b41824f843f3659064de/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java#L162
common:windows --action_env=PATH=C:\\do-not-use-PATH
# Enable compact *.repo_mapping manifest
build --incompatible_compact_repo_mapping_manifest
# Generally good remote cache tweaks
# on CI, set remote_cache_async to false! set to false for local runs also, to investigate https://github.com/bazelbuild/bazel/issues/19273
common --remote_cache_async=false --remote_cache_compression=true
common:ci --remote_cache_async=false
# https://www.buildbuddy.io/blog/debugging-slow-bazel-builds/
# check if `--remote_download_outputs=minimal` makes sense for CI or some local builds
build --remote_build_event_upload=minimal
build --nolegacy_important_outputs
# Avoid
# Exception in thread "main" java.io.IOException: Error getting terminal size: GetConsoleScreenBufferInfo error 6
# at coursier.jniutils.WindowsAnsiTerminal.terminalSize(WindowsAnsiTerminal.java:10)
common:windows --repo_env=COURSIER_NO_TERM=true
common:windows --repo_env=COURSIER_PROGRESS=false
# Enable on Bazel 9
# common --experimental_strict_repo_env
# More debug on CI
common:ci --announce_rc
common:ci --show_progress_rate_limit=30
# avoid creating a runfiles tree for binaries or tests until it is needed
build --nobuild_runfile_links
# detailed tests output by default
# https://bazel.build/reference/command-line-reference#build-flag--test_summary
test --test_summary=detailed
# streamed tests output by default
# https://bazel.build/reference/command-line-reference#build-flag--test_output
test --test_output=streamed
# https://bazel.build/reference/test-encyclopedia
# https://bazel.build/reference/command-line-reference#flag--test_timeout
test --test_timeout=60,300,900,14400
# A workaround for https://github.com/bazelbuild/rules_kotlin/issues/1352
common --repo_env=ANDROID_HOME=
# Use prebuilt protoc instead of building from source, https://protobuf.dev/news/2026-01-16/
common --incompatible_enable_proto_toolchain_resolution
common --@protobuf//bazel/toolchains:prefer_prebuilt_protoc=true
# need to use Python from rules_python in rules_pkg in pkg_zip target
common --@rules_python//python/config_settings:bootstrap_impl=script
# Retry downloads up to 5 times
common --experimental_repository_downloader_retries=5
# Scale HTTP timeouts by 2x
common --http_timeout_scaling=2.0