Skip to content

Commit 2229c2f

Browse files
committed
Move build_rust_cmd function to build_defs.bzl for Bazel 7.x compatibility
1 parent 9456403 commit 2229c2f

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

BUILD.bazel

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
load(
22
":build_defs.bzl",
3+
"build_rust_cmd",
34
"CLDEBUGINFO100_GRAMMAR_JSON_FILE",
45
"COMMON_COPTS",
56
"DEBUGINFO_GRAMMAR_JSON_FILE",
@@ -35,15 +36,6 @@ config_setting(
3536
define_values = {"spirv_tools_rust_profile": "debug"},
3637
)
3738

38-
39-
def _build_rust_cmd(profile):
40-
return (
41-
"$(location :build_rust_ffi) " +
42-
"--manifest-path $(location rust/Cargo.toml) " +
43-
"--profile {profile} --target-dir $(@D)/cargo --output $@"
44-
).format(profile = profile)
45-
46-
4739
py_binary(
4840
name = "build_rust_ffi",
4941
srcs = ["rust/scripts/build_rust_ffi.py"],
@@ -152,12 +144,12 @@ genrule(
152144
),
153145
outs = ["rust/libspirv_tools_ffi.a"],
154146
cmd = select({
155-
"//:spirv_rust_profile_debug": _build_rust_cmd("debug"),
156-
"//conditions:default": _build_rust_cmd("release"),
147+
"//:spirv_rust_profile_debug": build_rust_cmd("debug"),
148+
"//conditions:default": build_rust_cmd("release"),
157149
}),
158150
cmd_bat = select({
159-
"//:spirv_rust_profile_debug": _build_rust_cmd("debug"),
160-
"//conditions:default": _build_rust_cmd("release"),
151+
"//:spirv_rust_profile_debug": build_rust_cmd("debug"),
152+
"//conditions:default": build_rust_cmd("release"),
161153
}),
162154
tools = [":build_rust_ffi"],
163155
tags = ["requires-cargo"],

build_defs.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,11 @@ def generate_extinst_lang_headers(name, grammar = None):
164164
tools = [":generate_language_headers"],
165165
visibility = ["//visibility:private"],
166166
)
167+
168+
def build_rust_cmd(profile):
169+
"""Returns the command to build the Rust FFI library."""
170+
return (
171+
"$(location :build_rust_ffi) " +
172+
"--manifest-path $(location rust/Cargo.toml) " +
173+
"--profile {profile} --target-dir $(@D)/cargo --output $@"
174+
).format(profile = profile)

0 commit comments

Comments
 (0)