-
Notifications
You must be signed in to change notification settings - Fork 99
Move Bazel workspace root to project root #573
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
base: main
Are you sure you want to change the base?
Conversation
Moved MODULE.bazel, WORKSPACE.bazel, .bazelrc, WORKSPACE.bzlmod, and p4runtime_deps.bzl from proto/ to the repository root. Added strip_import_prefix = "/proto" to proto_library targets in proto/BUILD.bazel to maintain correct import paths. Updated bazel/example/using-workspace and bazel/example/using-bzlmod to depend on //proto:p4info_cc_proto and point to the repository root instead of proto/. Created a root BUILD.bazel file exporting LICENSE and p4runtime_deps.bzl. Fixes #571.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
- Moved Bazel workspace files (MODULE.bazel, WORKSPACE.bazel, .bazelrc, etc.) from `proto/` to the repository root. - Refactored `proto/BUILD.bazel` by splitting targets into colocated BUILD files in `proto/p4/config/v1/BUILD.bazel` and `proto/p4/v1/BUILD.bazel`. - Added `strip_import_prefix = "/proto"` to proto_library targets to maintain import compatibility. - Added aliases in `proto/BUILD.bazel` for backward compatibility. - Updated example projects to use the new canonical targets and workspace root. Fixes #571.
- Moved Bazel workspace files (MODULE.bazel, WORKSPACE.bazel, .bazelrc, etc.) from `proto/` to the repository root. - Refactored `proto/BUILD.bazel` by splitting targets into colocated BUILD files in `proto/p4/config/v1/BUILD.bazel` and `proto/p4/v1/BUILD.bazel`. - Added `strip_import_prefix = "/proto"` to proto_library targets. - Added aliases in the root `BUILD.bazel` to maintain backward compatibility for users who update their workspace root. - Added aliases in `proto/BUILD.bazel` to maintain backward compatibility for users who do not update their workspace root (though strictly speaking the paths are different). - Updated example projects to use the new canonical targets and workspace root. Fixes #571.
BUILD.bazel
Outdated
|
|
||
| # Aliases for backward compatibility with the old workspace structure | ||
| # where proto/ was the root. | ||
|
|
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.
Add:
TODO(https://github.com/p4lang/p4runtime/issues/576): Remove in 2.0.
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.
Done.
BUILD.bazel
Outdated
|
|
||
| # Aliases for backward compatibility with the old workspace structure | ||
| # where proto/ was the root. | ||
|
|
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.
Remove empty line
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.
Done.
| 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") | ||
|
|
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.
Remove empty line (here and a few more times below)
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.
Done.
| # cc_grpc_library. Make proto folder the Bazel root folder as a workaround. | ||
| # strip_import_prefix = "proto", | ||
| ) | ||
| # Aliases for backward compatibility |
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.
Add:
TODO(https://github.com/p4lang/p4runtime/issues/576): Remove in 2.0.
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.
Done.
| 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") | ||
|
|
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.
Please remove empty line here and a few more times below.
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.
Done.
proto/BUILD.bazel
Outdated
| alias(name = "p4runtime_cc_grpc", actual = "//proto/p4/v1:p4runtime_cc_grpc") | ||
| alias(name = "p4runtime_py_grpc", actual = "//proto/p4/v1:p4runtime_py_grpc") | ||
|
|
||
| build_test( |
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.
Tests should live adjacent to the source files they test. Please break up into two tests in proto/p4/v1 and proto/p4/config/v1.
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.
Done. Split into //proto/p4/config/v1:proto_build_test and //proto/p4/v1:proto_build_test. Updated the root alias //:proto_build_test to be a test_suite pointing to both.
- Moved Bazel workspace files (MODULE.bazel, WORKSPACE.bazel, .bazelrc, etc.) from `proto/` to the repository root. - Refactored `proto/BUILD.bazel` by splitting targets into colocated BUILD files in `proto/p4/config/v1/BUILD.bazel` and `proto/p4/v1/BUILD.bazel`. - Added `strip_import_prefix = "/proto"` to proto_library targets. - Added aliases in the root `BUILD.bazel` to maintain backward compatibility for users who update their workspace root. - Added aliases in `proto/BUILD.bazel` to maintain backward compatibility for users who do not update their workspace root. - Added removal TODOs for aliases pointing to issue #576. - Split `proto_build_test` into per-package build tests and aggregated them in a root `test_suite`. - Updated example projects to use the new canonical targets and workspace root. Fixes #571.
smolkaj
left a comment
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. @matthewtlam, would you also be able to review?
matthewtlam
left a comment
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 overall. Thanks Jules!
| 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") |
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.
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
This change moves the Bazel workspace root from the
proto/directory to the repository root, resolving issue #571. This aligns the project structure with standard Bazel practices and simplifies usage for consumers.Changes:
proto/MODULE.bazel,proto/WORKSPACE.bazel,proto/.bazelrc,proto/WORKSPACE.bzlmod, andproto/p4runtime_deps.bzlto the repository root.BUILD.bazelfile.proto_librarytargets inproto/BUILD.bazelto includestrip_import_prefix = "/proto", ensuring import paths likep4/config/v1/...continue to work correctly.bazel/example/using-workspace/BUILD.bazelandbazel/example/using-bzlmod/BUILD.bazelto reference@com_github_p4lang_p4runtime//proto:p4info_cc_protoinstead of the root package.bazel/example/using-workspace/WORKSPACE.bazelandbazel/example/using-bzlmod/MODULE.bazelto pointlocal_repository/local_path_overrideto the repo root and removed thestrip_prefixworkaround.Verified by building
//proto/...and the example projects//bazel/example/....PR created automatically by Jules for task 3243768557642822763 started by @smolkaj