1// Shared library for target
2// ========================================================
3package {
4    // See: http://go/android-license-faq
5    // A large-scale-change added 'default_applicable_licenses' to import
6    // all of the 'license_kinds' from "art_license"
7    // to get the below license kinds:
8    //   SPDX-license-identifier-Apache-2.0
9    default_applicable_licenses: ["art_license"],
10    default_team: "trendy_team_art_mainline",
11}
12
13cc_library_headers {
14    name: "libnativeloader-headers",
15    defaults: ["art_defaults"],
16    apex_available: [
17        "//apex_available:platform",
18        "com.android.art",
19        "com.android.art.debug",
20        "com.android.media",
21    ],
22    visibility: [
23        "//art:__subpackages__",
24        // TODO(b/133140750): Clean this up.
25        "//frameworks/av/media/libstagefright",
26        "//frameworks/native/libs/graphicsenv",
27        "//frameworks/native/vulkan/libvulkan",
28    ],
29    host_supported: true,
30    export_include_dirs: ["include"],
31    header_libs: ["jni_headers"],
32    export_header_lib_headers: ["jni_headers"],
33}
34
35cc_defaults {
36    name: "libnativeloader-defaults",
37    defaults: ["art_defaults"],
38    header_libs: ["libnativeloader-headers"],
39    export_header_lib_headers: ["libnativeloader-headers"],
40}
41
42art_cc_library {
43    name: "libnativeloader",
44    defaults: ["libnativeloader-defaults"],
45    visibility: [
46        "//frameworks/base/cmds/app_process",
47        // TODO(b/133140750): Clean this up.
48        "//frameworks/base/native/webview/loader",
49    ],
50    apex_available: [
51        "com.android.art",
52        "com.android.art.debug",
53        "test_broken_com.android.art",
54    ],
55    host_supported: true,
56    srcs: [
57        "native_loader.cpp",
58    ],
59    header_libs: [
60        "art_libartbase_headers",
61        "libnativehelper_header_only",
62    ],
63    shared_libs: [
64        "liblog",
65        "libnativebridge",
66        "libbase",
67    ],
68    target: {
69        android: {
70            srcs: [
71                "library_namespaces.cpp",
72                "native_loader_namespace.cpp",
73                "public_libraries.cpp",
74            ],
75            shared_libs: [
76                "libdl_android",
77            ],
78            static_libs: [
79                "libPlatformProperties",
80                "libmodules-utils-build",
81            ],
82        },
83    },
84    stubs: {
85        symbol_file: "libnativeloader.map.txt",
86        versions: ["1"],
87    },
88}
89
90// Wrapper that loads nativeloader.so lazily, to be used to deal with layer
91// inversion in places like in early boot where libnativeloader and/or
92// libnativebridge aren't available.
93// TODO(b/124250621) eliminate the need for this library
94cc_library {
95    name: "libnativeloader_lazy",
96    defaults: ["libnativeloader-defaults"],
97    visibility: [
98        "//frameworks/base/core/jni",
99        "//frameworks/native/opengl/libs",
100        "//frameworks/native/vulkan/libvulkan",
101    ],
102    apex_available: [
103        "//apex_available:platform",
104        "com.android.media",
105        "com.android.media.swcodec",
106    ],
107    host_supported: false,
108    srcs: ["native_loader_lazy.cpp"],
109    runtime_libs: ["libnativeloader"],
110    shared_libs: ["liblog"],
111}
112
113art_cc_test {
114    name: "libnativeloader_test",
115    defaults: [
116        // Cannot use art_standalone_gtest_defaults because it makes us link
117        // libnativebridge statically through libart-gtest, but we need to mock
118        // its symbols here.
119        "art_standalone_test_defaults",
120    ],
121    host_supported: false,
122
123    // Ordinarily, symbols are only exported if they are referenced by some
124    // shared object dependency. Instead, export everything using
125    // --export-dynamic, then restrict the visibility using the version script.
126    ldflags: ["-Wl,--export-dynamic"],
127    version_script: "libnativeloader_test.map",
128
129    header_libs: [
130        "libnativebridge-headers",
131        "libnativehelper_header_only",
132    ],
133    shared_libs: [
134        "liblog", // libbase dependency
135        "libnativeloader",
136    ],
137    static_libs: [
138        "libbase",
139        "libgmock",
140    ],
141
142    tidy_timeout_srcs: [
143        "native_loader_test.cpp",
144    ],
145    srcs: [
146        "library_namespaces_test.cpp",
147        "native_loader_api_test.c",
148        "native_loader_test.cpp",
149    ],
150
151    test_for: [
152        "com.android.art",
153        "com.android.art.debug",
154    ],
155    test_suites: [
156        "general-tests",
157        "mts-art",
158    ],
159}
160
161cc_defaults {
162    name: "libnativeloader_api_test_defaults",
163    defaults: ["art_standalone_test_defaults"],
164
165    srcs: ["native_loader_api_test.cpp"],
166    header_libs: [
167        "libnativebridge-headers",
168        "libnativehelper_header_only",
169    ],
170    static_libs: [
171        "libbase",
172        "libgmock",
173    ],
174}
175
176art_cc_test {
177    name: "art_libnativeloader_cts_test",
178    defaults: ["libnativeloader_api_test_defaults"],
179    shared_libs: [
180        "libnativeloader",
181    ],
182    test_config_template: ":art-gtests-target-standalone-cts-template",
183    test_suites: [
184        "cts",
185        "mcts-art",
186    ],
187}
188
189art_cc_test {
190    name: "libnativeloader_lazy_test",
191    defaults: ["libnativeloader_api_test_defaults"],
192    static_libs: [
193        "libnativeloader_lazy",
194    ],
195    test_suites: [
196        "general-tests",
197        "mts-art",
198    ],
199}
200