Skip to content
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

Migrate to Bzlmod (fixes #153) #155

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build --host_cxxopt=-std=c++17
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
# Use Bzlmod (`MODULE.bazel`) and `WORKSPACE.bzlmod`.
# TODO - Disable workspace once all dependencies are migrated to bzlmod.
common --enable_bzlmod
common --enable_workspace
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
bazel-*
user.bazelrc
buildifier
*.lock
25 changes: 25 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module(
name = "p4-constraints",
bazel_compatibility = [">=7.4.1"],
repo_name = "com_github_p4lang_p4_constraints",
)

bazel_dep(name = "protobuf", version = "28.2", repo_name = "com_google_protobuf")
bazel_dep(name = "abseil-cpp", version = "20240116.2", repo_name = "com_google_absl")
bazel_dep(name = "re2", version = "2024-02-01", repo_name = "com_googlesource_code_re2")
bazel_dep(name = "p4runtime", version = "1.4.1", repo_name = "com_github_p4lang_p4runtime")
git_override(
module_name = "p4runtime",
commit = "da2e3441e1774112ecf44905ba8ef57d1b33c3e0",
remote = "https://github.com/p4lang/p4runtime.git",
strip_prefix = "proto",
)

# Dev Depdencies.
bazel_dep(
name = "googletest",
version = "1.15.2",
dev_dependency = True,
repo_name = "com_google_googletest",
)
bazel_dep(name = "rules_license", version = "1.0.0", dev_dependency = True)
3 changes: 3 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Bazel workspace file.
#
# NOTE: This file is ignored when bzlmod is enabled. It is provided for users
# who have not yet migrated to bzlmod, and will be removed in the future.

workspace(name = "com_github_p4lang_p4_constraints")

Expand Down
83 changes: 83 additions & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# https://bazel.build/external/migration#workspace.bzlmod
#
# When bzlmod is enabled and this file exists, the contents of WORKSPACE.bazel
# is ignored. This file will become empty once all dependencies have been
# migrated to bzlmod (`MODULE.bazel`).

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# -- P4{C, Runtime} + transitive dependencies ----------------------------------

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

load("@com_github_p4lang_p4c//:bazel/p4c_deps.bzl", "p4c_deps")

p4c_deps()

load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")

boost_deps()


# load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")

# switched_rules_by_language(
# name = "com_google_googleapis_imports",
# cc = True,
# grpc = True,
# )

# load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

# grpc_deps()

# load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

# grpc_extra_deps()

# -- Load Buildifier -----------------------------------------------------
# buildifier is written in Go and hence needs rules_go to be built.
# See https://github.com/bazelbuild/rules_go for the up to date setup instructions.
http_archive(
name = "io_bazel_rules_go",
sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
go_rules_dependencies()
http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3",
strip_prefix = "buildtools-4.2.2",
urls = [
"https://github.com/bazelbuild/buildtools/archive/refs/tags/4.2.2.tar.gz",
],
)

# -- Z3 & Load Rules Foreign CC -------------------------------------------------

http_archive(
name = "com_github_z3prover_z3",
url = "https://github.com/Z3Prover/z3/archive/z3-4.8.12.tar.gz",
strip_prefix = "z3-z3-4.8.12",
sha256 = "e3aaefde68b839299cbc988178529535e66048398f7d083b40c69fe0da55f8b7",
build_file = "@//:bazel/BUILD.z3.bazel",
)
http_archive(
name = "rules_foreign_cc",
sha256 = "d54742ffbdc6924f222d2179f0e10e911c5c659c4ae74158e9fe827aad862ac6",
strip_prefix = "rules_foreign_cc-0.2.0",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.2.0.tar.gz",
)

load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

rules_foreign_cc_dependencies()
5 changes: 2 additions & 3 deletions p4_constraints/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# GOOGLE ONLY (DO NOT REMOVE): load("//third_party/protobuf/bazel:proto_library.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")

package(
default_visibility = ["//visibility:public"],
Expand Down
Loading