Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel: Migrate to bazel 7; use bzlmod for dependencies #293

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 6 additions & 41 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,64 +1,29 @@
"""remote-apis dependencies"""

module(
name = "bazel_remote_apis",
repo_name = "com_github_bazelbuild_remote_apis",
name = "remoteapis",
Copy link

@mmorel-35 mmorel-35 Jun 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall it be this instead ?

Suggested change
name = "remoteapis",
name = "remote-apis",
repo_name = "bazel_remote_apis",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i pulled the non-dash version because that's what bazel uses, any precedent for folks using the other one? I didn't need to mirror the repo_name since it's never accessed

version = "0",
)

# deps
bazel_dep(name = "gazelle", version = "0.35.0")
bazel_dep(name = "googleapis", version = "0.0.0-20240326-1c8d509c5", repo_name = "com_google_googleapis")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_go", version = "0.44.2")
bazel_dep(name = "rules_java", version = "7.3.2")
bazel_dep(name = "rules_proto", version = "6.0.0-rc1")
bazel_dep(name = "rules_proto_grpc_cpp", version = "5.0.0-alpha2")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")

# dev deps
bazel_dep(name = "toolchains_llvm", version = "0.10.3", dev_dependency = True)

# Top-level projects will need a C++ toolchain to build protoc, grpc, etc., but
# we shouldn't dictate their toolchain, so the toolchain is marked as a dev
# dependency.
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True)
llvm.toolchain(
# This is a version of LLVM that builds absl and upb successfully with their
# default compile options.
#
# TODO: Update this to the latest version of LLVM possible
llvm_version = "13.0.0",
)
use_repo(llvm, "llvm_toolchain")
register_toolchains("@llvm_toolchain//:all", dev_dependency = True)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this version doesn't support macOS, excluding it just replies on the host having a CC toolchain installed, we could probably bring this back with a different version to support macOS too but I think the norm is normally to expect the host to have something for this


go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(
go_deps,
"com_google_cloud_go_longrunning",
"org_golang_google_genproto",
"org_golang_google_genproto_googleapis_api",
"org_golang_google_genproto_googleapis_rpc",
"org_golang_google_grpc",
"org_golang_google_protobuf",
)

# googleapis workaround for lack of bzlmod support
# From: https://github.com/bazelbuild/rules_go/issues/3685#issuecomment-1711854475
#
# TODO: Drop this once googleapis has official bzlmod support
bazel_dep(name = "com_google_googleapis", version = "64926d52febbf298cb82a8f472ade4a3969ba922")
archive_override(
module_name = "com_google_googleapis",
integrity = "sha256-nRqTDnZ8k8glOYuPhpLso/41O5qq3t+88fyiKCyF34g=",
patch_strip = 1,
patches = [
"patches/googleapis_add_bzlmod_support.patch",
],
strip_prefix = "googleapis-64926d52febbf298cb82a8f472ade4a3969ba922",
urls = [
"https://github.com/googleapis/googleapis/archive/64926d52febbf298cb82a8f472ade4a3969ba922.zip",
],
)
switched_rules = use_extension("@com_google_googleapis//:extensions.bzl", "switched_rules")
switched_rules.use_languages()
switched_rules.use_languages(go = True)
use_repo(switched_rules, "com_google_googleapis_imports")
10 changes: 5 additions & 5 deletions build/bazel/remote/execution/v2/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ proto_library(
srcs = ["remote_execution.proto"],
deps = [
"//build/bazel/semver:semver_proto",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
"@com_google_googleapis//google/api:annotations_proto",
"@com_google_googleapis//google/api:http_proto",
"@com_google_googleapis//google/longrunning:operations_proto",
"@com_google_googleapis//google/rpc:status_proto",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
],
)

Expand All @@ -31,7 +31,7 @@ go_grpc_library(
protos = [":remote_execution_proto"],
deps = [
"//build/bazel/semver:semver_go_grpc",
"@org_golang_google_genproto//googleapis/longrunning",
"@com_google_googleapis//google/longrunning:longrunning_go_proto",
"@org_golang_google_genproto_googleapis_api//annotations",
"@org_golang_google_genproto_googleapis_rpc//http",
"@org_golang_google_genproto_googleapis_rpc//status",
Expand Down
5 changes: 4 additions & 1 deletion build/bazel/semver/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ cpp_grpc_library(

cpp_grpc_library(
name = "client_cpp_grpc",
protos = ["@com_google_googleapis//google/api:client_proto"],
protos = [
"@com_google_googleapis//google/api:client_proto",
"@com_google_googleapis//google/api:launch_stage_proto",
],
)

cpp_grpc_library(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/bazelbuild/remote-apis
go 1.21

require (
cloud.google.com/go/longrunning v0.5.4
google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac
google.golang.org/genproto/googleapis/api v0.0.0-20240116215550-a9fa1716bcac
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac
Expand All @@ -11,7 +12,6 @@ require (
)

require (
cloud.google.com/go/longrunning v0.5.4 // indirect
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
Expand Down