Skip to content

[bazel] Prepare p4c for BCR#5459

Open
prerak09 wants to merge 1 commit intop4lang:mainfrom
prerak09:bazel-bzlmod
Open

[bazel] Prepare p4c for BCR#5459
prerak09 wants to merge 1 commit intop4lang:mainfrom
prerak09:bazel-bzlmod

Conversation

@prerak09
Copy link

@prerak09 prerak09 commented Jan 4, 2026

This PR updates p4c’s Bazel setup so it works properly with Bazel bzlmod.

What is changed

  • Added a BUILD.bazel file inside the bazel/ folder
  • Updated Bazel load paths to use //bazel:... format
  • Updated example Bazel files to match the new paths

Why this change

Without this, p4c Bazel rules cannot be used correctly when bzlmod is enabled.
This change does not affect existing WORKSPACE based builds.

No functional code changes are included.

@fruffy fruffy added the infrastructure Topics related to code style and build and test infrastructure. label Jan 6, 2026
@fruffy
Copy link
Collaborator

fruffy commented Jan 7, 2026

The bazel formatting test fails

@fruffy fruffy requested a review from smolkaj January 7, 2026 19:34
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 modulo running the formatting script and minor comments. Thanks for the PR!

@@ -0,0 +1,3 @@
exports_files([
Copy link
Member

Choose a reason for hiding this comment

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

While we're at it, can we use bzl_library?

Example:

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

bzl_library(
    name = "defs",
    srcs = ["defs.bzl"],
    deps = [
        ":utils", # defs.bzl loads utils.bzl
        "//external_pkg:rules",
    ],
    visibility = ["//visibility:public"],
)

bzl_library(
    name = "utils",
    srcs = ["utils.bzl"],
)

@@ -0,0 +1,3 @@
exports_files([
"p4_library.bzl",
Copy link
Member

Choose a reason for hiding this comment

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

Don't we also need to declare our other .bzl files for flex and bison etc? Why does this even compile?

Copy link
Author

Choose a reason for hiding this comment

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

Agreed .
I will use bzl_library and declare the other bazel files ( flex , bison and others )

@smolkaj
Copy link
Member

smolkaj commented Jan 14, 2026

What's the status on this PR?

@smolkaj
Copy link
Member

smolkaj commented Feb 21, 2026

Are you still planing to submit this or shall we close it?

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

Labels

infrastructure Topics related to code style and build and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants