aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidIdeInfoProviderApi.java
blob: 8c6424e609e6b63522cec87694cdb26fcd347c2f (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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
// Copyright 2017 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.android;

import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.skylarkbuildapi.FileApi;
import com.google.devtools.build.lib.skylarkbuildapi.ProviderApi;
import com.google.devtools.build.lib.skylarkbuildapi.StructApi;
import com.google.devtools.build.lib.skylarkbuildapi.java.OutputJarApi;
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.syntax.EvalException;
import com.google.devtools.build.lib.syntax.SkylarkDict;
import com.google.devtools.build.lib.syntax.SkylarkList;
import com.google.devtools.build.lib.syntax.SkylarkNestedSet;
import javax.annotation.Nullable;

/**
 * Configured targets implementing this provider can contribute Android-specific info to IDE to the
 * compilation.
 */
@SkylarkModule(name = "AndroidIdeInfo", doc = "", documented = false)
public interface AndroidIdeInfoProviderApi<
        FileT extends FileApi, OutputJarT extends OutputJarApi<FileT>>
    extends StructApi {

  /** Name of this info object. */
  public static String NAME = "AndroidIdeInfo";

  /** Returns the Java package. */
  @SkylarkCallable(name = "java_package", structField = true, doc = "", documented = false)
  String getJavaPackage();

  /** Returns the direct AndroidManifest. */
  @SkylarkCallable(
      name = "manifest",
      structField = true,
      doc = "",
      documented = false,
      allowReturnNones = true)
  @Nullable
  FileT getManifest();

  /** Returns the direct generated AndroidManifest. */
  @SkylarkCallable(
      name = "generated_manifest",
      structField = true,
      doc = "",
      documented = false,
      allowReturnNones = true)
  @Nullable
  FileT getGeneratedManifest();

  @SkylarkCallable(
      name = "idl_import_root",
      structField = true,
      doc = "",
      documented = false,
      allowReturnNones = true)
  @Nullable
  String getIdlImportRoot();

  /** A list of sources from the "idl_srcs" attribute. */
  @SkylarkCallable(name = "idl_srcs", structField = true, doc = "", documented = false)
  ImmutableCollection<FileT> getIdlSrcs();

  /** A list of java files generated from the "idl_srcs" attribute. */
  @SkylarkCallable(
      name = "idl_generated_java_files",
      structField = true,
      doc = "",
      documented = false)
  ImmutableCollection<FileT> getIdlGeneratedJavaFiles();

  @SkylarkCallable(
      name = "idl_source_jar",
      structField = true,
      doc = "",
      documented = false,
      allowReturnNones = true)
  @Nullable
  FileT getIdlSourceJar();

  @SkylarkCallable(
      name = "idl_class_jar",
      structField = true,
      doc = "",
      documented = false,
      allowReturnNones = true)
  @Nullable
  FileT getIdlClassJar();

  /**
   * Returns true if the target defined Android resources. Exposes {@link
   * LocalResourceContainer#definesAndroidResources(AttributeMap)}
   */
  @SkylarkCallable(
      name = "defines_android_resources",
      structField = true,
      doc = "",
      documented = false)
  boolean definesAndroidResources();

  @SkylarkCallable(
      name = "resource_jar",
      structField = true,
      doc = "",
      documented = false,
      allowReturnNones = true)
  @Nullable
  OutputJarT getResourceJar();

  @SkylarkCallable(
      name = "resource_apk",
      structField = true,
      doc = "",
      documented = false,
      allowReturnNones = true)
  @Nullable
  FileT getResourceApk();

  /** Returns the direct debug key signed apk, if there is one. */
  @SkylarkCallable(
      name = "signed_apk",
      structField = true,
      doc = "",
      documented = false,
      allowReturnNones = true)
  @Nullable
  FileT getSignedApk();

  @SkylarkCallable(
      name = "aar",
      structField = true,
      doc = "",
      documented = false,
      allowReturnNones = true)
  @Nullable
  FileT getAar();

  /** A list of the APKs related to the app under test, if any. */
  @SkylarkCallable(name = "apks_under_test", structField = true, doc = "", documented = false)
  ImmutableCollection<FileT> getApksUnderTest();

  /** A map, keyed on architecture, of the native libs for the app, if any. */
  @SkylarkCallable(name = "native_libs", structField = true, doc = "", documented = false)
  ImmutableMap<String, SkylarkNestedSet> getNativeLibsSkylark();

  /** The provider implementing this can construct the AndroidIdeInfo provider. */
  @SkylarkModule(name = "Provider", doc = "", documented = false)
  public interface Provider<FileT extends FileApi, OutputJarT extends OutputJarApi<FileT>>
      extends ProviderApi {

    @SkylarkCallable(
        name = NAME,
        doc = "The <code>AndroidIdeInfo</code> constructor.",
        parameters = {
          @Param(
              name = "java_package",
              doc = "A string of the Java package.",
              positional = true,
              named = false,
              type = String.class),
          @Param(
              name = "manifest",
              doc = "An artifact of the Android manifest.",
              positional = true,
              named = false,
              noneable = true,
              type = FileApi.class),
          @Param(
              name = "generated_manifest",
              doc = "An artifact of the generated Android manifest.",
              positional = true,
              named = false,
              noneable = true,
              type = FileApi.class),
          @Param(
              name = "idl_import_root",
              doc = "A string of the idl import root.",
              positional = true,
              named = false,
              type = String.class),
          @Param(
              name = "idl_srcs",
              doc = "A list of artifacts of the idl srcs.",
              positional = true,
              named = false,
              type = SkylarkList.class,
              generic1 = FileApi.class),
          @Param(
              name = "idl_generated_java_files",
              doc = "A list of artifacts of the idl generated java files.",
              positional = true,
              named = false,
              type = SkylarkList.class,
              generic1 = FileApi.class),
          @Param(
              name = "idl_source_jar",
              doc = "An artifact of the source Jar with the idl generated java files.",
              positional = true,
              named = false,
              noneable = true,
              type = FileApi.class),
          @Param(
              name = "idl_class_jar",
              doc = "An artifact of the class Jar with the compiled idl generated java files.",
              positional = true,
              named = false,
              noneable = true,
              type = FileApi.class),
          @Param(
              name = "defines_android_resources",
              doc = "A boolean if target specifies Android resources.",
              positional = true,
              named = false,
              type = Boolean.class),
          @Param(
              name = "resource_jar",
              doc = "An artifact of the Jar containing Android resources.",
              positional = true,
              named = false,
              noneable = true,
              type = OutputJarApi.class),
          @Param(
              name = "resource_apk",
              doc = "An artifact of the Apk containing Android resources.",
              positional = true,
              named = false,
              type = FileApi.class),
          @Param(
              name = "signed_apk",
              doc = "An artifact of the signed Apk.",
              positional = true,
              named = false,
              noneable = true,
              type = FileApi.class),
          @Param(
              name = "aar",
              doc = "An artifact of the Android archive.",
              positional = true,
              named = false,
              noneable = true,
              type = FileApi.class),
          @Param(
              name = "apks_under_test",
              doc = "A list of artifacts of the apks under test",
              positional = true,
              named = false,
              type = SkylarkList.class,
              generic1 = FileApi.class),
          @Param(
              name = "native_libs",
              doc =
                  "A dictionary of string to a list of artifacts mapping architectures to native "
                      + "libs.",
              positional = true,
              named = false,
              type = SkylarkDict.class,
              generic1 = String.class)
        },
        selfCall = true)
    @SkylarkConstructor(objectType = AndroidIdeInfoProviderApi.class)
    AndroidIdeInfoProviderApi<FileT, OutputJarT> createInfo(
        String javaPackage,
        /*noneable*/ Object manifest,
        /*noneable*/ Object generatedManifest,
        String idlImportRoot,
        SkylarkList<FileT> idlSrcs,
        SkylarkList<FileT> idlGeneratedJavaFiles,
        /*noneable*/ Object idlSourceJar,
        /*noneable*/ Object idlClassJar,
        boolean definesAndroidResources,
        /*noneable*/ Object resourceJar,
        FileT resourceApk,
        /*noneable*/ Object signedApk,
        /*noneable*/ Object aar,
        SkylarkList<FileT> apksUnderTest,
        SkylarkDict<String, SkylarkNestedSet> nativeLibs)
        throws EvalException;
  }
}