Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

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:

  • Moved proto/MODULE.bazel, proto/WORKSPACE.bazel, proto/.bazelrc, proto/WORKSPACE.bzlmod, and proto/p4runtime_deps.bzl to the repository root.
  • Created a root BUILD.bazel file.
  • Updated proto_library targets in proto/BUILD.bazel to include strip_import_prefix = "/proto", ensuring import paths like p4/config/v1/... continue to work correctly.
  • Updated bazel/example/using-workspace/BUILD.bazel and bazel/example/using-bzlmod/BUILD.bazel to reference @com_github_p4lang_p4runtime//proto:p4info_cc_proto instead of the root package.
  • Updated bazel/example/using-workspace/WORKSPACE.bazel and bazel/example/using-bzlmod/MODULE.bazel to point local_repository/local_path_override to the repo root and removed the strip_prefix workaround.

Verified by building //proto/... and the example projects //bazel/example/....


PR created automatically by Jules for task 3243768557642822763 started by @smolkaj

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.
@google-labs-jules
Copy link
Contributor Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line

Copy link
Contributor Author

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")

Copy link
Member

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)

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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")

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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(
Copy link
Member

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.

Copy link
Contributor Author

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.
Copy link
Member

@smolkaj smolkaj left a 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?

@smolkaj smolkaj marked this pull request as ready for review December 24, 2025 05:39
@smolkaj smolkaj self-assigned this Dec 24, 2025
Copy link
Contributor

@matthewtlam matthewtlam left a 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")
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants