Skip to content

Commit

Permalink
Upgrade to bazel 6
Browse files Browse the repository at this point in the history
And fix incompatible changes:

* cc_binary no longer appends ".exe" on Windows
* labels for aspects start with "@//" indicating the default repository
* strip_include_prefix usage of "" migrated to "."
  - bazelbuild/bazel#17039
* removes --bes_header from bazelrc
  - Bazel uses an updated google auth library that uses the quota
    project set in the application default credentials

Bug: 266863277
Test: n/a
Change-Id: I6b1b8495a319652cfa12dc4c84da19a7b6ff1346

Former-commit-id: 610b1d46e31165a7db4facb001946a36fe795e4d
  • Loading branch information
Tom Renn committed Jan 30, 2023
1 parent ed05d54 commit 392a59a
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 31 deletions.
2 changes: 1 addition & 1 deletion bazel/bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def main():
sys.exit('Platform %s is not yet supported.' % sys.platform)

env = {}
env['USE_BAZEL_VERSION'] = os.environ.get('USE_BAZEL_VERSION', '5.1.1')
env['USE_BAZEL_VERSION'] = os.environ.get('USE_BAZEL_VERSION', '6.0.0')
bazel = os.path.join(workspace, 'prebuilts', 'tools', platform, 'bazel',
'bazelisk')
args = sys.argv[1:]
Expand Down
2 changes: 0 additions & 2 deletions bazel/common.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ build:release --copt=-w

## Base RBE configuration
build:_remote_base --bes_timeout=240s
build:_remote_base --project_id=908081808034
build:_remote_base --google_default_credentials
build:_remote_base --remote_cache=remotebuildexecution.googleapis.com
build:_remote_base --remote_instance_name=projects/google.com:android-studio-alphasource/instances/default_instance
Expand All @@ -139,7 +138,6 @@ build:_remote_base --strategy=zipper=local
# Publish to the private BES backend.
build:sponge --bes_backend=buildeventservice-pa.googleapis.com
build:sponge --bes_results_url=https://fusion2.corp.google.com/invocations/
build:sponge --bes_header=X-Goog-User-Project=google.com:android-studio-alphasource
build:sponge --workspace_status_command="python3 tools/base/bazel/workspace.py"

# Enable go/antswatcher to process test results.
Expand Down
2 changes: 0 additions & 2 deletions bazel/platforms/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ platform(
"@platforms//cpu:x86_64",
"@platforms//os:linux",
"@bazel_tools//tools/cpp:clang",
"@bazel_toolchains//constraints:xenial",
"@bazel_toolchains//constraints/sanitizers:support_msan",
],
exec_properties = dicts.add(
create_rbe_exec_properties_dict(
Expand Down
2 changes: 1 addition & 1 deletion bazel/proto.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def cc_grpc_proto_library(
tags = tags,
hdrs = hdrs,
copts = select_android(["-std=c++11"], []),
strip_include_prefix = "",
strip_include_prefix = ".",
include_prefix = include_prefix,
)

Expand Down
7 changes: 3 additions & 4 deletions bazel/toplevel.WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ register_toolchains("@windows_toolchains//:python_toolchain")

http_archive(
name = "bazel_toolchains",
sha256 = "83352b6e68fa797184071f35e3b67c7c8815efadcea81bb9cdb6bbbf2e07d389",
strip_prefix = "bazel-toolchains-1.1.3",
sha256 = "02e4f3744f1ce3f6e711e261fd322916ddd18cccd38026352f7a4c0351dbda19",
strip_prefix = "bazel-toolchains-5.1.2",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/1.1.3.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/1.1.3.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/refs/tags/v5.1.2.tar.gz",
],
)

Expand Down
6 changes: 3 additions & 3 deletions bazel/validations/exec_props.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
LARGE_MACHINE_ALLOWLIST = [
# Issue b/228456598
# This target requires a large (min 16 GB) amount of memory to run.
"//tools/adt/idea/sync-perf-tests:intellij.android.sync-perf-tests_tests__ExtraLargeV2",
"@//tools/adt/idea/sync-perf-tests:intellij.android.sync-perf-tests_tests__ExtraLargeV2",
# TODO: This can be moved to standard pool once Gradle 8.0 memory regression is solved.
"//tools/adt/idea/sync-memory-tests:intellij.android.sync-memory-tests_tests__Benchmark500",
"//tools/adt/idea/sync-memory-tests:intellij.android.sync-memory-tests_tests__Benchmark1000",
"@//tools/adt/idea/sync-memory-tests:intellij.android.sync-memory-tests_tests__Benchmark500",
"@//tools/adt/idea/sync-memory-tests:intellij.android.sync-memory-tests_tests__Benchmark1000",
]

LARGE_MACHINE_FAILURE_MESSAGE = """'{}' is trying to use large machines.
Expand Down
7 changes: 6 additions & 1 deletion bazel/validations/flaky.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ def _has_intersect(this, other):

def _limit_flaky_tests_impl(target, ctx):
if ctx.rule.kind.endswith("_test"):
if ctx.rule.attr.flaky and str(ctx.label) not in APPROVED_FLAKY_TESTS:
label = str(ctx.label)

# Starting in Bazel 6, targets in the default workspace start with '@'.
if label.startswith("@//"):
label = label[1:]
if ctx.rule.attr.flaky and str(label) not in APPROVED_FLAKY_TESTS:
if not _has_intersect(IGNORE_TAG, ctx.rule.attr.tags):
fail(FAILURE_MESSAGE.format(str(ctx.label)))
return []
Expand Down
5 changes: 1 addition & 4 deletions debuggers/native/coroutine/agent/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ android_cc_binary(
"armeabi-v7a",
"arm64-v8a",
],
binary = select({
"//tools/base/bazel:windows": ":coroutine_debugger_agent.so.stripped.exe",
"//conditions:default": ":coroutine_debugger_agent.so.stripped",
}),
binary = ":coroutine_debugger_agent.so.stripped",
filename = "coroutine_debugger_agent.so",
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Make sure debug info don't be stripped in our BUILD files.
Change the "stripped" dependencies to normal:
```
binary = select({
"//tools/base/bazel:windows": ":installer.stripped.exe",
"//tools/base/bazel:windows": ":installer.stripped",
# "//conditions:default": ":installer.stripped",
"//conditions:default": ":installer",
}),
Expand Down
5 changes: 1 addition & 4 deletions deploy/agent/native/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ android_cc_binary(
"armeabi-v7a",
"arm64-v8a",
],
binary = select({
"//tools/base/bazel:windows": ":libswap.so.stripped.exe",
"//conditions:default": ":libswap.so.stripped",
}),
binary = ":libswap.so.stripped",
filename = "android-libswap.so",
tags = [
"no_windows",
Expand Down
10 changes: 2 additions & 8 deletions deploy/installer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,7 @@ android_cc_binary(
"armeabi-v7a",
"arm64-v8a",
],
binary = select({
"//tools/base/bazel:windows": ":installer.stripped.exe",
"//conditions:default": ":installer.stripped",
}),
binary = ":installer.stripped",
filename = "android-installer_raw",
tags = ["no_windows"],
visibility = ["//tools/base/deploy:__subpackages__"],
Expand All @@ -299,10 +296,7 @@ android_cc_binary(
"armeabi-v7a",
"arm64-v8a",
],
binary = select({
"//tools/base/bazel:windows": ":install-server.stripped.exe",
"//conditions:default": ":install-server.stripped",
}),
binary = ":installer.stripped",
filename = "android-install-server",
tags = [
"no_windows",
Expand Down

0 comments on commit 392a59a

Please sign in to comment.