summaryrefslogtreecommitdiff
path: root/pkg/providers.bzl
blob: 459a064389ef172d77197cccee82cbc92b8e6686 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Copyright 2020 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Packaging related providers."""

PackageArtifactInfo = provider(
    doc = """Metadata about a package artifact.""",
    fields = {
        "file": "File object for said artifact",
        "file_name": "DEPRECATED (use fields of file instead): The file name of the artifact.",
        "label": "Label which produced it",
    },
)

PackageVariablesInfo = provider(
    doc = """Variables which may be substituted into package names and content.""",
    fields = {
        "values": "Dict of name/value pairs",
    },
)

PackageFilesInfo = provider(
    doc = """Provider representing the installation of one or more files to destination with attributes""",
    fields = {
        "attributes": """Attribute information, represented as a `dict`.

Keys are strings representing attribute identifiers, values are
arbitrary data structures that represent the associated data.  These are
most often strings, but are not explicity defined.

For known attributes and data type expectations, see the Common
Attributes documentation in the `rules_pkg` reference.
        """,

        # This is a mapping of destinations to sources to allow for the same
        # target to be installed to multiple locations within a package within a
        # single provider.
        "dest_src_map": """Map of file destinations to sources.

        Sources are represented by bazel `File` structures.""",
    },
)

PackageDirsInfo = provider(
    doc = """Provider representing the creation of one or more directories in a package""",
    fields = {
        "attributes": """See `attributes` in PackageFilesInfo.""",
        "dirs": """string list: installed directory names""",
    },
)

PackageSymlinkInfo = provider(
    doc = """Provider representing the creation of a single symbolic link in a package""",
    fields = {
        "attributes": """See `attributes` in PackageFilesInfo.""",
        "destination": """string: Filesystem link 'name'""",
        "target": """string or Label: Filesystem link 'target'.

        TODO(nacl): Label sources not yet supported.
        """,
    },
)

# Grouping provider: the only one that needs to be consumed by packaging (or
# other) rules that materialize paths.
PackageFilegroupInfo = provider(
    doc = """Provider representing a collection of related packaging providers,

    In the "fields" documentation, "origin" refers to the label identifying the
    where the provider was originally defined.  This can be used by packaging
    rules to provide better diagnostics related to where packaging rules were
    created.

    """,
    fields = {
        "pkg_files": "list of tuples of (PackageFilesInfo, origin)",
        "pkg_dirs": "list of tuples of (PackageDirsInfo, origin)",
        "pkg_symlinks": "list of tuples of (PackageSymlinkInfo, origin)",
    },
)