forked from najaeda/naja
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMODULE.bazel
More file actions
243 lines (202 loc) · 9.99 KB
/
Copy pathMODULE.bazel
File metadata and controls
243 lines (202 loc) · 9.99 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
236
237
238
239
240
241
242
243
# SPDX-FileCopyrightText: 2023 The Naja authors <https://github.com/najaeda/naja/blob/main/AUTHORS>
#
# SPDX-License-Identifier: Apache-2.0
"""Bazel module for naja.
CMake is naja's primary build system (see CLAUDE.md's "Build systems"
section) -- this file, and the BUILD.bazel tree throughout the repo,
are kept as a validated smoke test (ubuntu-bazel.yml/macos-bazel.yml:
`bazel build //... && bazel test //...`), not CI's primary gate. See
internal/bazel-migration-plan.md for the full history of how this was
built out and the 2026-07-28 pivot away from full Bazel migration.
ci/check_submodule_bazel_sync.py (run by
.github/workflows/dependency-sync-check.yml) keeps this file's
git_override()/git_repository() commit pins in sync with CMake's git
submodule pins (.gitmodules/thirdparty/) for the dependencies both
build systems share.
"""
module(
name = "naja",
version = "1.0.0",
)
# --- Bazel Central Registry dependencies (Phase 0) ---
bazel_dep(name = "rules_cc", version = "0.2.17")
# Used by test/ (cc_test targets land in Phase 5, task #20).
bazel_dep(name = "googletest", version = "1.17.0.bcr.2", repo_name = "googletest")
# Used by bench/ (task #28) -- mirrors CMake's `find_package(benchmark
# REQUIRED)` (bench/CMakeLists.txt), gated there behind -DBUILD_BENCHMARKS=ON;
# no equivalent optional-fetch mechanism in bzlmod, so this is just an
# ordinary bazel_dep (same non-dev-dependency style as googletest above).
bazel_dep(name = "google_benchmark", version = "1.9.5")
# select()-ed on directly (task #18, dnl/bne/opt/metrics' -Wno-sign-conversion
# on macOS, matching CMakeLists.txt's `if(APPLE)` guards) -- otherwise only
# pulled in transitively, not visible to our own module under strict deps.
bazel_dep(name = "platforms", version = "1.0.0")
# Transitive dependency of capnp-cpp; also used directly by naja's own
# codegen/serialization glue.
bazel_dep(name = "zlib", version = "1.3.2")
# Replaces the CMake-side `capnp_generate_cpp()` toolchain
# (src/nl/netlist/serialization/capnp/CMakeLists.txt). Schema BUILD rules
# for the 3 naja-if .capnp files are written in Phase 2 (task #9).
bazel_dep(name = "capnp-cpp", version = "1.4.0")
# --- cpptrace (task #4): BCR module exists, pinned to the exact current
# submodule commit (3db8da8) rather than the newer 1.0.4 BCR release, so
# behavior doesn't shift as a side effect of the build-system switch. ---
bazel_dep(name = "cpptrace", version = "1.0.4.bcr.1")
git_override(
module_name = "cpptrace",
remote = "https://github.com/jeremy-rifkin/cpptrace",
commit = "3db8da80111171c219ab5839905771386bee06b3",
)
# --- naja-if, naja-verilog (tasks #5, #6): both are najaeda-org forks
# (siblings of this repo, not truly third-party), each carrying its own
# native MODULE.bazel/BUILD.bazel -- making them real Bazel modules
# consumable via bazel_dep + git_override, the same pattern as cpptrace
# above. See internal/bazel-migration-plan.md.
bazel_dep(name = "naja-if", version = "0.0.0")
git_override(
module_name = "naja-if",
remote = "https://github.com/najaeda/naja-if",
commit = "099677d9f52c0db11b12c08d03e32543eebc7888", # bazel-support
)
# naja-verilog's `bazel-support` branch (native MODULE.bazel/BUILD.bazel)
# was merged into `main` (2026), so this now just tracks `main`'s tip
# directly, same commit CMake's own submodule pin
# (thirdparty/naja-verilog) tracks -- ci/check_submodule_bazel_sync.py
# checks these for an exact match now, not just ancestry.
bazel_dep(name = "naja-verilog", version = "0.0.0")
git_override(
module_name = "naja-verilog",
remote = "https://github.com/najaeda/naja-verilog",
commit = "5da040bb34f0e4e5bb8d67223b999a0132fb401f", # main
)
# --- slang (task #7): also a najaeda-org fork, but its build (Python
# codegen-driven, FetchContent for fmt/mimalloc/Catch2/Boost.regex/
# tomlplusplus) is the single highest-risk item in this migration --
# deliberately kept as the Phase 1 non-module git_repository + placeholder
# overlay rather than attempting a native upstream port at the same time
# (see the Phase 3 scope decision in internal/bazel-migration-plan.md).
# Real build target: task #14, shelling out to slang's own CMake build via
# rules_foreign_cc (bazel/thirdparty/slang/BUILD.bazel). ---
bazel_dep(name = "rules_foreign_cc", version = "0.15.1")
host_prefixes = use_repo_rule(
"//bazel/thirdparty:slang_host_prefixes.bzl",
"host_prefixes",
)
host_prefixes(name = "slang_host_prefixes")
git_repository = use_repo_rule(
"@bazel_tools//tools/build_defs/repo:git.bzl",
"git_repository",
)
git_repository(
name = "slang",
remote = "https://github.com/najaeda/slang",
commit = "512c327c209d3043aa98ecfd02d06a1b73fcd5fb",
build_file = "//bazel/thirdparty:slang_overlay.BUILD",
)
# fmt: svlang's static library doesn't bundle it (found as a system lib via
# CMAKE_PREFIX_PATH, see host_prefixes.bzl above), so @slang//:slang needs
# to link it directly too. Vendored (pinned to the exact 12.2.0 tag
# commit, matching slang's own `FIND_PACKAGE_ARGS 12.2` requirement)
# rather than pkg-config-wrapped like tbb/boost: live Ubuntu CI showed a
# real ABI mismatch when this was pkg-config-wrapped against apt's
# libfmt-dev (v8/v9, far below 12.2) -- slang's own internal build
# rejects that same old version and fetches a real fmt 12.2.0 over the
# network instead, so libsvlang.a ends up needing `fmt::v12::...`
# symbols an older wrapped fmt can never provide (undefined reference
# errors, confirmed on live CI). Same fix as tomlplusplus below: pin our
# own copy to the exact version slang requires, everywhere, rather than
# depend on whatever a platform's package manager happens to ship.
git_repository(
name = "fmt",
remote = "https://github.com/fmtlib/fmt",
commit = "1be298e1bd68957e4cd352e1f676f00e07dcfb57", # 12.2.0
build_file = "//bazel/thirdparty:fmt_overlay.BUILD",
)
# tomlplusplus: same situation as fmt (svlang doesn't bundle it in
# either), vendored the same way (pinned to the v3.4.0 tag's commit,
# matching slang's own `FIND_PACKAGE_ARGS 3.4` minimum) -- Ubuntu's apt
# doesn't have libtomlplusplus-dev at all (confirmed on live CI). See
# bazel/thirdparty/tomlplusplus_overlay.BUILD.
git_repository(
name = "tomlplusplus",
remote = "https://github.com/marzer/tomlplusplus",
commit = "30172438cee64926dc41fdd9c11fb3ba5b2ba9de", # v3.4.0
build_file = "//bazel/thirdparty:tomlplusplus_overlay.BUILD",
)
# --- TBB (task #10): no BCR module. Wrap the already system-installed
# oneTBB (same one CMake's find_package(TBB REQUIRED) resolves against)
# via pkg-config rather than building it from source under Bazel. ---
tbb_repository = use_repo_rule(
"//bazel/thirdparty/tbb:repo.bzl",
"tbb_repository",
)
tbb_repository(name = "tbb")
# --- Boost (task #11): no BCR module. naja only consumes it as headers
# (no compiled Boost:: component is linked anywhere in src/), so vendor
# the official release tarball the same way fmt/tomlplusplus are vendored
# above, rather than wrapping whatever Boost a given host happens to have
# installed. The earlier pkg-config/find_path-style
# bazel/thirdparty/boost/repo.bzl meant both the exact version and the
# search-order-picked install location varied by machine, and its
# repo_ctx.symlink of the whole discovered include prefix was found to
# leak unrelated system headers into the include path (a stale
# libgtest-dev gtest.h shadowed Bazel's own fetched @googletest on one
# dev machine). Pinning a tarball fetch removes both: identical Boost
# bits everywhere, and only boost/** on the include path. ---
http_archive = use_repo_rule(
"@bazel_tools//tools/build_defs/repo:http.bzl",
"http_archive",
)
http_archive(
name = "boost",
url = "https://archives.boost.io/release/1.89.0/source/boost_1_89_0.tar.gz",
sha256 = "9de758db755e8330a01d995b0a24d09798048400ac25c03fc5ea9be364b13c93",
strip_prefix = "boost_1_89_0",
build_file = "//bazel/thirdparty:boost_overlay.BUILD",
)
# --- Python (tasks #21/#22): no BCR module usable here (rules_python's
# hermetic toolchain would introduce a second, different Python from the
# one naja's own CMake build already uses) -- wrap the system Python 3
# via python3-config instead, same pragmatic pattern as everything above.
# See bazel/thirdparty/python/repo.bzl. ---
python_repository = use_repo_rule(
"//bazel/thirdparty/python:repo.bzl",
"python_repository",
)
python_repository(name = "python")
# --- lefdef (task #13): vendored directly in thirdparty/lefdef/ (not a
# submodule, no separate repo to push a bazel-support branch to). Only
# `bison` is needed (this SDK's lef.y/def.y embed their own hand-written
# lexers -- no flex/.l files at all), located via system_tool.bzl the same
# way CMake's find_package(BISON REQUIRED)
# (thirdparty/lefdef/CMakeLists.txt) does. See
# bazel/lefdef_bison.bzl and internal/bazel-migration-plan.md. ---
system_tool_repository = use_repo_rule(
"//bazel:system_tool.bzl",
"system_tool_repository",
)
system_tool_repository(name = "bison_tool", tool = "bison")
system_tool_repository(name = "m4_tool", tool = "m4")
# --- najaeda Python test infra (task #28): the interpreter itself (not
# just Python.h/libpython above) is needed to actually run
# `python3 -m unittest discover` inside sh_test sandboxes. Reuses
# system_tool.bzl's PATH-search pattern already declared above for
# bison/m4 rather than a second repo rule. ---
system_tool_repository(name = "python3_tool", tool = "python3")
# --- naja_core version stamping (task #15/#18): generates
# src/core/NajaVersion.h's @NAJA_GIT_HASH@ substitution. See
# bazel/git_version.bzl for the staleness caveat versus CMake's
# configure_file (rerun on every configure). ---
git_version = use_repo_rule(
"//bazel:git_version.bzl",
"git_version",
)
git_version(name = "naja_git_version")
# Phase 5, task #20: absolute workspace root, needed only by
# test/nl/formats/systemverilog/frontend's SNLSVConstructorTestSimple.cpp
# CWD-changing test. See bazel/workspace_root.bzl.
workspace_root = use_repo_rule(
"//bazel:workspace_root.bzl",
"workspace_root",
)
workspace_root(name = "naja_workspace_root")