-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathversion.bzl
More file actions
33 lines (28 loc) · 939 Bytes
/
version.bzl
File metadata and controls
33 lines (28 loc) · 939 Bytes
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
"""Generates the version header file using a template.
In typical nbdkit build, this is done with autoconf.
"""
def _expand_version_impl(ctx):
output = ctx.outputs.expanded_file
ctx.actions.expand_template(
template = ctx.file.template,
output = output,
substitutions = {
"@NBDKIT_VERSION_MAJOR@": ctx.attr.major,
"@NBDKIT_VERSION_MINOR@": ctx.attr.minor,
"@NBDKIT_VERSION_MICRO@": ctx.attr.micro,
},
)
return [DefaultInfo(files = depset([output]))]
expand_version = rule(
implementation = _expand_version_impl,
attrs = {
"major": attr.string(mandatory = True),
"minor": attr.string(mandatory = True),
"micro": attr.string(mandatory = True),
"template": attr.label(
mandatory = True,
allow_single_file = True,
),
"expanded_file": attr.output(mandatory = True),
},
)