Merge "Make libdvr a shared library" into oc-dev
am: 1ca4674b72
Change-Id: I4257eb8f7e0b3492b606fb4a96eeeeef2f76627c
diff --git a/libs/vr/libdvr/Android.bp b/libs/vr/libdvr/Android.bp
index 3876745..fa78b1c 100644
--- a/libs/vr/libdvr/Android.bp
+++ b/libs/vr/libdvr/Android.bp
@@ -19,47 +19,69 @@
export_include_dirs: ["include"],
}
-cc_library_static {
+cflags = [
+ "-DLOG_TAG=\"libdvr\"",
+]
+
+srcs = [
+ "dvr_api.cpp",
+ "dvr_buffer.cpp",
+ "dvr_buffer_queue.cpp",
+ "dvr_display_manager.cpp",
+ "dvr_hardware_composer_client.cpp",
+ "dvr_surface.cpp",
+ "dvr_vsync.cpp",
+]
+
+static_libs = [
+ "libbufferhub",
+ "libbufferhubqueue",
+ "libdisplay",
+ "libvrsensor",
+ "libvirtualtouchpadclient",
+ "libvr_hwc-impl",
+ "libvr_hwc-binder",
+ "libgrallocusage",
+ "libpdx_default_transport",
+]
+
+shared_libs = [
+ "android.hardware.graphics.bufferqueue@1.0",
+ "android.hidl.token@1.0-utils",
+ "libbase",
+ "libbinder",
+ "liblog",
+ "libcutils",
+ "libutils",
+ "libnativewindow",
+ "libgui",
+ "libui",
+]
+
+cc_library_shared {
name: "libdvr",
owner: "google",
-
- cflags: [
- "-fvisibility=hidden",
- "-DLOG_TAG=\"libdvr\"",
- "-DDVR_EXPORT=__attribute__((visibility(\"default\")))",
- ],
-
+ cflags: cflags,
header_libs: ["libdvr_headers"],
export_header_lib_headers: ["libdvr_headers"],
+ srcs: srcs,
+ static_libs: static_libs,
+ shared_libs: shared_libs,
+ version_script: "exported_apis.lds",
+}
- srcs: [
- "dvr_api.cpp",
- "dvr_buffer.cpp",
- "dvr_buffer_queue.cpp",
- "dvr_display_manager.cpp",
- "dvr_hardware_composer_client.cpp",
- "dvr_surface.cpp",
- "dvr_vsync.cpp",
- ],
-
- static_libs: [
- "libbufferhub",
- "libbufferhubqueue",
- "libdisplay",
- "libvrsensor",
- "libvirtualtouchpadclient",
- "libvr_hwc-impl",
- "libvr_hwc-binder",
- "libgrallocusage",
- ],
-
- shared_libs: [
- "android.hardware.graphics.bufferqueue@1.0",
- "android.hidl.token@1.0-utils",
- "libbase",
- "libnativewindow",
- ],
-
+// Also build a static libdvr for linking into tests. The linker script
+// restricting function access in the shared lib makes it inconvenient to use in
+// test code.
+cc_library_static {
+ name: "libdvr_static",
+ owner: "google",
+ cflags: cflags,
+ header_libs: ["libdvr_headers"],
+ export_header_lib_headers: ["libdvr_headers"],
+ srcs: srcs,
+ static_libs: static_libs,
+ shared_libs: shared_libs,
}
subdirs = [
diff --git a/libs/vr/libdvr/dvr_api.cpp b/libs/vr/libdvr/dvr_api.cpp
index 4d7e1a6..2c95583 100644
--- a/libs/vr/libdvr/dvr_api.cpp
+++ b/libs/vr/libdvr/dvr_api.cpp
@@ -18,7 +18,7 @@
extern "C" {
-DVR_EXPORT int dvrGetApi(void* api, size_t struct_size, int version) {
+int dvrGetApi(void* api, size_t struct_size, int version) {
ALOGI("dvrGetApi: api=%p struct_size=%zu version=%d", api, struct_size,
version);
if (version == 1) {
diff --git a/libs/vr/libdvr/exported_apis.lds b/libs/vr/libdvr/exported_apis.lds
new file mode 100644
index 0000000..5ecb498
--- /dev/null
+++ b/libs/vr/libdvr/exported_apis.lds
@@ -0,0 +1,9 @@
+{
+ global:
+ # Whitelist the function to load the dvr api.
+ dvrGetApi;
+
+ local:
+ # Hide everything else.
+ *;
+};
diff --git a/libs/vr/libdvr/tests/Android.bp b/libs/vr/libdvr/tests/Android.bp
index af202b4..ef746e2 100644
--- a/libs/vr/libdvr/tests/Android.bp
+++ b/libs/vr/libdvr/tests/Android.bp
@@ -25,7 +25,7 @@
]
static_libraries = [
- "libdvr",
+ "libdvr_static",
"libbufferhubqueue",
"libbufferhub",
"libchrome",