# 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//:jvm-builder=@community//:monorepo-jvm-builder_deploy.jar 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 build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 # 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 # protobuf common --incompatible_enable_proto_toolchain_resolution # 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 # https://bazel.build/reference/test-encyclopedia # https://bazel.build/reference/command-line-reference#flag--test_timeout test --test_timeout=60,300,900,14400