Repository navigation
Expand file tree
/
Copy pathextensions.bzl
More file actions
50 lines (41 loc) · 1.5 KB
/
Copy pathextensions.bzl
File metadata and controls
50 lines (41 loc) · 1.5 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
"""Module extensions for rules_halide"""
load("//internal:prebuilt_pkg.bzl", "prebuilt_pkg")
load("//internal:versions.bzl", "DEFAULT_VERSION", "SUPPORTED_VERSIONS")
def _halide_impl(module_ctx):
version = DEFAULT_VERSION
# Find the version requested by modules. We'll use the root module's request
# or the first version we find.
for mod in module_ctx.modules:
for tag in mod.tags.toolchain:
if tag.version:
version = tag.version
if version not in SUPPORTED_VERSIONS:
fail("Unsupported Halide version: {}. Supported versions: {}".format(
version,
", ".join(SUPPORTED_VERSIONS.keys()),
))
version_info = SUPPORTED_VERSIONS[version]
urls = {platform: [info["url"]] for platform, info in version_info.items()}
sha256 = {platform: info["sha256"] for platform, info in version_info.items()}
strip_prefix = {platform: info["strip_prefix"] for platform, info in version_info.items()}
prebuilt_pkg(
name = "halide_prebuilt_pkg",
build_file = Label("//internal:BUILD.prebuilt_pkg"),
urls = urls,
sha256 = sha256,
strip_prefix = strip_prefix,
)
toolchain_tag = tag_class(
attrs = {
"version": attr.string(
doc = "The prebuilt Halide version to use (e.g. '14.0.0').",
default = DEFAULT_VERSION,
),
},
)
halide = module_extension(
implementation = _halide_impl,
tag_classes = {
"toolchain": toolchain_tag,
},
)