xref: /aosp_15_r20/art/tools/veridex/Android.bp (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1// Copyright (C) 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    // See: http://go/android-license-faq
17    // A large-scale-change added 'default_applicable_licenses' to import
18    // all of the 'license_kinds' from "art_license"
19    // to get the below license kinds:
20    //   SPDX-license-identifier-Apache-2.0
21    default_applicable_licenses: ["art_license"],
22}
23
24cc_binary {
25    name: "veridex",
26    defaults: ["art_defaults"],
27    host_supported: true,
28    srcs: [
29        "flow_analysis.cc",
30        "hidden_api.cc",
31        "hidden_api_finder.cc",
32        "precise_hidden_api_finder.cc",
33        "resolver.cc",
34        "veridex.cc",
35    ],
36    cflags: [
37        "-Wall",
38        "-Werror",
39    ],
40    static_libs: [
41        "libdexfile",
42        "libartbase",
43        "libartpalette",
44        "libbase",
45        "liblog",
46        "libz",
47        "libziparchive",
48    ],
49    stl: "libc++_static",
50    header_libs: [
51        "art_libartbase_headers",
52    ],
53    target: {
54        darwin: {
55            enabled: true,
56        },
57    },
58}
59
60// Expose the appcompat.sh script for use by the build.
61sh_binary_host {
62    name: "veridex-appcompat",
63    src: "appcompat.sh",
64    filename_from_src: true,
65}
66
67genrule {
68    name: "system_stub_dex_d8_input_jar",
69    visibility: ["//visibility:private"],
70    srcs: [":system_android_jar"],
71    tools: ["zip2zip"],
72    out: ["system_stub_dex_d8_input.jar"],
73    cmd: "$(location zip2zip) " +
74        "-j -i $(in) " +
75        "-o $(out) \"**/*.class\" ",
76}
77
78genrule {
79    name: "system_stub_dex",
80    visibility: ["//visibility:private"],
81    srcs: [":system_stub_dex_d8_input_jar"],
82    tools: ["d8"],
83    out: [
84        "dex_dir/classes.dex",
85        "dex_dir/classes2.dex",
86    ],
87    cmd: "mkdir -p $(genDir)/dex_dir &&" +
88        "$(location d8) " +
89        "-JXmx4096M -JXX:+TieredCompilation -JXX:TieredStopAtLevel=1 " +
90        "-JDcom.android.tools.r8.emitRecordAnnotationsInDex " +
91        "-JDcom.android.tools.r8.emitPermittedSubclassesAnnotationsInDex " +
92        "-JXX:OnError=\"cat hs_err_pid%p.log\" " +
93        "-JXX:CICompilerCount=6 -JXX:+UseDynamicNumberOfGCThreads " +
94        "--output $(genDir)/dex_dir " +
95        "--min-api 1000 " +
96        "$(in)",
97}
98
99genrule {
100    name: "public_oahl_stub_dex_d8_input_jar",
101    visibility: ["//visibility:private"],
102    srcs: [":public.org.apache.http.legacy.jar"],
103    tools: ["zip2zip"],
104    out: ["oahl_stub_dex_d8_input.jar"],
105    cmd: "$(location zip2zip) " +
106        "-j -i $(in) " +
107        "-o $(out) \"**/*.class\" ",
108}
109
110genrule {
111    name: "oahl_stub_dex",
112    visibility: ["//visibility:private"],
113    srcs: [":public_oahl_stub_dex_d8_input_jar"],
114    tools: ["d8"],
115    out: [
116        "dex_dir/classes.dex",
117    ],
118    cmd: "mkdir -p $(genDir)/dex_dir &&" +
119        "$(location d8) " +
120        "-JXmx4096M -JXX:+TieredCompilation -JXX:TieredStopAtLevel=1 " +
121        "-JDcom.android.tools.r8.emitRecordAnnotationsInDex " +
122        "-JDcom.android.tools.r8.emitPermittedSubclassesAnnotationsInDex " +
123        "-JXX:OnError=\"cat hs_err_pid%p.log\" " +
124        "-JXX:CICompilerCount=6 -JXX:+UseDynamicNumberOfGCThreads " +
125        "--output $(genDir)/dex_dir " +
126        "--min-api 1000 " +
127        "$(in)",
128}
129
130genrule {
131    name: "org.apache.http.legacy-stubs.zip",
132    visibility: ["//visibility:private"],
133    srcs: [":oahl_stub_dex"],
134    tools: ["soong_zip"],
135    out: ["org.apache.http.legacy-stubs.zip"],
136    cmd: "mkdir -p $(genDir)/tmp &&" +
137        "ls -1 $(locations :oahl_stub_dex) | sort > $(genDir)/tmp/org.apache.http.legacy-stubs.zip.list && " +
138        "$(locations soong_zip) -o $(genDir)/org.apache.http.legacy-stubs.zip " +
139        " -j -l $(genDir)/tmp/org.apache.http.legacy-stubs.zip.list",
140}
141
142genrule {
143    name: "system-stubs.zip",
144    visibility: ["//visibility:private"],
145    srcs: [":system_stub_dex"],
146    tools: ["soong_zip"],
147    out: ["system-stubs.zip"],
148    cmd: "mkdir -p $(genDir)/tmp &&" +
149        "ls -1 $(locations :system_stub_dex) | sort > $(genDir)/tmp/system-stubs.zip.list && " +
150        "$(locations soong_zip) -o $(genDir)/system-stubs.zip" +
151        " -j -l $(genDir)/tmp/system-stubs.zip.list",
152}
153
154python_binary_host {
155    name: "appcompat",
156    srcs: ["appcompat.py"],
157    data: [
158        ":veridex",
159        ":org.apache.http.legacy-stubs.zip",
160        ":system-stubs.zip",
161    ],
162    device_common_data: [
163        ":platform-bootclasspath{hiddenapi-flags.csv}",
164    ],
165}
166
167// TODO: Remove `veridex_zip` and `appcompat.sh` after migrating
168//       `GtsUnofficialApisUsageTestCases` and `GtsNetUnofficialApisUsageTestCases` to use appcompat.
169java_genrule {
170    name: "veridex_zip",
171    srcs: [
172        "appcompat.sh",
173        ":platform-bootclasspath{hiddenapi-flags.csv}",
174        ":org.apache.http.legacy-stubs.zip",
175        ":system-stubs.zip",
176    ],
177    tools: [
178        "soong_zip",
179        "veridex",
180    ],
181    out: ["veridex.zip"],
182    cmd: "mkdir -p $(genDir)/tmp &&" +
183        "$(locations soong_zip) -o $(out)" +
184        " -C `dirname $(location appcompat.sh)` -f $(location appcompat.sh)" +
185        " -C `dirname $(location :platform-bootclasspath{hiddenapi-flags.csv})` -f $(location :platform-bootclasspath{hiddenapi-flags.csv})" +
186        " -C `dirname $(location veridex)` -f $(location veridex)" +
187        " -C `dirname $(location :org.apache.http.legacy-stubs.zip)` -f $(location :org.apache.http.legacy-stubs.zip)" +
188        " -C `dirname $(location :system-stubs.zip)` -f $(location :system-stubs.zip)",
189    visibility: ["//visibility:public"],
190}
191