[bazel] Use platform-specific startup options in common.bazelrc (IJI-3155)

From now on all startup options are specified in .bazelrc files to prevent shell-specific issues (e.g. https://youtrack.jetbrains.com/issue/IJI-3155) and improve maintainability.

(cherry picked from commit b8cd66068118444aca05b24b3550b3917e15866e)

GitOrigin-RevId: f0c711bb02532eed6db72ad28ee70804ae7ff570
This commit is contained in:
Ilia Kirianovskii
2025-10-29 15:47:21 +00:00
committed by intellij-monorepo-bot
parent bb149e1af9
commit afba298d9f
8 changed files with 17 additions and 37 deletions
+1 -7
View File
@@ -2,10 +2,4 @@
set -e -u -o pipefail
script_root="$(cd "$(dirname "$0")"; pwd)"
. "$script_root/common.sh"
# shellcheck disable=SC2154
# $output_user_root_opt is defined in common.sh
exec "$BAZEL_REAL" "$output_user_root_opt" "$@"
exec "$BAZEL_REAL" "$@"
+1 -4
View File
@@ -2,8 +2,5 @@
setlocal
call "%~dp0common.bat"
if errorlevel 1 exit /b %ERRORLEVEL%
"%BAZEL_REAL%" %OUTPUT_USER_ROOT_OPT% %*
"%BAZEL_REAL%" %*
exit /b %ERRORLEVEL%
-3
View File
@@ -1,3 +0,0 @@
REM Common code for all Bazel wrappers
REM IJI-2767 Bazel: move bazel output root to a standard location
set OUTPUT_USER_ROOT_OPT=--output_user_root=%LOCALAPPDATA%\JetBrains\MonorepoBazel
-10
View File
@@ -1,10 +0,0 @@
# Common code for all Bazel wrappers
# output_user_root_opt will be used upon running Bazel
# IJI-2767 Bazel: move bazel output root to a standard location
# shellcheck disable=SC2034
case "$(uname -s)" in
Darwin) output_user_root_opt=--output_user_root=~/Library/Caches/JetBrains/MonorepoBazel ;;
Linux) output_user_root_opt=--output_user_root=~/.cache/JetBrains/MonorepoBazel ;;
*) echo "unrecognized operating system $(uname -s)"; exit 1 ;;
esac
+8 -3
View File
@@ -9,20 +9,25 @@
# 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 --host_jvm_args=-XX:+UseZGC
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 --host_jvm_args=-Djdk.nio.file.WatchService.maxEventsPerPoll=1000000 # 1M
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 --host_jvm_args=-Djdk.nio.file.WatchService.bufferSizeToRetrieveEventsPerDirectory=524288 # 512K
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
+5
View File
@@ -1,3 +1,8 @@
# 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
build --nobuild_runfile_links
# rules_kotlin Compiling Kotlin on Windows appears to require --legacy_external_runfiles https://github.com/bazelbuild/rules_kotlin/issues/1309
@@ -3,7 +3,6 @@
set -e -u -o pipefail
ultimate_root="$(cd "$(dirname "$0")/../../../../../.."; pwd)"
community_root="$(cd "$(dirname "$0")/../../../../.."; pwd)"
# Provide packages.jetbrains.team credentials for Bazel in .netrc
# The script will be missing if run from community repository
@@ -12,8 +11,4 @@ if [ -f "$authorizer" ]; then
"$authorizer"
fi
. "$community_root/build/bazel-wrapper/common.sh"
# shellcheck disable=SC2154
# $output_user_root_opt is defined in common.sh
exec "$BAZEL_REAL" "$output_user_root_opt" "$@"
exec "$BAZEL_REAL" "$@"
@@ -9,8 +9,5 @@ REM The script will be missing if run from community repository
if exist "%AUTHORIZER%" call "%AUTHORIZER%"
if errorlevel 1 exit /b %ERRORLEVEL%
call "%~dp0../../../../../build/bazel-wrapper/common.bat"
if errorlevel 1 exit /b %ERRORLEVEL%
"%BAZEL_REAL%" %OUTPUT_USER_ROOT_OPT% %*
"%BAZEL_REAL%" %*
exit /b %ERRORLEVEL%