1//
2// Copyright (C) 2020 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17package {
18    // See: http://go/android-license-faq
19    // A large-scale-change added 'default_applicable_licenses' to import
20    // all of the 'license_kinds' from "art_license"
21    // to get the below license kinds:
22    //   SPDX-license-identifier-Apache-2.0
23    default_applicable_licenses: ["art_license"],
24}
25
26cc_defaults {
27    name: "odrefresh-defaults",
28    host_supported: true,
29    defaults: ["art_defaults"],
30    srcs: [
31        "odrefresh.cc",
32        "odr_compilation_log.cc",
33        "odr_fs_utils.cc",
34        "odr_metrics.cc",
35        "odr_metrics_record.cc",
36    ],
37    local_include_dirs: ["include"],
38    header_libs: ["dexoptanalyzer_headers"],
39    generated_sources: [
40        "apex-info-list",
41        "art-apex-cache-info",
42        "art-odrefresh-operator-srcs",
43    ],
44    shared_libs: [
45        "libartpalette",
46        "libbase",
47        "libdexfile",
48        "liblog",
49    ],
50    static_libs: ["libxml2"],
51    target: {
52        android: {
53            compile_multilib: "first",
54        },
55        host: {
56            shared_libs: [
57                // Both these libraries for libxml2 on host for code derived from apex-info-list.
58                "libicui18n",
59                "libicuuc",
60            ],
61        },
62    },
63    tidy: true,
64    tidy_flags: [
65        "-format-style=file",
66        "-header-filter=(art/odrefresh/|system/apex/)",
67    ],
68}
69
70cc_library_headers {
71    name: "odrefresh_headers",
72    export_include_dirs: ["include"],
73    host_supported: true,
74    stl: "none",
75    system_shared_libs: [],
76    min_sdk_version: "29", // As part of mainline modules(APEX), it should support at least 29(Q).
77    sdk_version: "minimum", // The minimum sdk version required by users of this module.
78    apex_available: [
79        "//apex_available:platform", // For odsign.
80    ],
81    visibility: ["//visibility:public"],
82}
83
84gensrcs {
85    name: "art-odrefresh-operator-srcs",
86    cmd: "$(location generate_operator_out) art/odrefresh $(in) > $(out)",
87    tools: ["generate_operator_out"],
88    srcs: [
89        "odr_metrics.h",
90    ],
91    output_extension: "operator_out.cc",
92}
93
94art_cc_binary {
95    name: "odrefresh",
96    defaults: ["odrefresh-defaults"],
97    required: [
98        "dexoptanalyzer",
99        "dex2oat",
100    ],
101    shared_libs: [
102        "libart",
103        "libartbase",
104    ],
105    apex_available: [
106        "com.android.art",
107        "com.android.art.debug",
108    ],
109}
110
111art_cc_binary {
112    name: "odrefreshd",
113    defaults: [
114        "art_debug_defaults",
115        "odrefresh-defaults",
116    ],
117    required: [
118        "dexoptanalyzerd",
119        "dex2oatd",
120    ],
121    shared_libs: [
122        "libartd",
123        "libartbased",
124    ],
125    apex_available: [
126        "com.android.art.debug",
127        // TODO(b/183882457): This binary doesn't go into com.android.art, but
128        // apex_available lists need to be the same for internal libs to avoid
129        // stubs, and this depends on libartd.
130        "com.android.art",
131    ],
132}
133
134cc_library_static {
135    name: "libodrstatslog",
136    defaults: ["art_defaults"],
137    host_supported: true,
138    export_include_dirs: ["include"],
139
140    local_include_dirs: ["include"],
141    shared_libs: ["libartbase"],
142    target: {
143        android: {
144            generated_headers: ["statslog_odrefresh.h"],
145            generated_sources: ["statslog_odrefresh.cpp"],
146            srcs: [
147                "odr_metrics_record.cc",
148                "odr_statslog_android.cc",
149            ],
150            shared_libs: ["libstatssocket"],
151        },
152        host: {
153            srcs: ["odr_statslog_host.cc"],
154        },
155    },
156    apex_available: [
157        "com.android.art",
158        "com.android.art.debug",
159    ],
160}
161
162art_cc_defaults {
163    name: "art_odrefresh_tests_defaults",
164    generated_sources: ["art-odrefresh-operator-srcs"],
165    header_libs: ["odrefresh_headers"],
166    srcs: [
167        "odr_artifacts_test.cc",
168        "odr_compilation_log.cc",
169        "odr_compilation_log_test.cc",
170        "odr_fs_utils.cc",
171        "odr_fs_utils_test.cc",
172        "odr_metrics.cc",
173        "odr_metrics_test.cc",
174        "odr_metrics_record.cc",
175        "odr_metrics_record_test.cc",
176        "odrefresh_test.cc",
177    ],
178    shared_libs: ["libbase"],
179}
180
181// Version of ART gtest `art_odrefresh_tests` bundled with the ART APEX on target.
182// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete.
183art_cc_test {
184    name: "art_odrefresh_tests",
185    defaults: [
186        "art_gtest_defaults",
187        "art_odrefresh_tests_defaults",
188    ],
189}
190
191// Standalone version of ART gtest `art_odrefresh_tests`, not bundled with the ART APEX on target.
192art_cc_test {
193    name: "art_standalone_odrefresh_tests",
194    defaults: [
195        "art_standalone_gtest_defaults",
196        "art_odrefresh_tests_defaults",
197    ],
198}
199
200genrule {
201    name: "statslog_odrefresh.h",
202    tools: ["stats-log-api-gen"],
203    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_odrefresh.h --module art --namespace art,metrics,statsd",
204    out: [
205        "statslog_odrefresh.h",
206    ],
207}
208
209genrule {
210    name: "statslog_odrefresh.cpp",
211    tools: ["stats-log-api-gen"],
212    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_odrefresh.cpp --module art --namespace art,metrics,statsd --importHeader statslog_odrefresh.h",
213    out: [
214        "statslog_odrefresh.cpp",
215    ],
216}
217
218xsd_config {
219    name: "art-apex-cache-info",
220    srcs: ["CacheInfo.xsd"],
221    package_name: "com.android.art",
222    api_dir: "schema",
223    gen_writer: true,
224}
225