xref: /aosp_15_r20/cts/hostsidetests/compilation/Android.bp (revision b7c941bb3fa97aba169d73cee0bed2de8ac964bf)
1// Copyright (C) 2016 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    default_team: "trendy_team_art_mainline",
18}
19
20java_defaults {
21    name: "CompilationTestCases_defaults",
22    srcs: ["src/**/*.java"],
23    data: [
24        ":apksigner",
25        ":cts-compilation-testkey-files",
26    ],
27    device_common_data: [
28        ":StatusCheckerApp",
29    ],
30    java_resource_dirs: ["assets/"],
31    device_common_java_resources: [
32        ":AppUsedByOtherApp",
33        ":AppUsedByOtherApp_1_disable_embedded_profile_dm",
34        ":AppUsedByOtherApp_1_dm",
35        ":AppUsedByOtherApp_2_prof",
36        ":AppUsingOtherApp",
37        ":CompilationTestCases-package-dex-usage",
38        ":CtsCompilationApp",
39        ":CtsCompilationApp_profile",
40        ":CtsCompilationApp_dm",
41        ":CtsCompilationApp_with_bad_profile",
42        ":CtsCompilationApp_with_good_profile",
43        ":CtsCompilationApp_debuggable",
44        ":disable_embedded_profile_dm",
45        ":empty_config_dm",
46    ],
47    libs: [
48        "cts-tradefed",
49        "tradefed",
50        "compatibility-host-util",
51        "guava",
52        "truth",
53    ],
54    static_libs: [
55        "android.content.pm.flags-aconfig-java-host",
56        "art-aconfig-flags-java-lib-host",
57        "flag-junit-host",
58    ],
59}
60
61java_test_host {
62    name: "CtsCompilationTestCases",
63    defaults: ["CompilationTestCases_defaults"],
64    // tag this module as a cts test artifact
65    test_suites: [
66        "cts",
67        "general-tests",
68    ],
69    test_config: "CtsCompilationTestCases.xml",
70}
71
72java_test_host {
73    name: "CompilationTestCases",
74    defaults: ["CompilationTestCases_defaults"],
75    test_suites: [
76        "general-tests",
77    ],
78    test_config: "CompilationTestCases.xml",
79}
80
81// Generates a binary profile from a text profile for an APK.
82// The first input must be the text profile.
83// The second input must be the APK.
84genrule_defaults {
85    name: "profile_defaults",
86    tools: ["profman"],
87    cmd: "inputs=($(in)) && " +
88        "$(location profman) " +
89        "--create-profile-from=$${inputs[0]} " +
90        "--apk=$${inputs[1]} " +
91        "--dex-location=base.apk " +
92        "--reference-profile-file=$(out)",
93}
94
95sh_binary {
96    name: "generate_dm",
97    host_supported: true,
98    src: "scripts/generate_dm.sh",
99}
100
101// Generates a DM file.
102// Each input must be a binary profile or a config file in binary protobuf
103// format.
104genrule_defaults {
105    name: "dm_defaults",
106    tools: [
107        "generate_dm",
108        "soong_zip",
109    ],
110    cmd: "$(location generate_dm) $(location soong_zip) $(out) $(in)",
111}
112
113java_genrule {
114    name: "CtsCompilationApp_profile",
115    defaults: ["profile_defaults"],
116    srcs: [
117        "assets/primary.prof.txt",
118        ":CtsCompilationApp",
119    ],
120    out: ["CtsCompilationApp.prof"],
121}
122
123java_genrule {
124    name: "CtsCompilationApp_dm",
125    defaults: ["dm_defaults"],
126    srcs: [
127        ":CtsCompilationApp_profile",
128    ],
129    out: ["CtsCompilationApp.dm"],
130}
131
132java_genrule {
133    name: "AppUsedByOtherApp_1_prof",
134    defaults: ["profile_defaults"],
135    srcs: [
136        "assets/app_used_by_other_app_1.prof.txt",
137        ":AppUsedByOtherApp",
138    ],
139    out: ["AppUsedByOtherApp_1.prof"],
140}
141
142java_genrule {
143    name: "AppUsedByOtherApp_1_dm",
144    defaults: ["dm_defaults"],
145    srcs: [
146        ":AppUsedByOtherApp_1_prof",
147    ],
148    out: ["AppUsedByOtherApp_1.dm"],
149}
150
151java_genrule {
152    name: "AppUsedByOtherApp_2_prof",
153    defaults: ["profile_defaults"],
154    srcs: [
155        "assets/app_used_by_other_app_2.prof.txt",
156        ":AppUsedByOtherApp",
157    ],
158    out: ["AppUsedByOtherApp_2.prof"],
159}
160
161genrule {
162    name: "CompilationTestCases-package-dex-usage",
163    srcs: [
164        ":libartservice_protos",
165        "assets/package-dex-usage.textproto",
166    ],
167    tools: ["aprotoc"],
168    cmd: "$(location aprotoc) " +
169        "--encode=com.android.server.art.proto.DexUseProto " +
170        "$(locations :libartservice_protos) " +
171        "< $(location assets/package-dex-usage.textproto) > $(out)",
172    out: ["package-dex-usage.pb"],
173}
174
175genrule {
176    name: "CompilationTestCases-config-empty",
177    srcs: [
178        ":libartservice_protos",
179    ],
180    tools: ["aprotoc"],
181    cmd: "$(location aprotoc) " +
182        "--encode=com.android.server.art.proto.DexMetadataConfig " +
183        "$(locations :libartservice_protos) " +
184        "<<<'' > $(out)",
185    out: ["config-empty.pb"],
186}
187
188genrule {
189    name: "empty_config_dm",
190    defaults: ["dm_defaults"],
191    srcs: [
192        ":CompilationTestCases-config-empty",
193    ],
194    out: ["empty_config.dm"],
195}
196
197genrule {
198    name: "CompilationTestCases-config-disable_embedded_profile",
199    srcs: [
200        ":libartservice_protos",
201    ],
202    tools: ["aprotoc"],
203    cmd: "$(location aprotoc) " +
204        "--encode=com.android.server.art.proto.DexMetadataConfig " +
205        "$(locations :libartservice_protos) " +
206        "<<<'enable_embedded_profile: false' > $(out)",
207    out: ["config-disable_embedded_profile.pb"],
208}
209
210genrule {
211    name: "disable_embedded_profile_dm",
212    defaults: ["dm_defaults"],
213    srcs: [
214        ":CompilationTestCases-config-disable_embedded_profile",
215    ],
216    out: ["disable_embedded_profile.dm"],
217}
218
219java_genrule {
220    name: "AppUsedByOtherApp_1_disable_embedded_profile_dm",
221    defaults: ["dm_defaults"],
222    srcs: [
223        ":AppUsedByOtherApp_1_prof",
224        ":CompilationTestCases-config-disable_embedded_profile",
225    ],
226    out: ["AppUsedByOtherApp_1_disable_embedded_profile.dm"],
227}
228