From 721de5000d410706534ead2c1f643abdbd045f01 Mon Sep 17 00:00:00 2001 From: Bili Dong Date: Mon, 15 Sep 2025 15:25:46 +0000 Subject: [PATCH 1/3] Remove rules_cc Signed-off-by: Bili Dong --- WORKSPACE.bazel | 12 +++--------- p4_constraints/BUILD.bazel | 2 -- p4_constraints/backend/BUILD.bazel | 2 -- p4_constraints/cli/BUILD.bazel | 2 -- p4_constraints/frontend/BUILD.bazel | 3 --- p4_constraints_deps.bzl | 7 ------- 6 files changed, 3 insertions(+), 25 deletions(-) diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index f7a16e6..fbb33f9 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -56,12 +56,6 @@ load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") grpc_extra_deps() -# -- Load Rules CC ------------------------------------------------------------- -# See https://github.com/bazelbuild/rules_cc. -load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies") - -rules_cc_dependencies() - # -- Load Rules Foreign CC (for building Z3) ----------------------------------- # Used for Z3. @@ -75,10 +69,10 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "buildifier_prebuilt", - sha256 = "5dbf72e4f93917edfb91f53958d6289736adb845b2b89dbfb9bfc199a492030c", - strip_prefix = "buildifier-prebuilt-8.0.1", + sha256 = "7f85b688a4b558e2d9099340cfb510ba7179f829454fba842370bccffb67d6cc", + strip_prefix = "buildifier-prebuilt-7.3.1", urls = [ - "http://github.com/keith/buildifier-prebuilt/archive/8.0.1.tar.gz", + "http://github.com/keith/buildifier-prebuilt/archive/7.3.1.tar.gz", ], ) diff --git a/p4_constraints/BUILD.bazel b/p4_constraints/BUILD.bazel index 4e07c51..341ca58 100644 --- a/p4_constraints/BUILD.bazel +++ b/p4_constraints/BUILD.bazel @@ -1,6 +1,4 @@ load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") -load("@rules_cc//cc:cc_library.bzl", "cc_library") -load("@rules_cc//cc:cc_test.bzl", "cc_test") # GOOGLE ONLY (DO NOT REMOVE): load("//third_party/protobuf/bazel:proto_library.bzl", "proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") diff --git a/p4_constraints/backend/BUILD.bazel b/p4_constraints/backend/BUILD.bazel index f775a7a..9d0f2aa 100644 --- a/p4_constraints/backend/BUILD.bazel +++ b/p4_constraints/backend/BUILD.bazel @@ -1,5 +1,3 @@ -load("@rules_cc//cc:cc_library.bzl", "cc_library") -load("@rules_cc//cc:cc_test.bzl", "cc_test") load("//e2e_tests:p4check.bzl", "cmd_diff_test") package( diff --git a/p4_constraints/cli/BUILD.bazel b/p4_constraints/cli/BUILD.bazel index b8b6107..7c7aa4d 100644 --- a/p4_constraints/cli/BUILD.bazel +++ b/p4_constraints/cli/BUILD.bazel @@ -1,5 +1,3 @@ -load("@rules_cc//cc:cc_binary.bzl", "cc_binary") - package( default_visibility = ["//visibility:public"], licenses = ["notice"], # Apache 2.0 diff --git a/p4_constraints/frontend/BUILD.bazel b/p4_constraints/frontend/BUILD.bazel index b08751e..3336fb0 100644 --- a/p4_constraints/frontend/BUILD.bazel +++ b/p4_constraints/frontend/BUILD.bazel @@ -1,6 +1,3 @@ -load("@rules_cc//cc:cc_library.bzl", "cc_library") -load("@rules_cc//cc:cc_test.bzl", "cc_test") - package( licenses = ["notice"], # Apache 2.0 ) diff --git a/p4_constraints_deps.bzl b/p4_constraints_deps.bzl index f3c016c..822e5b8 100644 --- a/p4_constraints_deps.bzl +++ b/p4_constraints_deps.bzl @@ -64,13 +64,6 @@ def p4_constraints_deps(): sha256 = "e3aaefde68b839299cbc988178529535e66048398f7d083b40c69fe0da55f8b7", build_file = "@//:bazel/BUILD.z3.bazel", ) - if not native.existing_rule("rules_cc"): - http_archive( - name = "rules_cc", - urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"], - sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df", - strip_prefix = "rules_cc-0.0.16", - ) if not native.existing_rule("rules_foreign_cc"): # Required for Z3. http_archive( name = "rules_foreign_cc", From 31b9848e1f695824048bd4e0b636bc59fde2e41d Mon Sep 17 00:00:00 2001 From: Bili Dong Date: Mon, 15 Sep 2025 17:14:56 +0000 Subject: [PATCH 2/3] Tweak some Bazel dependency versions Signed-off-by: Bili Dong --- p4_constraints_deps.bzl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/p4_constraints_deps.bzl b/p4_constraints_deps.bzl index 822e5b8..66976d2 100644 --- a/p4_constraints_deps.bzl +++ b/p4_constraints_deps.bzl @@ -27,8 +27,9 @@ def p4_constraints_deps(): if not native.existing_rule("com_google_protobuf"): http_archive( name = "com_google_protobuf", - url = "https://github.com/protocolbuffers/protobuf/releases/download/v29.1/protobuf-29.1.tar.gz", - strip_prefix = "protobuf-29.1", + url = "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v25.2.zip", + strip_prefix = "protobuf-25.2", + sha256 = "ddd0f5271f31b549efc74eb39061e142132653d5d043071fcec265bd571e73c4", ) if not native.existing_rule("com_googlesource_code_re2"): http_archive( @@ -39,9 +40,9 @@ def p4_constraints_deps(): if not native.existing_rule("rules_proto"): http_archive( name = "rules_proto", - sha256 = "0e5c64a2599a6e26c6a03d6162242d231ecc0de219534c38cb4402171def21e8", - strip_prefix = "rules_proto-7.0.2", - url = "https://github.com/bazelbuild/rules_proto/releases/download/7.0.2/rules_proto-7.0.2.tar.gz", + url = "https://github.com/bazelbuild/rules_proto/archive/5.3.0-21.7.tar.gz", + strip_prefix = "rules_proto-5.3.0-21.7", + sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd", ) if not native.existing_rule("com_github_p4lang_p4runtime"): http_archive( From 5b6ec72c61c9f69b1d62b58e170eb414c6748059 Mon Sep 17 00:00:00 2001 From: Bili Dong Date: Mon, 15 Sep 2025 18:43:23 +0000 Subject: [PATCH 3/3] Downgrade Bazel version Signed-off-by: Bili Dong --- .bazelrc | 5 ----- .bazelversion | 2 +- .github/workflows/ci-native.yml | 2 +- WORKSPACE.bazel => WORKSPACE | 3 +++ p4_constraints/BUILD.bazel | 4 +--- p4_constraints_deps.bzl | 31 ++++++++++++++++++++----------- 6 files changed, 26 insertions(+), 21 deletions(-) rename WORKSPACE.bazel => WORKSPACE (96%) diff --git a/.bazelrc b/.bazelrc index f097dde..fa6c0b4 100644 --- a/.bazelrc +++ b/.bazelrc @@ -8,8 +8,3 @@ build --host_cxxopt=-std=c++17 # Use Clang. build --action_env=CC=clang build --action_env=CXX=clang++ - -# Use `WORKSPACE.bazel` instead of Bzlmod (`MODULE.bazel`). -# TODO - migrate to Bzlmod. -common --noenable_bzlmod -common --enable_workspace diff --git a/.bazelversion b/.bazelversion index 815da58..19b860c 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -7.4.1 +6.4.0 diff --git a/.github/workflows/ci-native.yml b/.github/workflows/ci-native.yml index 7d87df8..366a50c 100644 --- a/.github/workflows/ci-native.yml +++ b/.github/workflows/ci-native.yml @@ -21,7 +21,7 @@ jobs: os: [ubuntu-22.04, ubuntu-latest] # See Bazelisk README for legal values. # TODO - Add `latest` once it is supported. Requires using Bzlmod. - bazel_version: [7.x] + bazel_version: [6.x] # Don't abort other runs when one of them fails, to ease debugging. fail-fast: false diff --git a/WORKSPACE.bazel b/WORKSPACE similarity index 96% rename from WORKSPACE.bazel rename to WORKSPACE index fbb33f9..f0e769f 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE @@ -40,11 +40,14 @@ load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps") boost_deps() +# -- Load GRPC ----------------------------------------------------------------- + load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") switched_rules_by_language( name = "com_google_googleapis_imports", cc = True, + go = True, grpc = True, ) diff --git a/p4_constraints/BUILD.bazel b/p4_constraints/BUILD.bazel index 341ca58..b430bdb 100644 --- a/p4_constraints/BUILD.bazel +++ b/p4_constraints/BUILD.bazel @@ -1,6 +1,4 @@ -load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") -# GOOGLE ONLY (DO NOT REMOVE): load("//third_party/protobuf/bazel:proto_library.bzl", "proto_library") - +load("@com_google_googleapis_imports//:imports.bzl", "cc_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") package( diff --git a/p4_constraints_deps.bzl b/p4_constraints_deps.bzl index 66976d2..460d70c 100644 --- a/p4_constraints_deps.bzl +++ b/p4_constraints_deps.bzl @@ -10,6 +10,13 @@ def p4_constraints_deps(): urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240722.0/abseil-cpp-20240722.0.tar.gz"], strip_prefix = "abseil-cpp-20240722.0", ) + if not native.existing_rule("com_google_googleapis"): + http_archive( + name = "com_google_googleapis", + url = "https://github.com/googleapis/googleapis/archive/f405c718d60484124808adb7fb5963974d654bb4.zip", + strip_prefix = "googleapis-f405c718d60484124808adb7fb5963974d654bb4", + sha256 = "406b64643eede84ce3e0821a1d01f66eaf6254e79cb9c4f53be9054551935e79", + ) if not native.existing_rule("com_google_gutil"): http_archive( name = "com_google_gutil", @@ -27,9 +34,8 @@ def p4_constraints_deps(): if not native.existing_rule("com_google_protobuf"): http_archive( name = "com_google_protobuf", - url = "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v25.2.zip", - strip_prefix = "protobuf-25.2", - sha256 = "ddd0f5271f31b549efc74eb39061e142132653d5d043071fcec265bd571e73c4", + url = "https://github.com/protocolbuffers/protobuf/releases/download/v29.1/protobuf-29.1.tar.gz", + strip_prefix = "protobuf-29.1", ) if not native.existing_rule("com_googlesource_code_re2"): http_archive( @@ -40,22 +46,25 @@ def p4_constraints_deps(): if not native.existing_rule("rules_proto"): http_archive( name = "rules_proto", - url = "https://github.com/bazelbuild/rules_proto/archive/5.3.0-21.7.tar.gz", - strip_prefix = "rules_proto-5.3.0-21.7", - sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd", + sha256 = "0e5c64a2599a6e26c6a03d6162242d231ecc0de219534c38cb4402171def21e8", + strip_prefix = "rules_proto-7.0.2", + url = "https://github.com/bazelbuild/rules_proto/releases/download/7.0.2/rules_proto-7.0.2.tar.gz", ) if not native.existing_rule("com_github_p4lang_p4runtime"): http_archive( name = "com_github_p4lang_p4runtime", - urls = ["https://github.com/p4lang/p4runtime/archive/970cbdc1d8663356214d33e3ba213cb91676b491.tar.gz"], - strip_prefix = "p4runtime-970cbdc1d8663356214d33e3ba213cb91676b491/proto", + # Newest commit on main as of 2025-08-27. + urls = ["https://github.com/p4lang/p4runtime/archive/baaf39325ceabd89b04b0d03226b6f13fc9eca29.zip"], + strip_prefix = "p4runtime-baaf39325ceabd89b04b0d03226b6f13fc9eca29/proto", + sha256 = "8b71b8a9e59c3ee7d99653e394afc44a0bfc6437dec14df619d5e1f766f129c6", ) if not native.existing_rule("com_github_p4lang_p4c"): http_archive( name = "com_github_p4lang_p4c", - # Newest commit on main on 2021-12-07. - url = "https://github.com/p4lang/p4c/archive/80629201abb61d9172639fefc7bb5b9d6007db08.zip", - strip_prefix = "p4c-80629201abb61d9172639fefc7bb5b9d6007db08", + # Newest commit on main on 2024-08-01. + url = "https://github.com/p4lang/p4c/archive/44dbcda9c7e3d26d24baadb884b31b32d215edef.zip", + strip_prefix = "p4c-44dbcda9c7e3d26d24baadb884b31b32d215edef", + sha256 = "ae4d53d0fd41572c38b03e881a8e2d2e472df246f75d6a64555f9ff1b656b574", ) if not native.existing_rule("com_github_z3prover_z3"): http_archive(