1*7594170eSAndroid Build Coastguard Worker# Use the target platform (android_x86, android_arm) in the bazel-out/ output 2*7594170eSAndroid Build Coastguard Worker# directory name fragment instead of the CPU (darwin, k8). This avoids 3*7594170eSAndroid Build Coastguard Worker# thrashing the output directory when switching between top level target 4*7594170eSAndroid Build Coastguard Worker# --platforms values. 5*7594170eSAndroid Build Coastguard Workerbuild --experimental_platform_in_output_dir 6*7594170eSAndroid Build Coastguard Worker 7*7594170eSAndroid Build Coastguard Worker# Use toolchain resolution to find the cc toolchain. 8*7594170eSAndroid Build Coastguard Workerbuild --incompatible_enable_cc_toolchain_resolution 9*7594170eSAndroid Build Coastguard Worker 10*7594170eSAndroid Build Coastguard Worker# Ensure that the host_javabase always use the checked-in JDK. 11*7594170eSAndroid Build Coastguard Workerbuild --tool_java_runtime_version=jdk21 12*7594170eSAndroid Build Coastguard Workerbuild --java_runtime_version=jdk21 13*7594170eSAndroid Build Coastguard Worker 14*7594170eSAndroid Build Coastguard Worker# Lock down the PATH variable in actions to /usr/bin and /usr/local/bin. 15*7594170eSAndroid Build Coastguard Workerbuild --experimental_strict_action_env 16*7594170eSAndroid Build Coastguard Worker 17*7594170eSAndroid Build Coastguard Worker# Explicitly allow unresolved symlinks (it's an experimental Bazel feature) 18*7594170eSAndroid Build Coastguard Workerbuild --experimental_allow_unresolved_symlinks 19*7594170eSAndroid Build Coastguard Worker 20*7594170eSAndroid Build Coastguard Worker# Enable SCL because some files are shared between bazel and make/soong 21*7594170eSAndroid Build Coastguard Workercommon --experimental_enable_scl_dialect 22*7594170eSAndroid Build Coastguard Worker 23*7594170eSAndroid Build Coastguard Worker# Enable usage of experimental cc-related build APIs 24*7594170eSAndroid Build Coastguard Workercommon --experimental_cc_shared_library 25*7594170eSAndroid Build Coastguard Workerbuild --experimental_starlark_cc_import 26*7594170eSAndroid Build Coastguard Worker 27*7594170eSAndroid Build Coastguard Worker# Do not enable BzlMod as the migration to bzlmod has not been done yet 28*7594170eSAndroid Build Coastguard Workercommon --noenable_bzlmod 29*7594170eSAndroid Build Coastguard Worker 30*7594170eSAndroid Build Coastguard Worker# Do not tokenize copts, other than strings that consist of a single Make 31*7594170eSAndroid Build Coastguard Worker# variable. This prevents the need to double-escape characters like backslashes 32*7594170eSAndroid Build Coastguard Worker# and quotes in copts. 33*7594170eSAndroid Build Coastguard Workerbuild --features no_copts_tokenization 34*7594170eSAndroid Build Coastguard Worker 35*7594170eSAndroid Build Coastguard Worker# Disable local cpp toolchain detection, as it is explicitly declared in AOSP. 36*7594170eSAndroid Build Coastguard Workerbuild --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 37*7594170eSAndroid Build Coastguard Worker 38*7594170eSAndroid Build Coastguard Workerbuild --proto_compiler=//external/protobuf:aprotoc 39*7594170eSAndroid Build Coastguard Worker 40*7594170eSAndroid Build Coastguard Worker# Disable sandboxing for CppCompile actions, as headers are not fully specified. 41*7594170eSAndroid Build Coastguard Worker# TODO(b/186116353): This is a temporary fix, as appropriately-sandboxed actions 42*7594170eSAndroid Build Coastguard Worker# are a long term goal. 43*7594170eSAndroid Build Coastguard Workerbuild --strategy=CppCompile=standalone 44*7594170eSAndroid Build Coastguard Worker 45*7594170eSAndroid Build Coastguard Worker# Enable use of the implementation_deps attribute in native cc rules 46*7594170eSAndroid Build Coastguard Workerbuild --experimental_cc_implementation_deps 47*7594170eSAndroid Build Coastguard Worker 48*7594170eSAndroid Build Coastguard Worker# Use the llvm_coverage_map_format feature to turn on native code coverage. 49*7594170eSAndroid Build Coastguard Workerbuild --experimental_use_llvm_covmap 50*7594170eSAndroid Build Coastguard Worker 51*7594170eSAndroid Build Coastguard Worker# Always emit the stdout of failing tests as they should be emphasized. (b/247516541) 52*7594170eSAndroid Build Coastguard Workertest --test_output=errors 53*7594170eSAndroid Build Coastguard Worker 54*7594170eSAndroid Build Coastguard Worker# Enable building targets in //external:__subpackages__. 55*7594170eSAndroid Build Coastguard Workercommon --experimental_sibling_repository_layout 56*7594170eSAndroid Build Coastguard Workercommon --experimental_disable_external_package 57*7594170eSAndroid Build Coastguard Worker 58*7594170eSAndroid Build Coastguard Worker# Disable all repository_ctx.download calls. 59*7594170eSAndroid Build Coastguard Workercommon --repository_disable_download 60*7594170eSAndroid Build Coastguard Worker 61*7594170eSAndroid Build Coastguard Worker# Increase refresh rate of command line UI for improved perceived responsiveness. 62*7594170eSAndroid Build Coastguard Workercommon --show_progress_rate_limit=0.05 63*7594170eSAndroid Build Coastguard Worker 64*7594170eSAndroid Build Coastguard Worker# These are disabled when running under soong_ui (default = auto). Force enable them here. 65*7594170eSAndroid Build Coastguard Workercommon --color=yes 66*7594170eSAndroid Build Coastguard Workercommon --curses=yes 67*7594170eSAndroid Build Coastguard Worker 68*7594170eSAndroid Build Coastguard Worker# Configurations specific to CI builds, generally to improve signal-to-noise ratio in server logs. 69*7594170eSAndroid Build Coastguard Workercommon:ci --color=yes 70*7594170eSAndroid Build Coastguard Workercommon:ci --curses=no 71*7594170eSAndroid Build Coastguard Workercommon:ci --show_progress_rate_limit=5 72*7594170eSAndroid Build Coastguard Workercommon:ci --noshow_loading_progress 73*7594170eSAndroid Build Coastguard Worker# Show the full set of flags for observability and debuggability. 74*7594170eSAndroid Build Coastguard Workercommon:ci --announce_rc 75*7594170eSAndroid Build Coastguard Workerbuild:ci --verbose_failures 76*7594170eSAndroid Build Coastguard Workertest:ci --keep_going 77*7594170eSAndroid Build Coastguard Worker 78*7594170eSAndroid Build Coastguard Worker# Support a local user-specific bazelrc file. 79*7594170eSAndroid Build Coastguard Workertry-import %workspace%/user.bazelrc 80*7594170eSAndroid Build Coastguard Worker 81*7594170eSAndroid Build Coastguard Worker# Get rid no-op "affected by Starlark transition" config when label-based flag 82*7594170eSAndroid Build Coastguard Worker# (i.e. //command_line_option:fdo_profile) is set back to None 83*7594170eSAndroid Build Coastguard Workerbuild --experimental_output_directory_naming_scheme=diff_against_baseline 84*7594170eSAndroid Build Coastguard Workercommon --experimental_google_legacy_api 85*7594170eSAndroid Build Coastguard Workerbuild --android_sdk=//prebuilts/sdk:android_sdk 86*7594170eSAndroid Build Coastguard Workerbuild --incompatible_enable_android_toolchain_resolution 87*7594170eSAndroid Build Coastguard Workercommon --experimental_enable_android_migration_apis 88*7594170eSAndroid Build Coastguard Workercommon --incompatible_java_common_parameters 89*7594170eSAndroid Build Coastguard Workerbuild --android_databinding_use_v3_4_args 90*7594170eSAndroid Build Coastguard Workerbuild --experimental_android_databinding_v2 91*7594170eSAndroid Build Coastguard Workerbuild --define=android_incremental_dexing_tool=d8_dexbuilder 92*7594170eSAndroid Build Coastguard Workerbuild --define=android_dexmerger_tool=d8_dexmerger 93*7594170eSAndroid Build Coastguard Worker 94*7594170eSAndroid Build Coastguard Worker# TODO(b/199038020): Use a python_toolchain when we have Starlark rules_python. 95*7594170eSAndroid Build Coastguard Worker# This also means all python scripts are using py3 runtime. 96*7594170eSAndroid Build Coastguard Workerbuild --python_top=//prebuilts/build-tools:python3 97*7594170eSAndroid Build Coastguard Workerbuild --noincompatible_use_python_toolchains 98*7594170eSAndroid Build Coastguard Worker 99*7594170eSAndroid Build Coastguard Worker 100*7594170eSAndroid Build Coastguard Worker# Enable optimization compilation mode to build cc with fdo 101*7594170eSAndroid Build Coastguard Worker# https://github.com/bazelbuild/bazel/blob/de7b26acfdfcd9c36ec957305a889ac29f0da30e/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoHelper.java#L55 102*7594170eSAndroid Build Coastguard Workerbuild --compilation_mode=opt 103*7594170eSAndroid Build Coastguard Worker 104*7594170eSAndroid Build Coastguard Workercommon --incompatible_remove_rule_name_parameter=false 105*7594170eSAndroid Build Coastguard Worker 106*7594170eSAndroid Build Coastguard Workercommon --override_repository=rules_java_builtin=%workspace%/external/bazelbuild-rules_java 107*7594170eSAndroid Build Coastguard Worker 108*7594170eSAndroid Build Coastguard Worker# TODO(b/264304464): Remove when bugs with java_binary starlark impl are fixed. 109*7594170eSAndroid Build Coastguard Worker 110*7594170eSAndroid Build Coastguard Workercommon --experimental_builtins_injection_override=-java_binary 111*7594170eSAndroid Build Coastguard Worker 112*7594170eSAndroid Build Coastguard Workercommon --experimental_java_library_export 113*7594170eSAndroid Build Coastguard Worker 114*7594170eSAndroid Build Coastguard Worker# Set writable bit for all bazel outputs. This makes it easy to remove 115*7594170eSAndroid Build Coastguard Worker# the output directory and its contents after a build (using `rm`). 116*7594170eSAndroid Build Coastguard Workerbuild --experimental_writable_outputs 117*7594170eSAndroid Build Coastguard Worker 118*7594170eSAndroid Build Coastguard Worker# Make the Linux sandbox work under /tmp 119*7594170eSAndroid Build Coastguard Workerbuild --incompatible_sandbox_hermetic_tmp 120*7594170eSAndroid Build Coastguard Worker 121*7594170eSAndroid Build Coastguard Worker# TODO(b/275690057, b/275727890): Remove this and fix cc_shared_library usage proper. 122*7594170eSAndroid Build Coastguard Workerbuild --noexperimental_link_static_libraries_once 123*7594170eSAndroid Build Coastguard Worker 124*7594170eSAndroid Build Coastguard Worker# native.py rules are being ported to Starlark: https://github.com/bazelbuild/bazel/issues/15897 125*7594170eSAndroid Build Coastguard Worker# 126*7594170eSAndroid Build Coastguard Worker# TODO(b/200202912): Resolve/delete this when rules_python is pulled into AOSP. 127*7594170eSAndroid Build Coastguard Worker# 128*7594170eSAndroid Build Coastguard Worker# Need this, otherwise: 129*7594170eSAndroid Build Coastguard Worker# 130*7594170eSAndroid Build Coastguard Worker# ERROR: .. in py_runtime rule //prebuilts/build-tools:python2: 131*7594170eSAndroid Build Coastguard Worker# Traceback (most recent call last): 132*7594170eSAndroid Build Coastguard Worker# File "/virtual_builtins_bzl/common/python/py_runtime_rule.bzl", line 24, column 25, in _py_runtime_impl 133*7594170eSAndroid Build Coastguard Worker# File "/virtual_builtins_bzl/common/python/common.bzl", line 509, column 13, in check_native_allowed 134*7594170eSAndroid Build Coastguard Worker# Error in fail: //prebuilts/build-tools:python2 not allowed to use native.py_runtime 135*7594170eSAndroid Build Coastguard Worker# Generated by: py_runtime(name=python2) in prebuilts/build-tools/BUILD.bazel:63:11 136*7594170eSAndroid Build Coastguard Worker# Allowlist: no allowlist specified; all disallowed; specify one with --python_native_rules_allowlist 137*7594170eSAndroid Build Coastguard Worker# Migrate to using @rules_python, see https://github.com/bazelbuild/bazel/issues/17773 138*7594170eSAndroid Build Coastguard Worker# FIXCMD: add_python_loads --target=//prebuilts/build-tools:python2 --rule=py_runtime --generator_name=python2 --location=prebuilts/build-tools/BUILD.bazel:63:11 139*7594170eSAndroid Build Coastguard Worker# 140*7594170eSAndroid Build Coastguard Worker# See also message in https://github.com/bazelbuild/bazel/commit/2e558ed5dccdcc72622df52bf6d4dfe90ddc390c 141*7594170eSAndroid Build Coastguard Workerbuild --noincompatible_python_disallow_native_rules 142*7594170eSAndroid Build Coastguard Worker 143*7594170eSAndroid Build Coastguard Worker# Google internal operations 144*7594170eSAndroid Build Coastguard Workertry-import %workspace%/vendor/google/tools/soong_config/googler.bazelrc 145*7594170eSAndroid Build Coastguard Worker 146*7594170eSAndroid Build Coastguard Workerbuild --incompatible_visibility_private_attributes_at_definition 147*7594170eSAndroid Build Coastguard Worker 148*7594170eSAndroid Build Coastguard Worker# Some targets in rules_go use config_setting(s) that are not visible to them 149*7594170eSAndroid Build Coastguard Worker# TODO - b/289074954: Fix the visibility defs in rules_go and re-enable this enforcement. 150*7594170eSAndroid Build Coastguard Workerbuild --incompatible_enforce_config_setting_visibility=false 151*7594170eSAndroid Build Coastguard Worker 152*7594170eSAndroid Build Coastguard Worker# By default, b test will run all tests regardless of deviceless or device variants. 153*7594170eSAndroid Build Coastguard Worker# Use these configs to filter the tests to run, e.g. b test //system/... --config=deviceless_tests 154*7594170eSAndroid Build Coastguard Worker# The filter value is the name of the rule, but without the "_test" suffix. 155*7594170eSAndroid Build Coastguard Workertest:deviceless_tests --test_lang_filters=tradefed_deviceless 156*7594170eSAndroid Build Coastguard Workertest:device_tests --test_lang_filters=tradefed_device_driven,tradefed_host_driven_device 157*7594170eSAndroid Build Coastguard Worker 158*7594170eSAndroid Build Coastguard Worker# Supporting cgo for building go code is not required 159*7594170eSAndroid Build Coastguard Worker# Disable it explcitly to prevent issues with C toolchain setup 160*7594170eSAndroid Build Coastguard Workerbuild --@io_bazel_rules_go//go/config:pure 161*7594170eSAndroid Build Coastguard Worker 162*7594170eSAndroid Build Coastguard Worker# Breaking bazel feature for the 7/25 release. b/292565910 163*7594170eSAndroid Build Coastguard Workercommon --noincompatible_use_host_features 164*7594170eSAndroid Build Coastguard Worker 165*7594170eSAndroid Build Coastguard Worker# Run GoToolchainBinaryBuild in a sandbox 166*7594170eSAndroid Build Coastguard Worker# Without sandboxing, the action will run in an execution root that contains a symlink to prebuilts/go 167*7594170eSAndroid Build Coastguard Worker# This causes issues due to two separate factors combining together 168*7594170eSAndroid Build Coastguard Worker# a. The GOROOT in our checked in go binary is relative to android build top 169*7594170eSAndroid Build Coastguard Worker# b. GoToolchainBinaryBuild uses GOCACHE=$(mktemp -d) 170*7594170eSAndroid Build Coastguard Workerbuild --strategy GoToolchainBinaryBuild=sandboxed 171*7594170eSAndroid Build Coastguard Worker 172*7594170eSAndroid Build Coastguard Workerstartup --connect_timeout_secs=45 173*7594170eSAndroid Build Coastguard Worker 174*7594170eSAndroid Build Coastguard Worker# TODO(b/300376073): Reuse the RBE instance of BES for remote test. 175*7594170eSAndroid Build Coastguard Worker###### Remote Virtual Device Test Execution Configuration. 176*7594170eSAndroid Build Coastguard Worker###### 177*7594170eSAndroid Build Coastguard Worker# --flag_alias does not work with --config, has to be defined for top level build command 178*7594170eSAndroid Build Coastguard Workerbuild --flag_alias=ab_build_id=//build/bazel_common_rules/rules/remote_device:build_id 179*7594170eSAndroid Build Coastguard Workerbuild --flag_alias=ab_target=//build/bazel_common_rules/rules/remote_device:target 180*7594170eSAndroid Build Coastguard Workerbuild --flag_alias=ab_branch=//build/bazel_common_rules/rules/remote_device:branch 181*7594170eSAndroid Build Coastguard Worker 182*7594170eSAndroid Build Coastguard Workertest:remote_avd --config=remote 183*7594170eSAndroid Build Coastguard Workertest:remote_avd --test_timeout=3600 184*7594170eSAndroid Build Coastguard Workertest:remote_avd --//build/bazel_common_rules/rules/remote_device:target_device=//build/bazel_common_rules/rules/remote_device:cf_x86_64_phone 185*7594170eSAndroid Build Coastguard Workertest:remote_avd --//build/bazel_common_rules/rules/remote_device:exec_mode=remote 186*7594170eSAndroid Build Coastguard Workertest:remote_avd --experimental_credential_helper_timeout=60s 187*7594170eSAndroid Build Coastguard Workertest:remote_avd --google_default_credentials=true 188*7594170eSAndroid Build Coastguard Worker 189*7594170eSAndroid Build Coastguard Workerbuild:remote_avd --spawn_strategy=sandboxed # force disable remote cache, some actions don't work with it 190*7594170eSAndroid Build Coastguard Workerbuild:remote_avd --strategy=AbiDump=local # force disable sandbox 191*7594170eSAndroid Build Coastguard Workerbuild:remote_avd --strategy=AbiLink=local # force disable sandbox 192*7594170eSAndroid Build Coastguard Workerbuild:remote_avd --strategy=AbiDiff=local # force disable sandbox 193*7594170eSAndroid Build Coastguard Workertest:remote_avd --strategy=DownloadCvd=remote 194*7594170eSAndroid Build Coastguard Worker# Certain tests are tagged "no-remote", so allow sandboxed fallback to avoid forcing all tests to run remotely. 195*7594170eSAndroid Build Coastguard Workertest:remote_avd --strategy=TestRunner=remote,sandboxed 196*7594170eSAndroid Build Coastguard Workertest:remote_avd --test_env=PATH="/bin:/usr/bin/" 197*7594170eSAndroid Build Coastguard Worker 198*7594170eSAndroid Build Coastguard Worker# Depending on how many machines are in the remote execution instance, setting 199*7594170eSAndroid Build Coastguard Worker# this higher can make builds faster by allowing more jobs to run in parallel. 200*7594170eSAndroid Build Coastguard Worker# Setting it too high can result in jobs that timeout, however, while waiting 201*7594170eSAndroid Build Coastguard Worker# for a remote machine to execute them. 202*7594170eSAndroid Build Coastguard Workertest:remote --jobs=200 203*7594170eSAndroid Build Coastguard Workertest:remote --remote_cache=grpcs://remotebuildexecution.googleapis.com 204*7594170eSAndroid Build Coastguard Workertest:remote --remote_executor=grpcs://remotebuildexecution.googleapis.com 205*7594170eSAndroid Build Coastguard Workertest:remote --remote_timeout=3600 206*7594170eSAndroid Build Coastguard Worker 207