forked from sgammon/rules_graalvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extensions.bzl
57 lines (49 loc) · 1.74 KB
/
extensions.bzl
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
"Defines extensions for use with Bzlmod."
load(
"//graalvm:repositories.bzl",
"graalvm_repository",
)
def _gvm_impl(mctx):
"""Implementation of the GraalVM module extension."""
selected = None
all_components = []
for mod in mctx.modules:
# gather gvm toolchain info
for gvm in mod.tags.graalvm:
if not mod.is_root:
fail("graalvm tag is only allowed in the root module, use component tag instead")
selected = gvm
if len(gvm.components) > 0:
all_components += [i for i in gvm.components if not i in all_components]
# gather components
for extra_component in mod.tags.component:
if extra_component.name not in all_components:
all_components.append(extra_component.name)
graalvm_repository(
name = selected.name,
version = selected.version,
java_version = selected.java_version,
distribution = selected.distribution,
toolchain_prefix = selected.toolchain_prefix,
components = all_components,
setup_actions = selected.setup_actions,
)
_graalvm = tag_class(attrs = {
"name": attr.string(mandatory = True),
"version": attr.string(mandatory = True),
"java_version": attr.string(mandatory = True),
"distribution": attr.string(mandatory = False),
"toolchain_prefix": attr.string(mandatory = False),
"components": attr.string_list(mandatory = False),
"setup_actions": attr.string_list(mandatory = False),
})
_component = tag_class(attrs = {
"name": attr.string(mandatory = True),
})
graalvm = module_extension(
implementation = _gvm_impl,
tag_classes = {
"graalvm": _graalvm,
"component": _component,
},
)