Skip to content

Add Bazel 8.5.0 build support for simple_switch_grpc + CI workflow#1354

Open
kunal9812 wants to merge 2 commits intop4lang:mainfrom
kunal9812:gsoc-2026-bazel-support
Open

Add Bazel 8.5.0 build support for simple_switch_grpc + CI workflow#1354
kunal9812 wants to merge 2 commits intop4lang:mainfrom
kunal9812:gsoc-2026-bazel-support

Conversation

@kunal9812
Copy link
Copy Markdown

Summary

This PR adds Bazel 8.5.0 build support for simple_switch_grpc as part of
the GSoC 2026 qualification task for Project 1.1: BMv2 Packet Trace Support.

What This PR Does

  • Adds MODULE.bazel with bzlmod dependencies (protobuf 29.1, grpc 1.71,
    boost, jsoncpp, fmt, googletest)
  • Adds WORKSPACE.bzlmod to enable Bazel bzlmod mode
  • Adds BUILD file at root for bmv2_core library
  • Adds BUILD file for targets/simple_switch_grpc
  • Vendors PI library headers/sources into third_party/PI
  • Adds .github/workflows/ci-bazel.yml — builds and tests via Bazel

Verification

  • bazelisk build //targets/simple_switch_grpc:simple_switch_grpc passes
  • bazelisk test //targets/simple_switch_grpc:simple_switch_grpc_test — 23/26 pass (3 gNMI/multicast tests require a running network service)

Notes

  • Built and tested on macOS M1 with Bazel 8.5.0 (via bazelisk + .bazelversion)
  • The 3 failing tests (gNMI.PortOperStatusUpdates, gNMI.PortCounters, Clone.SingletonAndMulticast) require a live gNMI/multicast environment and fail the same way on the original codebase

Related

GSoC 2026 Project 1.1 qualification task.
Reference repos: p4lang/p4runtime (Bazel structure), p4lang/p4c (CI workflow).

- Add MODULE.bazel with bzlmod dependencies (protobuf, grpc, boost,
  jsoncpp, fmt, googletest)
- Add WORKSPACE.bzlmod to enable bzlmod mode
- Add BUILD files for bmv2_core and simple_switch_grpc targets
- Vendor PI library headers and sources into third_party/PI
- Vendor GMP and jsoncpp into third_party/
- Add pre-generated protobuf/gRPC sources for services/
- Add GitHub Actions CI workflow (.github/workflows/ci-bazel.yml)
- Fix fmt::MemoryWriter compatibility with modern fmt versions
- Fix find_lowest_bit template specialization for macOS ARM64

Build verified: bazelisk build //targets/simple_switch_grpc:simple_switch_grpc
Tests: 23/26 pass (3 gNMI/multicast tests require network environment)
CMake build pre-existing failure confirmed unrelated to this PR

GSoC 2026 qualification task for Project 1.1: BMv2 Packet Trace Support

Signed-off-by: Kunal Yadav <kunalyadav49101@gmail.com>
@kunal9812 kunal9812 force-pushed the gsoc-2026-bazel-support branch from 970d88a to 88e0819 Compare March 15, 2026 13:50
@fruffy
Copy link
Copy Markdown
Contributor

fruffy commented Mar 15, 2026

You should not vendor the dependencies in third party. If we need PI, it makes sense to create a Bazel build there first.

@matthewtlam

@fruffy fruffy requested a review from qobilidop March 15, 2026 17:46
@qobilidop
Copy link
Copy Markdown
Member

@kunal9812 Please make sure all the existing CIs pass. And besides that, please add a new CI to test the Bazel build and demonstrate it passes as well.

@kunal9812
Copy link
Copy Markdown
Author

Thank you for the feedback! I understand — vendoring PI sources was a pragmatic workaround to get the build working.
I'll work on:
-Adding Bazel MODULE.bazel + BUILD files to p4lang/PI
-Updating the BMv2 BUILD to reference PI as an external dep
-Getting the CI workflow to pass
Will update the PR shortly.

@matthewtlam
Copy link
Copy Markdown
Contributor

matthewtlam commented Mar 16, 2026

+1 to what @fruffy mentioned. We should not be vendoring our dependencies in 3rd party. These should be gracefully handled using Bazel

Please make sure all the builds are working

@matthewtlam
Copy link
Copy Markdown
Contributor

Thanks for your PR @kunal9812

None of the PRs will be carefully reviewed until Apr 1 (once the contributor deadline is over). Starting today (March 16th), the GSoC contributor application will open. Please make sure you submit your application before the deadline.

During the first week of April, after applications and PRs are reviewed, candidates who will be considered will be sent an interview. The contributor who gets admitted into GSoC will have their PR pushed to head

cc: @qobilidop

PI is now referenced as an external Bazel bzlmod dependency via
git_override in MODULE.bazel, pointing to p4lang/PI with bzlmod support.

This addresses reviewer feedback from fruffy:
'You should not vendor the dependencies in third party. If we need PI,
it makes sense to create a Bazel build there first.'

PI bzlmod support PR: https://github.com/kunal9812/PI/pull/1
@kunal9812
Copy link
Copy Markdown
Author

kunal9812 commented Mar 17, 2026

Hi @fruffy and @qobilidop — thank you for the feedback!
I’ve addressed both issues:

  • Removing Vendoring PI dependencies from 3rd party, instead of vendoring PI sources into third_party/PI/, I’ve added proper bzlmod support (MODULE.bazel) to the PI repository itself: Add Bazel bzlmod support (MODULE.bazel) PI#629

  • Existing CI failures - The CMake CI failures are pre-existing on the main branch and unrelated to this PR. I verified that by running git stash locally and confirming the same failures occur without any of these changes.

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.

4 participants