Skip to content

Commit f6beccc

Browse files
committed
Allow building specific variants
1 parent 0f9f23c commit f6beccc

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

scripts/build/__main__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ def main():
1818
choices=["x64", "arm64"],
1919
help="The architecture to build for (default: detected from current platform)",
2020
)
21+
parser.add_argument(
22+
"--variant",
23+
default=None,
24+
help="The variant to build for (e.g., 'sm86' for CUDA). If not specified, the default variant for the platform will be used.",
25+
)
2126
args = parser.parse_args()
2227

2328
platform = args.platform
2429
arch = args.arch
30+
variant = args.variant
2531
try:
2632
module = globals()[f"platform_{platform}"]
2733
except KeyError:
@@ -45,6 +51,7 @@ def main():
4551
additional_files_func,
4652
env_func,
4753
arch,
54+
variant,
4855
)
4956

5057

scripts/build/common.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def build_project(
188188
get_additional_files_func=None,
189189
get_env_func=None,
190190
arch=None,
191+
variant=None,
191192
):
192193
"""Common build logic for all backends.
193194
@@ -210,6 +211,13 @@ def build_project(
210211
if not variants:
211212
variants = [{"name": "any", "compile_flags": []}]
212213

214+
if variant is not None:
215+
# Filter variants to only include the specified one
216+
variants = [v for v in variants if v["name"] == variant]
217+
if not variants:
218+
print(f"Variant '{variant}' not found.")
219+
sys.exit(1)
220+
213221
# Get target for "any" variant to use for additional files
214222
target_any = get_target(get_platform_name_func, "any", arch)
215223

0 commit comments

Comments
 (0)