| # DO NOT MODIFY THIS FILE IF YOU WANT CHANGES TO YOUR PERSONAL CONFIGURATION. |
| # INSTEAD, MODIFY ONE OF THE FOLLOWING CONFIGURATION FILES DEPENDING ON WHICH |
| # CHECKOUTS YOU WANT TO AFFECT: |
| # If you're not sure what you want, you probably want option 2. See bazel/bazelrcs/example_chromiumos.bazelrc for an example |
| # Option 1) All bazel projects: $HOME/.bazelrc |
| # Option 2) All bazel chromiumos projects: $HOME/.chromiumos.bazelrc |
| # Option 3) This specific chromiumos checkoput: src/workspace.bazelrc |
| |
| # Bzlmod is the new dependency management system in bazel. |
| common --experimental_enable_bzlmod |
| # TODO(b/274698330): In the long term, we'll want to replace this with a GoB |
| # mirror of the BCR. |
| common --registry=https://bcr.bazel.build |
| # TODO(b/274698330): In the long term, we'll want to replace this with a |
| # GoB repo containing all bazel modules used throughout google. This shouldn't |
| # be ChromeOS specific. |
| common --registry=https://raw.githubusercontent.com/matts1/bazel-central-registry/main |
| |
| # Enable the use of RBE remote caching if the appropriate config is selected. |
| import %workspace%/bazel/bazelrcs/remote_build_artifacts.bazelrc |
| |
| |
| # Always show output from actions. |
| common --experimental_ui_max_stdouterr_bytes=-1 |
| |
| |
| # Prevent writing to the remote cache if source files change during the build. |
| # **DISABLED** Only useful when uploading artifacts from local builds, which we |
| # won't do once we have Bazel running in CI builds, and it prevents uploading |
| # artifacts to the remote cache due to actions Bazel takes (see |
| # https://github.com/bazelbuild/bazel/issues/17162). So we don't need it, and |
| # it gets in the way, so we've decided not to use it after all. In 6.x, we could |
| # just comment it out, but it's going to become the default in a later version |
| # so we use the inverse version to protect us against that future change. |
| #build --experimental_guard_against_concurrent_changes |
| #query --experimental_guard_against_concurrent_changes |
| build --noexperimental_guard_against_concurrent_changes |
| query --noexperimental_guard_against_concurrent_changes |
| |
| # Aspect-Recommended bazel flags for all projects |
| # Docs for these flags: https://bazel.build/reference/command-line-reference |
| # Accompanies this blog post: https://blog.aspect.dev/bazelrc-flags |
| |
| ### |
| # Performance fixes |
| ### |
| # Consider --experimental_remote_merkle_tree_cache_size as well |
| build --experimental_remote_merkle_tree_cache |
| query --experimental_remote_merkle_tree_cache |
| # Note: The noexperimental_check_external_repository_files flag requires Bazel 6 |
| build --noexperimental_check_output_files --noexperimental_check_external_repository_files |
| fetch --noexperimental_check_output_files --noexperimental_check_external_repository_files |
| query --noexperimental_check_output_files --noexperimental_check_external_repository_files |
| # Observed to speed up an Angular build from 7.5min to 5min |
| build --experimental_reuse_sandbox_directories |
| # Improve remote cache hit rate |
| build --nostamp |
| # Minimize remote cache downloads |
| build --remote_download_toplevel |
| |
| # Avoid waiting on 'Waiting for build events upload: Build Event Service' |
| build --bes_upload_mode=fully_async |
| |
| ### |
| # Correctness guarantees |
| ### |
| # We disable this for ChromeOS because it throws errors along the lines of |
| # "Infinite symlink chain detected". |
| # startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1 |
| build --sandbox_default_allow_network=false |
| test --incompatible_exclusive_test_sandboxed |
| build --incompatible_strict_action_env |
| build --nolegacy_external_runfiles |
| build --incompatible_remote_results_ignore_disk |
| build --incompatible_default_to_explicit_init_py |
| build --incompatible_allow_tags_propagation |
| fetch --incompatible_allow_tags_propagation |
| query --incompatible_allow_tags_propagation |
| |
| # See github.com/bazelbuild/rules_python/issues/1059 |
| # Without this, packages installed to $HOME/.local/lib/python3.10/site-packages |
| # can be imported from bazel's python. |
| build --action_env=PYTHONNOUSERSITE=1 |
| build --action_env=RUST_BACKTRACE=1 |
| # Allows actions to detect that they're running as a bazel action rather than as |
| # a binary directly (eg. bazel run / test). |
| build --action_env=IS_BAZEL_ACTION=1 |
| |
| # These are symlinked elsewhere. |
| build --deleted_packages=bazel/workspace_root |
| query --deleted_packages=bazel/workspace_root |
| |
| ### Toolchain resolution. |
| build --host_platform=//bazel/platforms:host |
| # Use platforms instead of crostool_top to resolve C++ toolchains. |
| build --incompatible_enable_cc_toolchain_resolution |
| |
| ### |
| # Convenience |
| ### |
| build --remote_local_fallback |
| build --heap_dump_on_oom |
| test --test_verbose_timeout_warnings |
| build --experimental_remote_build_event_upload=minimal |
| |
| # Import project-shared configs. |
| import %workspace%/bazel/bazelrcs/prebuilts.bazelrc |
| |
| # Allow user-specific overrides for this repository. |
| # Should be at the end of this file so that users can override anything above. |
| try-import %workspace%/workspace.bazelrc |
| |
| # Run linters at build time. |
| build:lint --config=clippy |
| build:clippy --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect --output_groups=+clippy_checks |
| |
| # Add a config to run formatter validation at build time. |
| # It’s recommended to only enable this config in CI so formatting issues do not |
| # impact user’s ability to rapidly iterate on changes. |
| # Because aspects can't modify source files, we may want to investigate having |
| # them output some kind of diff, so we can then just apply the diff after. |
| # It's also recommended to run this config in combination with --keep_going, |
| # otherwise it can only give you formatting errors for a single file. |
| build:format --config=rustfmt |
| |
| # Bzlmod doesn't yet have a way of defining a rustfmt toolchain. |
| # Once it does, swap out this line for the one below. |
| build:rustfmt -- |
| # build:rustfmt --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect --output_groups=+rustfmt_checks |
| |
| # When building rust, also add rustc output formatted as json to the bazel |
| # outputs, so that it can be picked up by rust-analyzer. |
| # This isn't needed by CQ - only by local builds, but the cost is negligible. |
| build --@rules_rust//:output_diagnostics=true --output_groups=+rust_lib_rustc_output,+rust_metadata_rustc_output |
| |
| # This will be removed when it becomes the default. |
| build:hermetic_toolchains --config=hermetic_cc --config=hermetic_rust |
| build:hermetic_cc --//bazel/module_extensions/toolchains/cc:hermetic |
| build:hermetic_rust --//bazel/module_extensions/toolchains/rust:hermetic |
| |
| build:nohermetic_toolchains --config=nohermetic_cc --config=nohermetic_rust |
| build:nohermetic_cc --no//bazel/module_extensions/toolchains/cc:hermetic |
| build:nohermetic_rust --no//bazel/module_extensions/toolchains/rust:hermetic |
| |
| build --config=nohermetic_toolchains |
| |
| # Enable printing artifact hashes + verifying ebuilds |
| build --aspects //bazel/portage/build_defs:hash_tracer.bzl%hash_tracer,//bazel/portage/build_defs:hash_tracer.bzl%hash_tracer_validator |