Skip to content
New issue

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

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

Already on GitHub? # to your account

bazel: Migrate to bzlmod for dependency management #189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.4.1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bazel-*
26 changes: 26 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module(
name = "gnmi",
)

bazel_dep(name = "grpc", version = "1.66.0.bcr.3")
bazel_dep(name = "protobuf", version = "28.0")
bazel_dep(name = "rules_go", version = "0.50.1")
bazel_dep(name = "rules_proto", version = "6.0.2")
bazel_dep(name = "rules_proto_grpc", version = "5.0.0")
bazel_dep(name = "rules_proto_grpc_cpp", version = "5.0.0")
bazel_dep(name = "toolchains_protoc", version = "0.3.3")

protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")

# protoc toolchain version must match version of `protobuf` bazel_dep above; see
# https://protobuf.dev/support/cross-version-runtime-guarantee/#cpp for more
# info
protoc.toolchain(
google_protobuf = "com_google_protobuf",
version = "v28.0",
)

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")

# Should match version listed in go.mod
go_sdk.download(version = "1.22.0")
5,182 changes: 5,182 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

30 changes: 0 additions & 30 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,3 @@
# limitations under the License.

workspace(name = "gnmi")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_go",
sha256 = "d6b2513456fe2229811da7eb67a444be7785f5323c6708b38d851d2b51e54d83",
urls = [
"https://github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.17")

# -- Load Dependencies ---------------------------------------------------------
load("gnmi_deps.bzl", "gnmi_deps")

gnmi_deps()

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

grpc_deps()

load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

grpc_extra_deps()
58 changes: 0 additions & 58 deletions gnmi_deps.bzl

This file was deleted.

25 changes: 16 additions & 9 deletions proto/collector/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# Supporting infrastructure for implementing and testing PINS.
#

load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@rules_proto_grpc_cpp//:defs.bzl", "cpp_grpc_library")
load("@rules_go//go:def.bzl", "go_library")
load("@rules_go//proto:def.bzl", "go_proto_library")

package(
default_visibility = ["//visibility:public"],
Expand All @@ -27,14 +29,19 @@ proto_library(
srcs = ["collector.proto"],
)

cc_proto_library(
name = "collector_cc_proto",
deps = [":collector_proto"],
cpp_grpc_library(
name = "collector_cc_grpc_proto",
protos = [":collector_proto"],
)

cc_grpc_library(
name = "collector_cc_grpc_proto",
srcs = [":collector_proto"],
grpc_only = True,
deps = [":collector_cc_proto"],
go_proto_library(
name = "collector_go_proto",
importpath = "github.com/openconfig/gnmi/proto/collector",
proto = ":collector_proto",
)

go_library(
name = "collector",
embed = [":collector_go_proto"],
importpath = "github.com/openconfig/gnmi/proto/collector",
)
23 changes: 8 additions & 15 deletions proto/gnmi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# Supporting infrastructure for implementing and testing PINS.
#

load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto_grpc_cpp//:defs.bzl", "cpp_grpc_library")
load("@rules_go//go:def.bzl", "go_library")
load("@rules_go//proto:def.bzl", "go_proto_library")

package(
default_visibility = ["//visibility:public"],
Expand All @@ -30,22 +30,15 @@ proto_library(
import_prefix = "github.com/openconfig/gnmi",
deps = [
"//proto/gnmi_ext:gnmi_ext_proto",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
"@protobuf//:any_proto",
"@protobuf//:descriptor_proto",
],
)

cc_proto_library(
name = "gnmi_cc_proto",
deps = [":gnmi_proto"],
)

cc_grpc_library(
cpp_grpc_library(
name = "gnmi_cc_grpc_proto",
srcs = [":gnmi_proto"],
generate_mocks = True,
grpc_only = True,
deps = [":gnmi_cc_proto"],
protos = [":gnmi_proto"],
deps = ["//proto/gnmi_ext:gnmi_ext_cc_proto"],
)

go_proto_library(
Expand Down
11 changes: 6 additions & 5 deletions proto/gnmi_ext/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
# Supporting infrastructure for implementing and testing PINS.
#

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_go//go:def.bzl", "go_library")
load("@rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto_grpc_cpp//:defs.bzl", "cpp_proto_library")

package(
default_visibility = ["//visibility:public"],
Expand All @@ -26,13 +27,13 @@ package(
proto_library(
name = "gnmi_ext_proto",
srcs = ["gnmi_ext.proto"],
deps = ["@com_google_protobuf//:duration_proto" ],
import_prefix = "github.com/openconfig/gnmi",
deps = ["@protobuf//:duration_proto"],
)

cc_proto_library(
cpp_proto_library(
name = "gnmi_ext_cc_proto",
deps = [":gnmi_ext_proto"],
protos = [":gnmi_ext_proto"],
)

go_proto_library(
Expand Down
29 changes: 26 additions & 3 deletions proto/target/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# Supporting infrastructure for implementing and testing PINS.
#

load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@rules_proto_grpc_cpp//:defs.bzl", "cpp_proto_library")
load("@rules_go//go:def.bzl", "go_library")
load("@rules_go//proto:def.bzl", "go_proto_library")

package(
default_visibility = ["//visibility:public"],
Expand All @@ -30,7 +32,28 @@ proto_library(
],
)

cc_proto_library(
cpp_proto_library(
name = "target_cc_proto",
deps = [":target_proto"],
protos = [":target_proto"],
deps = [
"//proto/gnmi:gnmi_cc_grpc_proto",
],
)

go_proto_library(
name = "target_go_proto",
importpath = "github.com/openconfig/gnmi/proto/target",
proto = ":target_proto",
deps = [
"//proto/gnmi:gnmi_go_proto",
],
)

go_library(
name = "target",
embed = [":target_go_proto"],
importpath = "github.com/openconfig/gnmi/proto/target",
deps = [
"//proto/gnmi",
],
)