1// Copyright (C) 2023 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
15// We need this "trampoline" rule to force soong to give a host-side jar to
16// framework-minus-apex.ravenwood-base. Otherwise, soong would mix up the arch (?) and we'd get
17// a dex jar.
18java_library {
19    name: "framework-minus-apex-for-hoststubgen",
20    installable: false, // host only jar.
21    static_libs: [
22        "framework-minus-apex",
23    ],
24    sdk_version: "core_platform",
25    visibility: ["//visibility:private"],
26}
27
28// Generate the stub/impl from framework-all, with hidden APIs.
29java_genrule {
30    name: "framework-minus-apex.ravenwood-base",
31    tools: ["hoststubgen"],
32    cmd: "$(location hoststubgen) " +
33        "@$(location :ravenwood-standard-options) " +
34
35        "--debug-log $(location hoststubgen_framework-minus-apex.log) " +
36        "--stats-file $(location hoststubgen_framework-minus-apex_stats.csv) " +
37        "--supported-api-list-file $(location hoststubgen_framework-minus-apex_apis.csv) " +
38
39        "--out-impl-jar $(location ravenwood.jar) " +
40
41        "--gen-keep-all-file $(location hoststubgen_keep_all.txt) " +
42        "--gen-input-dump-file $(location hoststubgen_dump.txt) " +
43
44        "--in-jar $(location :framework-minus-apex-for-hoststubgen) " +
45        "--policy-override-file $(location :ravenwood-framework-policies) " +
46        "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) ",
47    srcs: [
48        ":framework-minus-apex-for-hoststubgen",
49        ":ravenwood-framework-policies",
50        ":ravenwood-standard-options",
51        ":ravenwood-annotation-allowed-classes",
52    ],
53    out: [
54        "ravenwood.jar",
55
56        // Following files are created just as FYI.
57        "hoststubgen_keep_all.txt",
58        "hoststubgen_dump.txt",
59
60        "hoststubgen_framework-minus-apex.log",
61        "hoststubgen_framework-minus-apex_stats.csv",
62        "hoststubgen_framework-minus-apex_apis.csv",
63    ],
64    visibility: ["//visibility:private"],
65}
66
67// Extract the impl jar from "framework-minus-apex.ravenwood-base" for subsequent build rules.
68// Note this emits a "device side" output, so that ravenwood tests can (implicitly)
69// depend on it.
70java_genrule {
71    name: "framework-minus-apex.ravenwood",
72    defaults: ["ravenwood-internal-only-visibility-genrule"],
73    cmd: "cp $(in) $(out)",
74    srcs: [
75        ":framework-minus-apex.ravenwood-base{ravenwood.jar}",
76    ],
77    out: [
78        "framework-minus-apex.ravenwood.jar",
79    ],
80}
81
82// Extract the stats file.
83genrule {
84    name: "framework-minus-apex.ravenwood.stats",
85    defaults: ["ravenwood-internal-only-visibility-genrule"],
86    cmd: "cp $(in) $(out)",
87    srcs: [
88        ":framework-minus-apex.ravenwood-base{hoststubgen_framework-minus-apex_stats.csv}",
89    ],
90    out: [
91        "hoststubgen_framework-minus-apex_stats.csv",
92    ],
93}
94
95genrule {
96    name: "framework-minus-apex.ravenwood.apis",
97    defaults: ["ravenwood-internal-only-visibility-genrule"],
98    cmd: "cp $(in) $(out)",
99    srcs: [
100        ":framework-minus-apex.ravenwood-base{hoststubgen_framework-minus-apex_apis.csv}",
101    ],
102    out: [
103        "hoststubgen_framework-minus-apex_apis.csv",
104    ],
105}
106
107genrule {
108    name: "framework-minus-apex.ravenwood.keep_all",
109    defaults: ["ravenwood-internal-only-visibility-genrule"],
110    cmd: "cp $(in) $(out)",
111    srcs: [
112        ":framework-minus-apex.ravenwood-base{hoststubgen_keep_all.txt}",
113    ],
114    out: [
115        "hoststubgen_framework-minus-apex_keep_all.txt",
116    ],
117}
118
119java_library {
120    name: "services.core-for-hoststubgen",
121    installable: false, // host only jar.
122    static_libs: [
123        "services.core",
124    ],
125    sdk_version: "core_platform",
126    visibility: ["//visibility:private"],
127}
128
129java_genrule {
130    name: "services.core.ravenwood-base",
131    tools: ["hoststubgen"],
132    cmd: "$(location hoststubgen) " +
133        "@$(location :ravenwood-standard-options) " +
134
135        "--debug-log $(location hoststubgen_services.core.log) " +
136        "--stats-file $(location hoststubgen_services.core_stats.csv) " +
137        "--supported-api-list-file $(location hoststubgen_services.core_apis.csv) " +
138
139        "--out-impl-jar $(location ravenwood.jar) " +
140
141        "--gen-keep-all-file $(location hoststubgen_keep_all.txt) " +
142        "--gen-input-dump-file $(location hoststubgen_dump.txt) " +
143
144        "--in-jar $(location :services.core-for-hoststubgen) " +
145        "--policy-override-file $(location :ravenwood-services-policies) " +
146        "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) ",
147    srcs: [
148        ":services.core-for-hoststubgen",
149        ":ravenwood-services-policies",
150        ":ravenwood-standard-options",
151        ":ravenwood-annotation-allowed-classes",
152    ],
153    out: [
154        "ravenwood.jar",
155
156        // Following files are created just as FYI.
157        "hoststubgen_keep_all.txt",
158        "hoststubgen_dump.txt",
159
160        "hoststubgen_services.core.log",
161        "hoststubgen_services.core_stats.csv",
162        "hoststubgen_services.core_apis.csv",
163    ],
164    visibility: ["//visibility:private"],
165}
166
167java_genrule {
168    name: "services.core.ravenwood",
169    defaults: ["ravenwood-internal-only-visibility-genrule"],
170    cmd: "cp $(in) $(out)",
171    srcs: [
172        ":services.core.ravenwood-base{ravenwood.jar}",
173    ],
174    out: [
175        "services.core.ravenwood.jar",
176    ],
177}
178
179// Extract the stats file.
180genrule {
181    name: "services.core.ravenwood.stats",
182    defaults: ["ravenwood-internal-only-visibility-genrule"],
183    cmd: "cp $(in) $(out)",
184    srcs: [
185        ":services.core.ravenwood-base{hoststubgen_services.core_stats.csv}",
186    ],
187    out: [
188        "hoststubgen_services.core_stats.csv",
189    ],
190}
191
192genrule {
193    name: "services.core.ravenwood.apis",
194    defaults: ["ravenwood-internal-only-visibility-genrule"],
195    cmd: "cp $(in) $(out)",
196    srcs: [
197        ":services.core.ravenwood-base{hoststubgen_services.core_apis.csv}",
198    ],
199    out: [
200        "hoststubgen_services.core_apis.csv",
201    ],
202}
203
204genrule {
205    name: "services.core.ravenwood.keep_all",
206    defaults: ["ravenwood-internal-only-visibility-genrule"],
207    cmd: "cp $(in) $(out)",
208    srcs: [
209        ":services.core.ravenwood-base{hoststubgen_keep_all.txt}",
210    ],
211    out: [
212        "hoststubgen_services.core_keep_all.txt",
213    ],
214}
215
216java_library {
217    name: "services.core.ravenwood-jarjar",
218    installable: false,
219    static_libs: [
220        "services.core.ravenwood",
221    ],
222    jarjar_rules: ":ravenwood-services-jarjar-rules",
223    visibility: ["//visibility:private"],
224}
225
226java_library {
227    name: "services.fakes.ravenwood-jarjar",
228    installable: false,
229    srcs: [":services.fakes-sources"],
230    libs: [
231        "ravenwood-framework",
232        "services.core.ravenwood",
233    ],
234    jarjar_rules: ":ravenwood-services-jarjar-rules",
235    visibility: ["//visibility:private"],
236}
237
238java_library {
239    name: "mockito-ravenwood-prebuilt",
240    installable: false,
241    static_libs: [
242        "mockito-robolectric-prebuilt",
243    ],
244}
245
246java_library {
247    name: "inline-mockito-ravenwood-prebuilt",
248    installable: false,
249    static_libs: [
250        "inline-mockito-robolectric-prebuilt",
251    ],
252}
253
254// Jars in "ravenwood-runtime" are set to the classpath, sorted alphabetically.
255// Rename some of the dependencies to make sure they're included in the intended order.
256java_genrule {
257    name: "100-framework-minus-apex.ravenwood",
258    cmd: "cp $(in) $(out)",
259    srcs: [":framework-minus-apex.ravenwood"],
260    out: ["100-framework-minus-apex.ravenwood.jar"],
261    visibility: ["//visibility:private"],
262}
263
264java_genrule {
265    // Use 200 to make sure it comes before the mainline stub ("all-updatable...").
266    name: "200-kxml2-android",
267    cmd: "cp $(in) $(out)",
268    srcs: [":kxml2-android"],
269    out: ["200-kxml2-android.jar"],
270    visibility: ["//visibility:private"],
271}
272
273java_genrule {
274    name: "z00-all-updatable-modules-system-stubs",
275    cmd: "cp $(in) $(out)",
276    srcs: [":all-updatable-modules-system-stubs"],
277    out: ["z00-all-updatable-modules-system-stubs.jar"],
278    visibility: ["//visibility:private"],
279}
280
281android_ravenwood_libgroup {
282    name: "ravenwood-runtime",
283    libs: [
284        "100-framework-minus-apex.ravenwood",
285        "200-kxml2-android",
286
287        "ravenwood-runtime-common-ravenwood",
288
289        "android.test.mock.ravenwood",
290        "ravenwood-helper-runtime",
291        "hoststubgen-helper-runtime.ravenwood",
292        "services.core.ravenwood-jarjar",
293        "services.fakes.ravenwood-jarjar",
294
295        // Provide runtime versions of utils linked in below
296        "junit",
297        "truth",
298        "flag-junit",
299        "ravenwood-framework",
300        "ravenwood-junit-impl",
301        "ravenwood-junit-impl-flag",
302        "mockito-ravenwood-prebuilt",
303        "inline-mockito-ravenwood-prebuilt",
304
305        // It's a stub, so it should be towards the end.
306        "z00-all-updatable-modules-system-stubs",
307    ],
308    jni_libs: [
309        "libandroid_runtime",
310        "libravenwood_runtime",
311    ],
312}
313
314android_ravenwood_libgroup {
315    name: "ravenwood-utils",
316    libs: [
317        "junit",
318        "truth",
319        "flag-junit",
320        "ravenwood-framework",
321        "ravenwood-junit",
322        "mockito-ravenwood-prebuilt",
323        "inline-mockito-ravenwood-prebuilt",
324    ],
325}
326