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

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

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 --------------------------------------
# TODO(https://github.com/p4lang/p4runtime/issues/576): Remove in 2.0.

alias(
name = "p4types_proto",
actual = "//proto/p4/config/v1:p4types_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4types_proto instead.",
)

alias(
name = "p4info_proto",
actual = "//proto/p4/config/v1:p4info_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_proto instead.",
)

alias(
name = "p4data_proto",
actual = "//proto/p4/v1:p4data_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4data_proto instead.",
)

alias(
name = "p4runtime_proto",
actual = "//proto/p4/v1:p4runtime_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_proto instead.",
)

alias(
name = "p4types_cc_proto",
actual = "//proto/p4/config/v1:p4types_cc_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4types_cc_proto instead.",
)

alias(
name = "p4info_cc_proto",
actual = "//proto/p4/config/v1:p4info_cc_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_cc_proto instead.",
)

alias(
name = "p4data_cc_proto",
actual = "//proto/p4/v1:p4data_cc_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4data_cc_proto instead.",
)

alias(
name = "p4runtime_cc_proto",
actual = "//proto/p4/v1:p4runtime_cc_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_cc_proto instead.",
)

alias(
name = "p4runtime_cc_grpc",
actual = "//proto/p4/v1:p4runtime_cc_grpc",
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_cc_grpc instead.",
)

alias(
name = "p4types_py_proto",
actual = "//proto/p4/config/v1:p4types_py_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4types_py_proto instead.",
)

alias(
name = "p4info_py_proto",
actual = "//proto/p4/config/v1:p4info_py_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_py_proto instead.",
)

alias(
name = "p4data_py_proto",
actual = "//proto/p4/v1:p4data_py_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4data_py_proto instead.",
)

alias(
name = "p4runtime_py_proto",
actual = "//proto/p4/v1:p4runtime_py_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_py_proto instead.",
)

alias(
name = "p4runtime_py_grpc",
actual = "//proto/p4/v1:p4runtime_py_grpc",
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_py_grpc instead.",
)

alias(
name = "p4info_go_proto",
actual = "//proto/p4/config/v1:p4info_go_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_go_proto instead.",
)

alias(
name = "p4runtime_go_proto",
actual = "//proto/p4/v1:p4runtime_go_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_go_proto instead.",
)
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.
164 changes: 63 additions & 101 deletions proto/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@

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"],
default_applicable_licenses = [":license"],
default_visibility = ["//visibility:public"],
)

license(
Expand All @@ -19,133 +13,101 @@ license(

exports_files(["LICENSE"])

proto_library(
# -- Aliases for backward compatibility --------------------------------------
# TODO(https://github.com/p4lang/p4runtime/issues/576): Remove in 2.0.

alias(
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",
actual = "//proto/p4/config/v1:p4types_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4types_proto instead.",
)

alias(
name = "p4info_proto",
actual = "//proto/p4/config/v1:p4info_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_proto instead.",
)

proto_library(
alias(
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",
actual = "//proto/p4/v1:p4data_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4data_proto instead.",
)

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(
alias(
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(
actual = "//proto/p4/v1:p4runtime_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_proto instead.",
)

alias(
name = "p4types_cc_proto",
deps = [":p4types_proto"],
actual = "//proto/p4/config/v1:p4types_cc_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4types_cc_proto instead.",
)

cc_proto_library(
alias(
name = "p4info_cc_proto",
deps = [":p4info_proto"],
actual = "//proto/p4/config/v1:p4info_cc_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_cc_proto instead.",
)

cc_proto_library(
alias(
name = "p4data_cc_proto",
deps = [":p4data_proto"],
actual = "//proto/p4/v1:p4data_cc_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4data_cc_proto instead.",
)

cc_proto_library(
alias(
name = "p4runtime_cc_proto",
deps = [":p4runtime_proto"],
actual = "//proto/p4/v1:p4runtime_cc_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_cc_proto instead.",
)

py_proto_library(
alias(
name = "p4runtime_cc_grpc",
actual = "//proto/p4/v1:p4runtime_cc_grpc",
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_cc_grpc instead.",
)

alias(
name = "p4types_py_proto",
deps = [":p4types_proto"],
actual = "//proto/p4/config/v1:p4types_py_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4types_py_proto instead.",
)

py_proto_library(
alias(
name = "p4info_py_proto",
deps = [":p4info_proto"],
actual = "//proto/p4/config/v1:p4info_py_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_py_proto instead.",
)

py_proto_library(
alias(
name = "p4data_py_proto",
deps = [":p4data_proto"],
actual = "//proto/p4/v1:p4data_py_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4data_py_proto instead.",
)

py_proto_library(
alias(
name = "p4runtime_py_proto",
deps = [":p4runtime_proto"],
actual = "//proto/p4/v1:p4runtime_py_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_py_proto instead.",
)

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

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"],
alias(
name = "p4info_go_proto",
actual = "//proto/p4/config/v1:p4info_go_proto",
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_go_proto instead.",
)

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_go_proto",
actual = "//proto/p4/v1:p4runtime_go_proto",
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_go_proto instead.",
)
Loading