Skip to content

Commit 6cb7024

Browse files
Move Bazel workspace root to project root and align with standard conventions. (#573)
This also includes defining Bazel build targets in BUILD.bazel files in the same directories as the source files. We declare build target aliases with a deprecation notice, so users depending on P4Runtime should not have to update their BUILD rules but are nudged in the right direction. Fixes #571. Signed-off-by: smolkaj <smolkaj@google.com> Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent b607cab commit 6cb7024

13 files changed

Lines changed: 342 additions & 107 deletions

File tree

File renamed without changes.

BUILD.bazel

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
load("@bazel_skylib//rules:build_test.bzl", "build_test")
2+
load("@rules_license//rules:license.bzl", "license")
3+
4+
package(
5+
default_applicable_licenses = [":license"],
6+
default_visibility = ["//visibility:public"],
7+
)
8+
9+
license(
10+
name = "license",
11+
license_kinds = ["@rules_license//licenses/spdx:Apache-2.0"],
12+
license_text = "LICENSE",
13+
)
14+
15+
exports_files([
16+
"LICENSE",
17+
"p4runtime_deps.bzl",
18+
])
19+
20+
# -- Aliases for backward compatibility --------------------------------------
21+
# TODO(https://github.com/p4lang/p4runtime/issues/576): Remove in 2.0.
22+
23+
alias(
24+
name = "p4types_proto",
25+
actual = "//proto/p4/config/v1:p4types_proto",
26+
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4types_proto instead.",
27+
)
28+
29+
alias(
30+
name = "p4info_proto",
31+
actual = "//proto/p4/config/v1:p4info_proto",
32+
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_proto instead.",
33+
)
34+
35+
alias(
36+
name = "p4data_proto",
37+
actual = "//proto/p4/v1:p4data_proto",
38+
deprecation = "Please use @p4runtime//proto/p4/v1:p4data_proto instead.",
39+
)
40+
41+
alias(
42+
name = "p4runtime_proto",
43+
actual = "//proto/p4/v1:p4runtime_proto",
44+
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_proto instead.",
45+
)
46+
47+
alias(
48+
name = "p4types_cc_proto",
49+
actual = "//proto/p4/config/v1:p4types_cc_proto",
50+
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4types_cc_proto instead.",
51+
)
52+
53+
alias(
54+
name = "p4info_cc_proto",
55+
actual = "//proto/p4/config/v1:p4info_cc_proto",
56+
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_cc_proto instead.",
57+
)
58+
59+
alias(
60+
name = "p4data_cc_proto",
61+
actual = "//proto/p4/v1:p4data_cc_proto",
62+
deprecation = "Please use @p4runtime//proto/p4/v1:p4data_cc_proto instead.",
63+
)
64+
65+
alias(
66+
name = "p4runtime_cc_proto",
67+
actual = "//proto/p4/v1:p4runtime_cc_proto",
68+
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_cc_proto instead.",
69+
)
70+
71+
alias(
72+
name = "p4runtime_cc_grpc",
73+
actual = "//proto/p4/v1:p4runtime_cc_grpc",
74+
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_cc_grpc instead.",
75+
)
76+
77+
alias(
78+
name = "p4types_py_proto",
79+
actual = "//proto/p4/config/v1:p4types_py_proto",
80+
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4types_py_proto instead.",
81+
)
82+
83+
alias(
84+
name = "p4info_py_proto",
85+
actual = "//proto/p4/config/v1:p4info_py_proto",
86+
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_py_proto instead.",
87+
)
88+
89+
alias(
90+
name = "p4data_py_proto",
91+
actual = "//proto/p4/v1:p4data_py_proto",
92+
deprecation = "Please use @p4runtime//proto/p4/v1:p4data_py_proto instead.",
93+
)
94+
95+
alias(
96+
name = "p4runtime_py_proto",
97+
actual = "//proto/p4/v1:p4runtime_py_proto",
98+
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_py_proto instead.",
99+
)
100+
101+
alias(
102+
name = "p4runtime_py_grpc",
103+
actual = "//proto/p4/v1:p4runtime_py_grpc",
104+
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_py_grpc instead.",
105+
)
106+
107+
alias(
108+
name = "p4info_go_proto",
109+
actual = "//proto/p4/config/v1:p4info_go_proto",
110+
deprecation = "Please use @p4runtime//proto/p4/config/v1:p4info_go_proto instead.",
111+
)
112+
113+
alias(
114+
name = "p4runtime_go_proto",
115+
actual = "//proto/p4/v1:p4runtime_go_proto",
116+
deprecation = "Please use @p4runtime//proto/p4/v1:p4runtime_go_proto instead.",
117+
)
File renamed without changes.
File renamed without changes.
File renamed without changes.

bazel/example/using-bzlmod/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cc_binary(
22
name = "hello_p4runtime",
33
srcs = ["hello_p4runtime.cc"],
44
deps = [
5-
"@com_github_p4lang_p4runtime//:p4info_cc_proto",
5+
"@com_github_p4lang_p4runtime//proto/p4/config/v1:p4info_cc_proto",
66
"@com_google_protobuf//:protobuf",
77
]
88
)

bazel/example/using-bzlmod/MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ bazel_dep(
77
# of `local_repository` to load p4runtime.
88
local_path_override(
99
module_name = "p4runtime",
10-
path = "../../../proto",
10+
path = "../../..",
1111
)
1212

1313
# git_override(
1414
# module_name = "p4runtime",
15-
# strip_prefix = "p4runtime-1.4.1/proto",
15+
# strip_prefix = "p4runtime-1.4.1",
1616
# urls = ["https://github.com/p4lang/p4runtime/archive/v1.4.1.tar.gz"],
1717
# # sha256 = "<insert hash value here>",
1818
# )

bazel/example/using-workspace/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cc_binary(
22
name = "hello_p4runtime",
33
srcs = ["hello_p4runtime.cc"],
44
deps = [
5-
"@com_github_p4lang_p4runtime//:p4info_cc_proto",
5+
"@com_github_p4lang_p4runtime//proto/p4/config/v1:p4info_cc_proto",
66
"@com_google_protobuf//:protobuf",
77
]
88
)

bazel/example/using-workspace/WORKSPACE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
55
# of `local_repository` to load p4runtime.
66
local_repository(
77
name = "com_github_p4lang_p4runtime",
8-
path = "../../../proto",
8+
path = "../../..",
99
)
1010
# http_archive(
1111
# name = "com_github_p4lang_p4runtime",
1212
# urls = ["https://github.com/p4lang/p4runtime/archive/v1.4.1.tar.gz"],
13-
# strip_prefix = "p4runtime-1.4.1/proto",
13+
# strip_prefix = "p4runtime-1.4.1",
1414
# # sha256 = "<insert hash value here>",
1515
# )
1616

0 commit comments

Comments
 (0)