-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update P4Runtime and use FetchContent instead of a submodule. #4082
Conversation
3d206ee
to
78a2c7b
Compare
78a2c7b
to
8a62174
Compare
@smolkaj I would like to make the include path of the generated Protobuf files consistent with the rest of the compiler includes, i.e.
I can do this in CMake, but I am unsure how to do this with Bazel. Is this possible? If not, I will just stick with the original style. |
Very likely possible, but I need a bit more context. In Bazel, include paths are by default relative to your
EDIT: And then there is a well-know limitation related to this, reported by yours truly: grpc/grpc#33377 |
Well, essentially I would like to control the place the proto files are generated to. With that I should also be able to manipulate the include path. This seems possible for project-local declarations, for example here: https://github.com/p4lang/p4c/blob/main/BUILD.bazel#L283 However, I do not know how to do this for a dependency and its generated proto files, for example P4Runtime.
Hmm, this might be a little bit of a blocker. |
P4Runtime does not generate .proto files at compile time. All .proto files are static, just like other source files (.h/.cc). And so the static path becomes your include path, unless you use some of the options I described above. One think you could do is use a genrule that moves the .proto file from one place to another, which would be similar to the example you pointed to (https://github.com/p4lang/p4c/blob/main/BUILD.bazel#L283) but using |
At least with CMake we call protoc at some point and it serializes the files into the folder we specify. This lets us precisely control the output directory and with that we can also make sure that include path is consistent with the rest of the compiler includes. I am guessing Bazel, or the Bazel Protobuf recipe does that for you? I reverted the control-plane changes, will give this another shot once I understand the Bazel build structure a little bit better. |
Thanks for clarifying, I'm starting to understand better.
Ah, okay...you are talking about the C++ API that is generated by protoc based on the .proto files? In Bazel, the BUILD rule for generating the C++ APIs is
Perhaps confusingly, while
Then you should be able to say
in your C++ files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but to qualify my approval, I mainly care that we don't break the build, and keep things manageable for us. In general using FetchContent in cmake seems like a good direction to move. Any breakages in build I expect CI to catch, or my monthly builds.
After taking a closer look, it should be somewhat straightforward to achieve: Currently:
I think the following should work:
Then in
to
|
Great, I tried the first step but could not figure out how to resolve the errors afterwards. |
Hmm, I am running into:
Replaced the colon with a slash and got
|
You have the colon in the wrong place:
EDIT: The syntax is `@<worskpace_name>//<path_to_build_file_relative_to_workspace_root>:<target_declared_in_build_file> |
I tried a bunch of things but I could not figure out the right syntax, maybe you can tell from the error what to do? If not, it's not that important, I will just revert to the previous include behavior. |
Since we are changing the location of some .proto files, the include paths within the .proto files themselves are now breaking... |
I will just revert and merge. |
This reverts commit 357898e.
Use FetchContent to pull in P4Runtime and remove the submodule. While doing this we also update P4Runtime to the latest version.
Also clean up some of the DPDK paths, the generated Protobuf files were polluting the top-level build folder.