-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Bzlmod (fixes #515).
Specifically, this allows P4Runtime users to use Bzlmod. I am not yet enabling Blzmod for P4Runtime itself. I plan to do so in a follow up PR. Signed-off-by: Steffen Smolka <[email protected]>
- Loading branch information
Showing
12 changed files
with
826 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Use Bzlmod instead of WORKSPACE. | ||
common --enable_bzlmod | ||
common --noenable_workspace | ||
|
||
# C++14 required for recent gRPC versions | ||
build --cxxopt='-std=c++14' |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
bazel_dep( | ||
name = "p4runtime", | ||
repo_name = "com_github_p4lang_p4runtime", | ||
) | ||
|
||
# In your own project, you will likely want to use `http_archive` instead | ||
# of `local_repository` to load p4runtime. | ||
local_path_override( | ||
module_name = "p4runtime", | ||
path = "../../../proto", | ||
) | ||
|
||
# git_override( | ||
# module_name = "p4runtime", | ||
# strip_prefix = "p4runtime-1.4.1/proto", | ||
# urls = ["https://github.com/p4lang/p4runtime/archive/v1.4.1.tar.gz"], | ||
# # sha256 = "<insert hash value here>", | ||
# ) | ||
|
||
bazel_dep( | ||
name = "protobuf", | ||
version = "29.1", | ||
repo_name = "com_google_protobuf", | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cc_binary( | ||
name = "hello_p4runtime", | ||
srcs = ["hello_p4runtime.cc"], | ||
deps = [ | ||
"@com_github_p4lang_p4runtime//:p4info_cc_proto", | ||
"@com_google_protobuf//:protobuf", | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <iostream> | ||
|
||
#include "google/protobuf/text_format.h" | ||
#include "p4/config/v1/p4info.pb.h" | ||
|
||
using ::google::protobuf::TextFormat; | ||
using ::p4::config::v1::P4Info; | ||
|
||
int main() { | ||
P4Info p4info; | ||
TextFormat::ParseFromString(R"PROTO( | ||
tables { | ||
preamble { | ||
id: 10 | ||
name: "Hello, P4Runtime!" | ||
} | ||
} | ||
)PROTO", &p4info); | ||
p4info.mutable_tables()->at(0).mutable_preamble()->set_id(42); | ||
std::cout << p4info.DebugString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module( | ||
name = "p4runtime", | ||
repo_name = "com_github_p4lang_p4runtime", | ||
) | ||
|
||
bazel_dep(name = "bazel_skylib", version = "1.7.1") | ||
bazel_dep( | ||
name = "googleapis", | ||
version = "0.0.0-20240819-fe8ba054a", | ||
repo_name = "com_google_googleapis", | ||
) | ||
|
||
switched_rules = use_extension("@com_google_googleapis//:extensions.bzl", "switched_rules") | ||
switched_rules.use_languages( | ||
cc = True, | ||
go = True, | ||
grpc = True, | ||
python = True, | ||
) | ||
use_repo(switched_rules, "com_google_googleapis_imports") | ||
|
||
bazel_dep(name = "grpc", version = "1.68.0", repo_name = "com_github_grpc_grpc") | ||
bazel_dep( | ||
name = "protobuf", | ||
version = "29.1", | ||
repo_name = "com_google_protobuf", | ||
) | ||
bazel_dep(name = "rules_license", version = "1.0.0") | ||
bazel_dep(name = "rules_proto", version = "7.0.2") | ||
bazel_dep( | ||
name = "rules_go", | ||
version = "0.50.1", | ||
repo_name = "io_bazel_rules_go", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# https://bazel.build/external/migration#workspace.bzlmod | ||
# | ||
# This file is intentionally empty. When bzlmod is enabled and this | ||
# file exists, the contents of WORKSPACE.bazel is ignored. This prevents | ||
# bzlmod builds from unintentionally depending on the WORKSPACE.bazel file. |