summaryrefslogtreecommitdiff
path: root/pkg/releasing/defs.bzl
blob: 9f381a64fb2f507ec18c10e7bb71365bcf28e633 (plain)
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
"""Impementation for print_rel_notes."""

def print_rel_notes(
        name,
        repo,
        version,
        artifact_name = None,
        outs = None,
        setup_file = "",
        deps_method = "",
        toolchains_method = "",
        org = "bazelbuild",
        changelog = None,
        mirror_host = None):
    if not artifact_name:
        artifact_name = ":%s-%s.tar.gz" % (repo, version)
    # Must use Label to get a path relative to the rules_pkg repository,
    # instead of the calling BUILD file.
    print_rel_notes_helper = Label("//pkg/releasing:print_rel_notes")
    tools = [print_rel_notes_helper]
    cmd = [
        "LC_ALL=C.UTF-8 $(location %s)" % str(print_rel_notes_helper),
        "--org=%s" % org,
        "--repo=%s" % repo,
        "--version=%s" % version,
        "--tarball=$(location %s)" % artifact_name,
    ]
    if setup_file:
        cmd.append("--setup_file=%s" % setup_file)
    if deps_method:
        cmd.append("--deps_method=%s" % deps_method)
    if toolchains_method:
        cmd.append("--toolchains_method=%s" % toolchains_method)
    if changelog:
        cmd.append("--changelog=$(location %s)" % changelog)
        # We should depend on a changelog as a tool so that it is always built
        # for the host configuration. If the changelog is generated on the fly,
        # then we would have to run commands against our revision control
        # system. That only makes sense locally on the host, because the
        # revision history is never exported to a remote build system.
        tools.append(changelog)
    if mirror_host:
        cmd.append("--mirror_host=%s" % mirror_host)
    cmd.append(">$@")
    native.genrule(
        name = name,
        srcs = [
            artifact_name,
        ],
        outs = outs or [name + ".txt"],
        cmd = " ".join(cmd),
        tools = tools,
    )