aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/DefaultInfoApi.java
blob: b4a3c2596f74e03462b8272859dfded073dc2c38 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Copyright 2018 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.

package com.google.devtools.build.lib.skylarkbuildapi;

import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.skylarkinterface.Param;
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkConstructor;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.syntax.SkylarkNestedSet;

/** A provider that gives general information about a target's direct and transitive files. */
@SkylarkModule(
    name = "DefaultInfo",
    category = SkylarkModuleCategory.PROVIDER,
    doc = "A provider that gives general information about a target's direct and transitive files. "
        + "Every rule type has this provider, even if it is not returned explicitly by the "
        + "rule's implementation function."
        + "Each <code>DefaultInfo</code> instance has the following fields: "
        + "<ul>"
        + "<li><code>files</code>"
        + "<li><code>files_to_run</code>"
        + "<li><code>data_runfiles</code>"
        + "<li><code>default_runfiles</code>"
        + "</ul>"
        + "See the <a href='../rules.$DOC_EXT'>rules</a> page for more information."
)
public interface DefaultInfoApi extends StructApi {

  @SkylarkCallable(
      name = "files",
      doc =  "A <a href='depset.html'><code>depset</code></a> of "
          + "<a href='File.html'><code>File</code></a> objects representing the default "
          + "outputs to build when this target is specified on the blaze command line. By "
          + "default it is all predeclared outputs.",
      structField = true,
      allowReturnNones = true
  )
  SkylarkNestedSet getFiles();

  @SkylarkCallable(
      name = "files_to_run",
      doc =  "A <a href='FilesToRunProvider.html'><code>FilesToRunProvider</code></a> object "
          + "containing information about the executable and runfiles of the target.",
      structField = true,
      allowReturnNones = true
  )
  FilesToRunProviderApi<?> getFilesToRun();

  @SkylarkCallable(
      name = "data_runfiles",
      doc = "the files that are added to the runfiles of a "
          + "target that depend on the rule via the <code>data</code> attribute.",
      structField = true,
      allowReturnNones = true
  )
  RunfilesApi getDataRunfiles();

  @SkylarkCallable(
      name = "default_runfiles",
      doc = "the files that are added to the runfiles of "
          + "a target that depend on the rule via anything but the <code>data</code> "
          + "attribute.",
      structField = true,
      allowReturnNones = true
  )
  RunfilesApi getDefaultRunfiles();

  /**
   * Provider for {@link DefaultInfoApi}.
   */
  @SkylarkModule(name = "Provider", documented = false, doc = "")
  public static interface DefaultInfoApiProvider<RunfilesT extends RunfilesApi,
      FileT extends FileApi> extends ProviderApi {

    @SkylarkCallable(
      name = "DefaultInfo",
      doc = "<p>The <code>DefaultInfo</code> constructor.",
      parameters = {
        @Param(
          name = "files",
          type = SkylarkNestedSet.class,
          named = true,
          positional = false,
          defaultValue = "None",
          noneable = true,
          doc = "A <a href='depset.html'><code>depset</code></a> of "
              + "<a href='File.html'><code>File</code></a> objects representing the default "
              + "outputs to build when this target is specified on the blaze command line. By "
              + "default it is all predeclared outputs."
        ),
        @Param(
            name = "runfiles",
            type = RunfilesApi.class,
            named = true,
            positional = false,
            defaultValue = "None",
            noneable = true,
            doc = "set of files acting as both the "
                + "<code>data_runfiles</code> and <code>default_runfiles</code>."
        ),
        @Param(
            name = "data_runfiles",
            type = RunfilesApi.class,
            named = true,
            positional = false,
            defaultValue = "None",
            noneable = true,
            doc = "the files that are added to the runfiles of a "
                + "target that depend on the rule via the <code>data</code> attribute."
        ),
        @Param(
            name = "default_runfiles",
            type = RunfilesApi.class,
            named = true,
            positional = false,
            defaultValue = "None",
            noneable = true,
            doc = "the files that are added to the runfiles of "
                + "a target that depend on the rule via anything but the <code>data</code> "
                + "attribute."
        ),
        @Param(
          name = "executable",
          type = FileApi.class,
          named = true,
          positional = false,
          defaultValue = "None",
          noneable = true,
          doc = "If this rule is marked "
              + "<a href='globals.html#rule.executable'><code>executable</code></a> or "
              + "<a href='globals.html#rule.test'><code>test</code></a>, this is a "
              + "<a href='File.html'><code>File</code></a> object representing the file that "
              + "should be executed to run the target. By default it is the predeclared output "
              + "<code>ctx.outputs.executable</code>."
        )},
      useLocation = true,
      selfCall = true)
    @SkylarkConstructor(objectType = DefaultInfoApi.class,
        receiverNameForDoc = "DefaultInfo")
    public DefaultInfoApi constructor(
        // TODO(cparsons): Use stricter types when Runfiles.NONE is passed as null.
        Object files,
        Object runfiles,
        Object dataRunfiles,
        Object defaultRunfiles,
        Object executable,
        Location loc) throws EvalException;
  }
}