Repository navigation
Expand file tree
/
Copy pathMODULE.bazel
More file actions
235 lines (206 loc) · 9.03 KB
/
Copy pathMODULE.bazel
File metadata and controls
235 lines (206 loc) · 9.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
module(
name = "fourward",
version = "head", # Updated to yyyymmdd.p on release branches.
bazel_compatibility = [">=8.0.0"],
)
# --- Core build rules ---
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "rules_kotlin", version = "2.3.20")
# WORKAROUND: rules_kotlin@2.3.20's Kotlin capability metadata knows about
# `-Xreturn-value-checker`, but its Starlark option surface does not expose
# an attribute for it. Keep this patch until rules_kotlin exposes the option
# directly.
single_version_override(
module_name = "rules_kotlin",
patch_strip = 1,
patches = ["//bazel:rules_kotlin_return_value_checker.patch"],
)
# `dev_dependency` so the strict-deps toolchain only activates when
# 4ward is the root module; BCR consumers see the default rules_kotlin
# toolchain. Same scoping as the `single_version_override` below.
register_toolchains(
"//bazel:fourward_kotlin_toolchain",
dev_dependency = True,
)
bazel_dep(name = "rules_java", version = "9.6.1")
bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_jvm_external", version = "6.10")
# --- Protobuf & gRPC ---
bazel_dep(name = "protobuf", version = "33.5")
# Compatibility note: released grpc@1.80.0 pulls rules_swift@2.5.0, which
# conflicts with Bazel 9's rules_swift@3.1.2 when 4ward is consumed as a
# dependency. The BCR test module is pinned to Bazel 8 until grpc publishes a
# Bazel-9-compatible BCR release.
bazel_dep(name = "grpc", version = "1.80.0") # For cc_grpc_library (dataplane_cc_grpc).
bazel_dep(name = "grpc-java", version = "1.78.0.bcr.1")
bazel_dep(name = "grpc_kotlin", version = "1.5.0")
# Abseil — idiomatic C++ utilities (absl::Status, absl::Duration, absl::StrCat)
# used by //fourward_cc. Declared directly so the apparent name @abseil-cpp
# resolves under strict deps; it is also pulled transitively via @grpc.
bazel_dep(name = "abseil-cpp", version = "20260107.1")
# Bzlmod overrides below are root-module only: downstream consumers of
# @fourward do not inherit `git_override` or `single_version_override` entries.
# Keep each override's local comment focused on why it exists and when it can
# be removed.
# WORKAROUND for strict-deps issues in grpc_kotlin@1.5.0.
#
# Exit criterion: drop the patch once a released grpc-kotlin version has the
# strict-deps fix. See `bazel/grpc_kotlin.patch` for details and the upstream
# PR link.
single_version_override(
module_name = "grpc_kotlin",
patch_strip = 1,
patches = ["//bazel:grpc_kotlin.patch"],
)
# OPTIONAL performance patch: native Bazel build for Z3. Safe to drop at
# any time — Z3 builds correctly without it via rules_foreign_cc cmake().
#
# Why: the cmake() wrapper rebuilds Z3 from scratch (~5 min) on any
# toolchain change (e.g. Xcode update). The native cc_library() build
# has fine-grained caching — only changed files recompile.
#
# Maintenance: pinned to Z3 4.15.2. If Z3 is upgraded and the patch
# breaks, delete these 4 lines — the cmake() fallback is always there.
# Based on https://github.com/Z3Prover/z3/pull/9411.
single_version_override(
module_name = "z3",
patch_strip = 1,
patches = ["//bazel:z3.patch"],
)
# --- P4 ecosystem ---
# p4runtime provides p4info.proto, p4runtime.proto, and p4data.proto.
bazel_dep(name = "p4runtime", version = "1.6.0")
# Transitively pulled by @p4runtime; declared directly so our BUILD
# files can reference it by apparent name under strict deps.
# googleapis-java enables //google/rpc:rpc_java_proto.
bazel_dep(name = "googleapis", version = "0.0.0-20260402-c8ca5bce")
bazel_dep(name = "googleapis-java", version = "1.1.5")
# p4c provides the compiler frontend and midend that our backend builds on.
# BCR consumers get p4c 1.2.5.11.bcr.1 (which has //p4include, testdata
# exports, and the macOS build fix).
#
# Why: our e2e_tests/p4testgen PNA suite needs the drop-by-default fix
# (p4lang/p4c#5569), which is still open upstream. The 4ward-p4/p4c fork is
# upstream main plus that single patch; PR #5570 (PNA STF backend) is already
# in upstream main.
#
# Exit criterion: drop the git_override once #5569 lands and ships in a
# released p4c.
bazel_dep(name = "p4c", version = "1.2.5.11.bcr.1")
git_override(
module_name = "p4c",
commit = "93932df3cc9fe7de596ad257f6eee7bcddc0fd58",
remote = "https://github.com/4ward-p4/p4c.git",
)
# p4-constraints validates @entry_restriction / @action_restriction annotations.
bazel_dep(name = "p4_constraints", version = "20260909.0")
# BMv2 (behavioral-model) — v1model reference simulator for differential testing.
# Dev/CI-only via `dev_dependency = True`.
#
# Why: upstream uses Autotools. Our patch adds native Bazel rules (no Thrift,
# no nanomsg) for BMv2 differential tests.
#
# Exit criterion: update the patch whenever BMv2 is bumped; drop it only if
# upstream grows usable Bazel rules or we remove BMv2 diff testing.
bazel_dep(name = "behavioral_model", version = "head", dev_dependency = True)
git_override(
module_name = "behavioral_model",
commit = "6c7c93e5484e069c539b5c990bf37c531599894a",
patch_strip = 1,
patches = ["//bazel:behavioral_model.patch"],
remote = "https://github.com/p4lang/behavioral-model.git",
)
# p4lang/PI — the P4Runtime backend library used by BMv2's simple_switch_grpc.
# Dev/CI-only via `dev_dependency = True`; used only by
# //e2e_tests/p4runtime_diff.
#
# Why: native Bazel rules for PI's C core (`:pi`, `:pip4info`, etc.) work under
# Bzlmod with a MODULE.bazel shim. Our patch adds the BMv2 adapter and
# proto/server pieces needed by the P4Runtime diff harness.
#
# Exit criterion: update the patch when bumping PI; drop it only if upstream
# ships suitable Bazel/Bzlmod rules or the diff harness no longer needs PI.
bazel_dep(name = "p4lang_pi", version = "head", dev_dependency = True)
git_override(
module_name = "p4lang_pi",
commit = "51805c0108cb49e85e4812dd05bb6693b1f48f85",
init_submodules = True,
patch_strip = 1,
patches = ["//bazel:p4lang_pi.patch"],
remote = "https://github.com/p4lang/PI.git",
)
# --- JVM dependencies ---
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
name = "fourward_maven",
artifacts = [
"com.google.protobuf:protobuf-java:4.29.3",
"com.google.protobuf:protobuf-java-util:4.29.3",
"junit:junit:4.13.2",
"com.facebook:ktfmt:0.61",
"io.gitlab.arturbosch.detekt:detekt-cli:1.23.8",
# gRPC runtime. We depend on these via @fourward_maven rather
# than @grpc-java//... so that BCR consumers don't need to bless
# grpc-java as a contributor to the shared @maven repo.
"io.grpc:grpc-api:1.78.0",
"io.grpc:grpc-inprocess:1.78.0",
"io.grpc:grpc-kotlin-stub:1.4.3",
"io.grpc:grpc-netty:1.78.0",
"io.grpc:grpc-stub:1.78.0",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1",
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1",
"org.anarres:jcpp:1.4.14",
],
repositories = [
"https://repo1.maven.org/maven2",
],
)
use_repo(maven, "fourward_maven")
# Bless grpc-java and protobuf as contributors to the shared @maven repo
# so grpc-java's internal BUILD files resolve. See bcr_test_module/ for
# the rationale and the boilerplate BCR consumers need to replicate.
maven.install(
known_contributing_modules = [
"grpc-java",
"protobuf",
],
)
use_repo(maven, "maven")
# --- Python (cram test runner, cpplint) ---
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.12")
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pip",
python_version = "3.12",
requirements_lock = "//:requirements.txt",
)
use_repo(pip, "pip")
# --- Dev tools ---
bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.2", dev_dependency = True)
# Not dev_dependency: //fourward_cc:fourward_server_test is visible to BCR
# consumers building `@fourward//...`, so its `@googletest` dep must resolve
# outside the root-module context too.
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
# Runs clang-tidy as a Bazel aspect — no compile_commands.json needed.
# Root-module lint only via `dev_dependency = True`.
#
# Why: the upstream commit after `9e54bbb` ("Add builtin include flags for
# clang-tidy", c4d35e0) passes cc_toolchain.built_in_include_directories as
# explicit -isystem flags, which promotes /usr/include out of clang's internal
# search order and breaks #include_next from <cstdlib>.
#
# Exit criterion: re-check upstream before bumping; drop the pin if the
# include-order regression is fixed.
#
# Usage: bazel build //p4c_backend/... --config=clang-tidy
bazel_dep(name = "bazel_clang_tidy", dev_dependency = True)
git_override(
module_name = "bazel_clang_tidy",
commit = "9e54bbb15d1939a9d030c52f3032886a0b278f98",
remote = "https://github.com/erenon/bazel_clang_tidy.git",
)