1// Copyright 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package {
16    default_applicable_licenses: ["Android-Apache-2.0"],
17}
18
19java_library_host {
20    name: "tradefed-protos",
21    // Restrict visibility to only those targets that need to access it.
22    visibility: [
23        "//tools/tradefederation/core/clearcut_client",
24        "//tools/tradefederation/core/common_util",
25        "//tools/tradefederation/core/device_build_interfaces",
26        "//tools/tradefederation/core/invocation_interfaces",
27        "//tools/tradefederation/core/test_result_interfaces",
28    ],
29    srcs: ["proto/**/*.proto"],
30    exclude_srcs: [
31        "proto/virtual_device_manager.proto",
32        "proto/resultdb/*",
33    ],
34    libs: [
35        "libprotobuf-java-full",
36    ],
37    proto: {
38        include_dirs: ["external/protobuf/src"],
39        type: "full",
40    },
41    // b/267831518: Pin tradefed and dependencies to Java 11.
42    java_version: "11",
43}
44
45java_library_host {
46    name: "lab-resource-grpc",
47    srcs: [
48        "proto/monitoring/server/lab_resource.proto",
49    ],
50    proto: {
51        include_dirs: ["external/protobuf/src"],
52        plugin: "grpc-java-plugin",
53    },
54    libs: [
55        "tradefed-protos",
56        "grpc-java",
57        "guava",
58        "javax-annotation-api-prebuilt-host-jar",
59    ],
60    // b/267831518: Pin tradefed and dependencies to Java 11.
61    java_version: "11",
62}
63
64java_library_host {
65    name: "tradefed-service-grpc-lib",
66    visibility: [
67        "//tools/tradefederation/core",
68    ],
69    srcs: [
70        "proto/feature/tradefed_service.proto",
71    ],
72    proto: {
73        include_dirs: ["external/protobuf/src"],
74        plugin: "grpc-java-plugin",
75    },
76    libs: [
77        "tradefed-protos",
78    ],
79    static_libs: [
80        "grpc-java",
81        "guava",
82        "javax-annotation-api-prebuilt-host-jar",
83    ],
84    // b/267831518: Pin tradefed and dependencies to Java 11.
85    java_version: "11",
86}
87
88java_library_host {
89    name: "resultdb-protos",
90    srcs: ["proto/resultdb/*.proto"],
91    libs: [
92        "libprotobuf-java-full",
93        "googleapis-field-behavior-java-proto",
94    ],
95    proto: {
96        include_dirs: [
97            "external/protobuf/src",
98            "external/googleapis",
99        ],
100        type: "full",
101    },
102    java_version: "11",
103}
104
105java_library_host {
106    name: "tradefed-invocation-grpc",
107    srcs: [
108        "proto/invocation/invocation_manager.proto",
109    ],
110    proto: {
111        include_dirs: ["external/protobuf/src"],
112        plugin: "grpc-java-plugin",
113    },
114    libs: [
115        "tradefed-protos",
116        "grpc-java",
117        "guava",
118        "javax-annotation-api-prebuilt-host-jar",
119    ],
120    // b/267831518: Pin tradefed and dependencies to Java 11.
121    java_version: "11",
122}
123
124java_library_host {
125    name: "tradefed-device-manager-grpc",
126    srcs: [
127        "proto/device/device_manager.proto",
128    ],
129    proto: {
130        include_dirs: ["external/protobuf/src"],
131        plugin: "grpc-java-plugin",
132    },
133    libs: [
134        "tradefed-protos",
135        "grpc-java",
136        "guava",
137        "javax-annotation-api-prebuilt-host-jar",
138    ],
139    // b/267831518: Pin tradefed and dependencies to Java 11.
140    java_version: "11",
141}
142
143java_library_host {
144    name: "tradefed-dynamic-sharding-grpc",
145    srcs: ["proto/dynamicsharding.proto"],
146    proto: {
147        include_dirs: ["external/protobuf/src"],
148        plugin: "grpc-java-plugin",
149    },
150    libs: [
151        "tradefed-protos",
152        "grpc-java",
153        "guava",
154        "javax-annotation-api-prebuilt-host-jar",
155    ],
156    // b/267831518: Pin tradefed and dependencies to Java 11.
157    java_version: "11",
158}
159
160java_library_host {
161    name: "virtual-device-manager-proto",
162    srcs: ["proto/virtual_device_manager.proto"],
163    libs: [
164        "libprotobuf-java-full",
165    ],
166    proto: {
167        include_dirs: ["external/protobuf/src"],
168        type: "full",
169    },
170    // b/267831518: Pin tradefed and dependencies to Java 11.
171    java_version: "11",
172}
173
174java_library_host {
175    name: "virtual-device-manager-grpc",
176    srcs: ["proto/virtual_device_manager.proto"],
177    proto: {
178        include_dirs: ["external/protobuf/src"],
179        plugin: "grpc-java-plugin",
180    },
181    libs: [
182        "virtual-device-manager-proto",
183        "grpc-java",
184        "guava",
185        "javax-annotation-api-prebuilt-host-jar",
186    ],
187    // b/267831518: Pin tradefed and dependencies to Java 11.
188    java_version: "11",
189}
190
191// Avoid version number in apk file name
192java_genrule {
193    name: "test-services-normalized.apk",
194    srcs: [":test-services.apk"],
195    out: ["test-services-normalized.apk"],
196    cmd: "cp $(in) $(out)",
197}
198
199// Avoid version number in apk file name
200java_genrule {
201    name: "test-orchestrator-normalized.apk",
202    srcs: [":androidx.test.orchestrator"],
203    out: ["test-orchestrator-normalized.apk"],
204    cmd: "cp $(in) $(out)",
205}
206
207// Main Target to build tradefed jar
208tradefed_java_library_host {
209    name: "tradefed",
210    defaults: ["tradefed_defaults"],
211    java_resource_dirs: [
212        "res",
213    ],
214    device_common_java_resources: [
215        ":TradefedContentProvider",
216        ":TelephonyUtility",
217        ":WifiUtil",
218        ":test-services-normalized.apk",
219        ":test-orchestrator-normalized.apk",
220    ],
221    static_libs: [
222        "tradefed-lib-core",
223        "tradefed-test-framework",
224        "resultdb-protos",
225    ],
226    required: [
227        "loganalysis",
228    ],
229    manifest: "MANIFEST.mf",
230    // b/267831518: Pin tradefed and dependencies to Java 11.
231    java_version: "11",
232}
233
234// Tradefed build target without the test framework statically linked
235java_library_host {
236    name: "tradefed-no-fwk",
237    defaults: ["tradefed_defaults"],
238    java_resource_dirs: [
239        "res",
240    ],
241    static_libs: [
242        "tradefed-lib-core",
243    ],
244    libs: [
245        "tradefed-test-framework",
246    ],
247    manifest: "MANIFEST.mf",
248    // b/267831518: Pin tradefed and dependencies to Java 11.
249    java_version: "11",
250}
251
252java_library_host {
253    name: "tradefed-lib-core",
254    visibility: [
255        "//tools/tradefederation/core/test_framework",
256    ],
257    defaults: ["tradefed_defaults"],
258    srcs: [
259        "src/**/*.java",
260        "global_configuration/**/*.java",
261        "test_observatory/**/*.java",
262    ],
263    static_libs: [
264        "tradefed-avd-util",
265        "tradefed-common-util",
266        "tradefed-clearcut-client",
267        "tradefed-result-interfaces",
268        "tradefed-device-build-interfaces",
269        "tradefed-invocation-interfaces",
270        "tradefed-external-dependencies",
271        "tradefed-service-grpc-lib",
272        "lab-resource-grpc",
273        "virtual-device-manager-grpc",
274        "tradefed-invocation-grpc",
275        "tradefed-device-manager-grpc",
276        "tradefed-dynamic-sharding-grpc",
277        "aoa-helper",
278        "error_prone_annotations",
279        "google-api-java-client-assembly",
280        "auto_value_annotations",
281        "google-api-services-compute",
282        "google-api-services-storage",
283        "google-auth-library-credentials-1.23.0",
284        "google-auth-library-oauth2-http-1.23.0",
285        "google-http-client-jackson2-1.28.0",
286        "gson",
287        "jackson-core",
288        "jacoco-cli",
289        "jline",
290        "junit-params",
291        "kxml2-2.3.0",
292        "libprotobuf-java-full",
293        "libprotobuf-java-util-full",
294        // TODO(b/1859290570: Delete platform-test-annotations dep
295        "platform-test-annotations",
296        "snakeyaml",
297        "tf-remote-client",
298        "tradefed-protos",
299        "tradefed-isolation-protos",
300        "tradefed-lite",
301        "guava-testlib",
302        "grpc-java-testing",
303        "grpc-java-netty-shaded",
304        "opencensus-java-api",
305        "opencensus-java-contrib-grpc-metrics",
306    ],
307    libs: [
308        "loganalysis",
309    ],
310    // b/267831518: Pin tradefed and dependencies to Java 11.
311    java_version: "11",
312}
313
314// Turn off various doclava warnings when generating
315// the docs. These are the same warnings that are
316// turned off in frameworks/base, plus error 101
317// which is necessary here because tradefed is
318// referencing bootclasspath classes that are not
319// feed to metalava when generating the stubs.
320tradefed_docs_only_args = " -hide 101 -hide 111 -hide 113 -hide 125 -hide 126 -hide 127 -hide 128 "
321
322tradefed_doc_stubs_args = " --hide UnresolvedLink " +
323    "--hide HiddenSuperclass " +
324    "--hide DeprecationMismatch " +
325    "--hide RequiresPermission " +
326    "--hide BroadcastBehavior " +
327    "--hide SdkConstant " +
328    "--hide Todo " +
329    "--hide ReferencesHidden " +
330    "--hide HiddenTypeParameter "
331
332droidstubs_host {
333    name: "tradefed-doc-stubs",
334    srcs: [
335        // Keep in alphabetical order
336        "common_util/**/*.java",
337        "device_build_interfaces/**/*.java",
338        "global_configuration/**/*.java",
339        "invocation_interfaces/**/*.java",
340        "lite/**/*.java",
341        "remote/**/*.java",
342        "src/**/*.java",
343        "test_framework/**/*.java",
344        "test_result_interfaces/**/*.java",
345    ],
346    libs: [
347        "loganalysis",
348        "tradefed",
349    ],
350    args: tradefed_doc_stubs_args,
351    create_doc_stubs: true,
352}
353
354droiddoc_host {
355    name: "tradefed-docs",
356    srcs: [
357        ":tradefed-doc-stubs",
358    ],
359    libs: [
360        "error_prone_annotations",
361        "kotlin-annotations",
362        "loganalysis",
363        "tradefed",
364    ],
365    custom_template: "droiddoc-templates-sdk",
366    hdf: [
367        "sac true",
368        "devices true",
369        "android.whichdoc online",
370        "css.path /reference/assets/css/doclava-devsite.css",
371        "book.root toc",
372        "book.path /_book.yaml",
373    ],
374    args: tradefed_docs_only_args +
375        "-yaml _book.yaml " +
376        "-apidocsdir reference/tradefed/ " +
377        "-werror " +
378        "-devsite ",
379}
380
381sh_binary_host {
382    name: "tradefed.sh",
383    src: "tradefed.sh",
384}
385
386sh_binary_host {
387    name: "tradefed_win",
388    src: "tradefed_win.bat",
389}
390
391sh_binary_host {
392    name: "script_help.sh",
393    src: "script_help.sh",
394}
395
396sh_binary_host {
397    name: "run_tf_cmd.sh",
398    src: "run_tf_cmd.sh",
399}
400
401java_genrule_host {
402    name: "tradefed_zip",
403    tools: [
404        "atest_tradefed.sh",
405        "casuploader",
406        "content_uploader",
407        "soong_zip",
408    ],
409    srcs: [
410        ":compatibility-host-util",
411        ":compatibility-tradefed",
412        ":loganalysis",
413        ":tradefed",
414        ":tradefed-avd-util-tests",
415        ":tradefed-contrib",
416        ":tradefed-tests",
417        "script_help.sh",
418        "tools/content_uploader.py",
419        "tradefed.sh",
420    ],
421    device_common_srcs: [
422        ":TradeFedTestApp",
423        ":TradeFedUiTestApp",
424    ],
425    uses_order_only_build_number_file: true,
426    out: ["tradefed.zip"],
427    dist: {
428        targets: ["tradefed"],
429    },
430    cmd: "mkdir -p $(genDir)/tmp && " +
431        "cp -f $(in) $(location casuploader) $(location atest_tradefed.sh) $(location content_uploader) $(genDir)/tmp && " +
432        "cp $(build_number_file) $(genDir)/tmp/version.txt && " +
433        "$(location soong_zip) -o $(out) -C $(genDir)/tmp -D $(genDir)/tmp",
434}
435
436// Create a simple alias to build all the TF-related targets
437// Note that this is incompatible with `make dist`.  If you want to make
438// the distribution, you must run `tapas` with the individual target names.
439phony_rule {
440    name: "tradefed-core",
441    phony_deps: [
442        "tradefed",
443        "tradefed-contrib",
444        "tradefed-test-framework",
445        "atest_tradefed.sh",
446        "script_help.sh",
447        "tradefed.sh",
448    ],
449}
450
451phony_rule {
452    name: "tradefed-all",
453    phony_deps: [
454        "casuploader",
455        "compatibility-host-util",
456        "compatibility-tradefed",
457        "tradefed-avd-util-tests",
458        "tradefed-core",
459        "tradefed-tests",
460        "tradefed_win",
461    ],
462}
463