1//
2// Copyright (C) 2019 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: "libartpalette_defaults",
28    defaults: ["art_defaults"],
29    host_supported: true,
30    export_include_dirs: ["include"],
31}
32
33cc_library_headers {
34    name: "libartpalette-headers",
35    export_include_dirs: ["include"],
36    host_supported: true,
37    visibility: [
38        "//art:__subpackages__",
39        "//system/libartpalette",
40    ],
41}
42
43// libartpalette is the dynamic loader of the platform abstraction
44// layer. It is only used on Android. For other targets, it just
45// implements a fake platform implementation.
46art_cc_library {
47    name: "libartpalette",
48    defaults: ["libartpalette_defaults"],
49    visibility: [
50        // TODO(b/183483755): Please visibility checks when the prebuilt
51        // libartpalette is present but not preferred, and the prebuilt
52        // libdexfile hence depends on the source instead.
53        // TODO(b/172480617): Alternatively, clean up when we no longer need to
54        // support both prebuilts and sources present simultaneously.
55        "//prebuilts/module_sdk/art/current/host-exports",
56    ],
57    header_libs: [
58        "libbase_headers",
59        "jni_headers",
60    ],
61    target: {
62        // Targets supporting dlopen build the client library which loads
63        // and binds the methods in the libartpalette-system library.
64        android: {
65            // libartpalette.so dlopen()'s libartpalette-system.
66            runtime_libs: ["libartpalette-system"],
67            srcs: ["apex/palette.cc"],
68            shared_libs: ["liblog"],
69            version_script: "libartpalette.map.txt",
70        },
71        linux_bionic: {
72            header_libs: ["libbase_headers"],
73            srcs: ["system/palette_fake.cc"],
74            shared: {
75                shared_libs: [
76                    "libbase",
77                    "liblog",
78                ],
79            },
80            version_script: "libartpalette.map.txt",
81        },
82        linux_glibc: {
83            header_libs: ["libbase_headers"],
84            srcs: ["system/palette_fake.cc"],
85            shared: {
86                shared_libs: [
87                    "libbase",
88                    "liblog",
89                ],
90            },
91            version_script: "libartpalette.map.txt",
92        },
93        // Targets without support for dlopen just use the sources for
94        // the system library which actually implements functionality.
95        darwin: {
96            enabled: true,
97            header_libs: ["libbase_headers"],
98            srcs: ["system/palette_fake.cc"],
99            static_libs: [
100                "libbase",
101                "liblog",
102            ],
103        },
104        windows: {
105            enabled: true,
106            header_libs: ["libbase_headers"],
107            srcs: ["system/palette_fake.cc"],
108            static_libs: [
109                "libbase",
110                "liblog",
111            ],
112        },
113    },
114    apex_available: [
115        "com.android.art",
116        "com.android.art.debug",
117        // TODO(b/142944931): remove this
118        "com.android.runtime", // due to the transitive dependency from linker
119    ],
120}
121
122art_cc_defaults {
123    name: "art_libartpalette_tests_defaults",
124    srcs: ["apex/palette_test.cc"],
125    shared_libs: ["libartpalette"],
126}
127
128// Version of ART gtest `art_libartpalette_tests` bundled with the ART APEX on target.
129// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete.
130art_cc_test {
131    name: "art_libartpalette_tests",
132    defaults: [
133        "art_gtest_defaults",
134        "art_libartpalette_tests_defaults",
135    ],
136    host_supported: true,
137}
138
139// Standalone version of ART gtest `art_libartpalette_tests`, not bundled with the ART APEX on
140// target.
141art_cc_test {
142    name: "art_standalone_libartpalette_tests",
143    defaults: [
144        "art_standalone_gtest_defaults",
145        "art_libartpalette_tests_defaults",
146    ],
147}
148