Skip to content

Commit be0be49

Browse files
committed
Migrate to Bzlmod.
Signed-off-by: smolkaj <[email protected]>
1 parent d8c34b2 commit be0be49

File tree

6 files changed

+117
-6
lines changed

6 files changed

+117
-6
lines changed

.bazelrc

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build --host_cxxopt=-std=c++17
99
build --action_env=CC=clang
1010
build --action_env=CXX=clang++
1111

12-
# Use `WORKSPACE.bazel` instead of Bzlmod (`MODULE.bazel`).
13-
# TODO - migrate to Bzlmod.
14-
common --noenable_bzlmod
12+
# Use Bzlmod (`MODULE.bazel`) and `WORKSPACE.bzlmod`.
13+
# TODO - Disable workspace once all dependencies are migrated to bzlmod.
14+
common --enable_bzlmod
1515
common --enable_workspace

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
bazel-*
33
user.bazelrc
44
buildifier
5+
*.lock

MODULE.bazel

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module(
2+
name = "p4-constraints",
3+
bazel_compatibility = [">=7.4.1"],
4+
repo_name = "com_github_p4lang_p4_constraints",
5+
)
6+
7+
bazel_dep(name = "protobuf", version = "28.2", repo_name = "com_google_protobuf")
8+
bazel_dep(name = "abseil-cpp", version = "20240116.2", repo_name = "com_google_absl")
9+
bazel_dep(name = "re2", version = "2024-02-01", repo_name = "com_googlesource_code_re2")
10+
bazel_dep(name = "p4runtime", version = "1.4.1", repo_name = "com_github_p4lang_p4runtime")
11+
git_override(
12+
module_name = "p4runtime",
13+
commit = "da2e3441e1774112ecf44905ba8ef57d1b33c3e0",
14+
remote = "https://github.com/p4lang/p4runtime.git",
15+
strip_prefix = "proto",
16+
)
17+
18+
# Dev Depdencies.
19+
bazel_dep(
20+
name = "googletest",
21+
version = "1.15.2",
22+
dev_dependency = True,
23+
repo_name = "com_google_googletest",
24+
)
25+
bazel_dep(name = "rules_license", version = "1.0.0", dev_dependency = True)

WORKSPACE.bazel

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Bazel workspace file.
2+
#
3+
# NOTE: This file is ignored when bzlmod is enabled. It is provided for users
4+
# who have not yet migrated to bzlmod, and will be removed in the future.
25

36
workspace(name = "com_github_p4lang_p4_constraints")
47

WORKSPACE.bzlmod

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# https://bazel.build/external/migration#workspace.bzlmod
2+
#
3+
# When bzlmod is enabled and this file exists, the contents of WORKSPACE.bazel
4+
# is ignored. This file will become empty once all dependencies have been
5+
# migrated to bzlmod (`MODULE.bazel`).
6+
7+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
8+
9+
# -- P4{C, Runtime} + transitive dependencies ----------------------------------
10+
11+
http_archive(
12+
name = "com_github_p4lang_p4c",
13+
# Newest commit on main on 2021-12-07.
14+
url = "https://github.com/p4lang/p4c/archive/80629201abb61d9172639fefc7bb5b9d6007db08.zip",
15+
strip_prefix = "p4c-80629201abb61d9172639fefc7bb5b9d6007db08",
16+
)
17+
18+
load("@com_github_p4lang_p4c//:bazel/p4c_deps.bzl", "p4c_deps")
19+
20+
p4c_deps()
21+
22+
load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
23+
24+
boost_deps()
25+
26+
27+
# load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
28+
29+
# switched_rules_by_language(
30+
# name = "com_google_googleapis_imports",
31+
# cc = True,
32+
# grpc = True,
33+
# )
34+
35+
# load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
36+
37+
# grpc_deps()
38+
39+
# load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
40+
41+
# grpc_extra_deps()
42+
43+
# -- Load Buildifier -----------------------------------------------------
44+
# buildifier is written in Go and hence needs rules_go to be built.
45+
# See https://github.com/bazelbuild/rules_go for the up to date setup instructions.
46+
http_archive(
47+
name = "io_bazel_rules_go",
48+
sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996",
49+
urls = [
50+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
51+
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip",
52+
],
53+
)
54+
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
55+
go_rules_dependencies()
56+
http_archive(
57+
name = "com_github_bazelbuild_buildtools",
58+
sha256 = "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3",
59+
strip_prefix = "buildtools-4.2.2",
60+
urls = [
61+
"https://github.com/bazelbuild/buildtools/archive/refs/tags/4.2.2.tar.gz",
62+
],
63+
)
64+
65+
# -- Z3 & Load Rules Foreign CC -------------------------------------------------
66+
67+
http_archive(
68+
name = "com_github_z3prover_z3",
69+
url = "https://github.com/Z3Prover/z3/archive/z3-4.8.12.tar.gz",
70+
strip_prefix = "z3-z3-4.8.12",
71+
sha256 = "e3aaefde68b839299cbc988178529535e66048398f7d083b40c69fe0da55f8b7",
72+
build_file = "@//:bazel/BUILD.z3.bazel",
73+
)
74+
http_archive(
75+
name = "rules_foreign_cc",
76+
sha256 = "d54742ffbdc6924f222d2179f0e10e911c5c659c4ae74158e9fe827aad862ac6",
77+
strip_prefix = "rules_foreign_cc-0.2.0",
78+
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.2.0.tar.gz",
79+
)
80+
81+
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
82+
83+
rules_foreign_cc_dependencies()

p4_constraints/BUILD.bazel

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# GOOGLE ONLY (DO NOT REMOVE): load("//third_party/protobuf/bazel:proto_library.bzl", "proto_library")
2-
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
3-
load("@rules_proto//proto:defs.bzl", "proto_library")
1+
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
2+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
43

54
package(
65
default_visibility = ["//visibility:public"],

0 commit comments

Comments
 (0)