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}
11
12cc_defaults {
13    name: "libnativeloader-defaults",
14    defaults: ["art_defaults"],
15    header_libs: ["libnativeloader-headers"],
16    export_header_lib_headers: ["libnativeloader-headers"],
17}
18
19art_cc_library {
20    name: "libnativeloader",
21    defaults: ["libnativeloader-defaults"],
22    visibility: [
23        "//frameworks/base/cmds/app_process",
24        // TODO(b/133140750): Clean this up.
25        "//frameworks/base/native/webview/loader",
26    ],
27    apex_available: [
28        "com.android.art",
29        "com.android.art.debug",
30    ],
31    host_supported: true,
32    srcs: [
33        "native_loader.cpp",
34    ],
35    header_libs: [
36        "libnativehelper_header_only",
37    ],
38    shared_libs: [
39        "liblog",
40        "libnativebridge",
41        "libbase",
42    ],
43    target: {
44        // Library search path needed for running host tests remotely (from testcases directory).
45        linux_glibc_x86: {
46            ldflags: [
47                "-Wl,-rpath,$ORIGIN/../art_common/out/host/linux-x86/lib",
48                "-Wl,--enable-new-dtags",
49            ],
50        },
51        linux_glibc_x86_64: {
52            ldflags: [
53                "-Wl,-rpath,$ORIGIN/../art_common/out/host/linux-x86/lib64",
54                "-Wl,--enable-new-dtags",
55            ],
56        },
57        android: {
58            srcs: [
59                "library_namespaces.cpp",
60                "native_loader_namespace.cpp",
61                "public_libraries.cpp",
62            ],
63            shared_libs: [
64                "libdl_android",
65            ],
66            static_libs: [
67                "PlatformProperties",
68            ],
69        },
70    },
71    stubs: {
72        symbol_file: "libnativeloader.map.txt",
73        versions: ["1"],
74    },
75}
76
77// TODO(b/124250621) eliminate the need for this library
78cc_library {
79    name: "libnativeloader_lazy",
80    defaults: ["libnativeloader-defaults"],
81    visibility: [
82        "//frameworks/base/core/jni",
83        "//frameworks/native/opengl/libs",
84        "//frameworks/native/vulkan/libvulkan",
85    ],
86    apex_available: [
87        "//apex_available:platform",
88        "com.android.media",
89        "com.android.media.swcodec",
90    ],
91    host_supported: false,
92    srcs: ["native_loader_lazy.cpp"],
93    runtime_libs: ["libnativeloader"],
94    shared_libs: ["liblog"],
95}
96
97cc_library_headers {
98    name: "libnativeloader-headers",
99    apex_available: [
100        "//apex_available:platform",
101        "com.android.art",
102        "com.android.art.debug",
103        "com.android.media",
104    ],
105    min_sdk_version: "S",
106    visibility: [
107        "//art:__subpackages__",
108        // TODO(b/133140750): Clean this up.
109        "//frameworks/av/media/libstagefright",
110        "//frameworks/native/libs/graphicsenv",
111        "//frameworks/native/vulkan/libvulkan",
112    ],
113    host_supported: true,
114    export_include_dirs: ["include"],
115    header_libs: ["jni_headers"],
116    export_header_lib_headers: ["jni_headers"],
117}
118
119cc_defaults {
120    name: "libnativeloader-test-defaults",
121    defaults: [
122        "art_module_source_build_defaults",
123        "art_test_defaults",
124    ],
125    host_supported: false,
126
127    cflags: ["-DANDROID"],
128
129    // The tests mock libdl_android and libnativebridge symbols, so export them
130    // to override the ones loaded from their libs.
131    ldflags: [
132        "-Wl,--export-dynamic-symbol=android_*",
133        "-Wl,--export-dynamic-symbol=NativeBridge*",
134    ],
135
136    header_libs: [
137        "libnativebridge-headers",
138        "libnativehelper_header_only",
139    ],
140    static_libs: [
141        "libgmock",
142    ],
143    shared_libs: [
144        "libbase",
145    ],
146
147    test_suites: ["device-tests"],
148}
149
150art_cc_test {
151    name: "libnativeloader_test",
152    defaults: ["libnativeloader-test-defaults"],
153    srcs: [
154        "native_loader_api_test.c",
155        "native_loader_test.cpp",
156    ],
157    shared_libs: [
158        "libnativeloader",
159    ],
160}
161
162art_cc_test {
163    name: "libnativeloader_lazy_test",
164    defaults: ["libnativeloader-test-defaults"],
165    srcs: [
166        "native_loader_lazy_test.cpp",
167    ],
168    static_libs: [
169        "libnativeloader_lazy",
170    ],
171}
172