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