Skip to content
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
File renamed without changes.
47 changes: 47 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_license//rules:license.bzl", "license")

package(
default_visibility = ["//visibility:public"],
default_applicable_licenses = [":license"],
)

license(
name = "license",
license_kinds = ["@rules_license//licenses/spdx:Apache-2.0"],
license_text = "LICENSE",
)

exports_files(["LICENSE", "p4runtime_deps.bzl"])

# Aliases for backward compatibility with the old workspace structure
# where proto/ was the root.
# TODO(https://github.com/p4lang/p4runtime/issues/576): Remove in 2.0.
alias(name = "p4types_proto", actual = "//proto/p4/config/v1:p4types_proto")
alias(name = "p4info_proto", actual = "//proto/p4/config/v1:p4info_proto")
alias(name = "p4data_proto", actual = "//proto/p4/v1:p4data_proto")
alias(name = "p4runtime_proto", actual = "//proto/p4/v1:p4runtime_proto")

Copy link
Member

Choose a reason for hiding this comment

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

Remove empty line (here and a few more times below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

alias(name = "p4types_cc_proto", actual = "//proto/p4/config/v1:p4types_cc_proto")
alias(name = "p4info_cc_proto", actual = "//proto/p4/config/v1:p4info_cc_proto")
alias(name = "p4data_cc_proto", actual = "//proto/p4/v1:p4data_cc_proto")
alias(name = "p4runtime_cc_proto", actual = "//proto/p4/v1:p4runtime_cc_proto")

alias(name = "p4types_py_proto", actual = "//proto/p4/config/v1:p4types_py_proto")
alias(name = "p4info_py_proto", actual = "//proto/p4/config/v1:p4info_py_proto")
alias(name = "p4data_py_proto", actual = "//proto/p4/v1:p4data_py_proto")
alias(name = "p4runtime_py_proto", actual = "//proto/p4/v1:p4runtime_py_proto")

alias(name = "p4info_go_proto", actual = "//proto/p4/config/v1:p4info_go_proto")
alias(name = "p4runtime_go_proto", actual = "//proto/p4/v1:p4runtime_go_proto")

alias(name = "p4runtime_cc_grpc", actual = "//proto/p4/v1:p4runtime_cc_grpc")
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we want to group these with the other cc/py files. Also maybe we want a comment to specify that each section corresponds to a particular language? Non-blocking comment

Any thoughts @smolkaj

alias(name = "p4runtime_py_grpc", actual = "//proto/p4/v1:p4runtime_py_grpc")

test_suite(
name = "proto_build_test",
tests = [
"//proto/p4/config/v1:proto_build_test",
"//proto/p4/v1:proto_build_test",
],
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bazel/example/using-bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cc_binary(
name = "hello_p4runtime",
srcs = ["hello_p4runtime.cc"],
deps = [
"@com_github_p4lang_p4runtime//:p4info_cc_proto",
"@com_github_p4lang_p4runtime//proto/p4/config/v1:p4info_cc_proto",
"@com_google_protobuf//:protobuf",
]
)
4 changes: 2 additions & 2 deletions bazel/example/using-bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ bazel_dep(
# of `local_repository` to load p4runtime.
local_path_override(
module_name = "p4runtime",
path = "../../../proto",
path = "../../..",
)

# git_override(
# module_name = "p4runtime",
# strip_prefix = "p4runtime-1.4.1/proto",
# strip_prefix = "p4runtime-1.4.1",
# urls = ["https://github.com/p4lang/p4runtime/archive/v1.4.1.tar.gz"],
# # sha256 = "<insert hash value here>",
# )
Expand Down
2 changes: 1 addition & 1 deletion bazel/example/using-workspace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cc_binary(
name = "hello_p4runtime",
srcs = ["hello_p4runtime.cc"],
deps = [
"@com_github_p4lang_p4runtime//:p4info_cc_proto",
"@com_github_p4lang_p4runtime//proto/p4/config/v1:p4info_cc_proto",
"@com_google_protobuf//:protobuf",
]
)
4 changes: 2 additions & 2 deletions bazel/example/using-workspace/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# of `local_repository` to load p4runtime.
local_repository(
name = "com_github_p4lang_p4runtime",
path = "../../../proto",
path = "../../..",
)
# http_archive(
# name = "com_github_p4lang_p4runtime",
# urls = ["https://github.com/p4lang/p4runtime/archive/v1.4.1.tar.gz"],
# strip_prefix = "p4runtime-1.4.1/proto",
# strip_prefix = "p4runtime-1.4.1",
# # sha256 = "<insert hash value here>",
# )

Expand Down
File renamed without changes.
150 changes: 18 additions & 132 deletions proto/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@

load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_license//rules:license.bzl", "license")
load("@rules_proto//proto:defs.bzl", "proto_library")

package(
default_visibility = ["//visibility:public"],
Expand All @@ -19,133 +13,25 @@ license(

exports_files(["LICENSE"])

proto_library(
name = "p4types_proto",
srcs = ["p4/config/v1/p4types.proto"],
# TODO(github.com/grpc/grpc/issues/20675): strip_import_prefix breaks
# cc_grpc_library. Make proto folder the Bazel root folder as a workaround.
# strip_import_prefix = "proto",
)

proto_library(
name = "p4data_proto",
srcs = ["p4/v1/p4data.proto"],
# TODO(github.com/grpc/grpc/issues/20675): strip_import_prefix breaks
# cc_grpc_library. Make proto folder the Bazel root folder as a workaround.
# strip_import_prefix = "proto",
)

proto_library(
name = "p4info_proto",
srcs = ["p4/config/v1/p4info.proto"],
deps = [
":p4types_proto",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
],
# TODO(github.com/grpc/grpc/issues/20675): strip_import_prefix breaks
# cc_grpc_library. Make proto folder the Bazel root folder as a workaround.
# strip_import_prefix = "proto",
)

proto_library(
name = "p4runtime_proto",
srcs = ["p4/v1/p4runtime.proto"],
deps = [
":p4data_proto",
":p4info_proto",
"@com_google_googleapis//google/rpc:status_proto",
"@com_google_protobuf//:any_proto",
],
# TODO(github.com/grpc/grpc/issues/20675): strip_import_prefix brakes
# cc_grpc_library. Make proto folder the Bazel root folder as a workaround.
# strip_import_prefix = "proto",
)

cc_proto_library(
name = "p4types_cc_proto",
deps = [":p4types_proto"],
)

cc_proto_library(
name = "p4info_cc_proto",
deps = [":p4info_proto"],
)

cc_proto_library(
name = "p4data_cc_proto",
deps = [":p4data_proto"],
)

cc_proto_library(
name = "p4runtime_cc_proto",
deps = [":p4runtime_proto"],
)

py_proto_library(
name = "p4types_py_proto",
deps = [":p4types_proto"],
)

py_proto_library(
name = "p4info_py_proto",
deps = [":p4info_proto"],
)
# Aliases for backward compatibility
Copy link
Member

Choose a reason for hiding this comment

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

Add:

TODO(https://github.com/p4lang/p4runtime/issues/576): Remove in 2.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

# TODO(https://github.com/p4lang/p4runtime/issues/576): Remove in 2.0.
alias(name = "p4types_proto", actual = "//proto/p4/config/v1:p4types_proto")
alias(name = "p4info_proto", actual = "//proto/p4/config/v1:p4info_proto")
alias(name = "p4data_proto", actual = "//proto/p4/v1:p4data_proto")
alias(name = "p4runtime_proto", actual = "//proto/p4/v1:p4runtime_proto")

Copy link
Member

Choose a reason for hiding this comment

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

Please remove empty line here and a few more times below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

py_proto_library(
name = "p4data_py_proto",
deps = [":p4data_proto"],
)
alias(name = "p4types_cc_proto", actual = "//proto/p4/config/v1:p4types_cc_proto")
alias(name = "p4info_cc_proto", actual = "//proto/p4/config/v1:p4info_cc_proto")
alias(name = "p4data_cc_proto", actual = "//proto/p4/v1:p4data_cc_proto")
alias(name = "p4runtime_cc_proto", actual = "//proto/p4/v1:p4runtime_cc_proto")

py_proto_library(
name = "p4runtime_py_proto",
deps = [":p4runtime_proto"],
)
alias(name = "p4types_py_proto", actual = "//proto/p4/config/v1:p4types_py_proto")
alias(name = "p4info_py_proto", actual = "//proto/p4/config/v1:p4info_py_proto")
alias(name = "p4data_py_proto", actual = "//proto/p4/v1:p4data_py_proto")
alias(name = "p4runtime_py_proto", actual = "//proto/p4/v1:p4runtime_py_proto")

go_proto_library(
name = "p4info_go_proto",
importpath = "github.com/p4lang/p4runtime/go/p4/config/v1",
protos = [
":p4info_proto",
":p4types_proto",
],
)
alias(name = "p4info_go_proto", actual = "//proto/p4/config/v1:p4info_go_proto")
alias(name = "p4runtime_go_proto", actual = "//proto/p4/v1:p4runtime_go_proto")

go_proto_library(
name = "p4runtime_go_proto",
importpath = "github.com/p4lang/p4runtime/go/p4/v1",
protos = [
":p4data_proto",
":p4runtime_proto",
],
deps = [
":p4info_go_proto",
"@com_google_googleapis//google/rpc:status_go_proto",
],
)

cc_grpc_library(
name = "p4runtime_cc_grpc",
srcs = [":p4runtime_proto"],
generate_mocks = True,
grpc_only = True,
deps = [":p4runtime_cc_proto"],
)

py_grpc_library(
name = "p4runtime_py_grpc",
srcs = [":p4runtime_proto"],
deps = [":p4runtime_py_proto"],
)

build_test(
name = "proto_build_test",
targets = [
":p4data_proto",
":p4info_proto",
":p4runtime_cc_grpc",
":p4runtime_proto",
":p4runtime_py_grpc",
":p4types_proto",
],
)
alias(name = "p4runtime_cc_grpc", actual = "//proto/p4/v1:p4runtime_cc_grpc")
alias(name = "p4runtime_py_grpc", actual = "//proto/p4/v1:p4runtime_py_grpc")
67 changes: 67 additions & 0 deletions proto/p4/config/v1/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_proto_library")
load("@bazel_skylib//rules:build_test.bzl", "build_test")

package(
default_visibility = ["//visibility:public"],
)

proto_library(
name = "p4types_proto",
srcs = ["p4types.proto"],
strip_import_prefix = "/proto",
)

proto_library(
name = "p4info_proto",
srcs = ["p4info.proto"],
deps = [
":p4types_proto",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
],
strip_import_prefix = "/proto",
)

cc_proto_library(
name = "p4types_cc_proto",
deps = [":p4types_proto"],
)

cc_proto_library(
name = "p4info_cc_proto",
deps = [":p4info_proto"],
)

py_proto_library(
name = "p4types_py_proto",
deps = [":p4types_proto"],
)

py_proto_library(
name = "p4info_py_proto",
deps = [":p4info_proto"],
)

go_proto_library(
name = "p4info_go_proto",
importpath = "github.com/p4lang/p4runtime/go/p4/config/v1",
protos = [
":p4info_proto",
":p4types_proto",
],
)

build_test(
name = "proto_build_test",
targets = [
":p4info_proto",
":p4types_proto",
":p4types_cc_proto",
":p4info_cc_proto",
":p4types_py_proto",
":p4info_py_proto",
":p4info_go_proto",
],
)
Loading