[Mesa-dev] [PATCH 1/4] gbm: Add Android build support

Rob Herring robh at kernel.org
Fri Apr 22 15:50:15 UTC 2016


Add libgbm to the Android build. GBM needs the same special
gallium_dri.so loading copied over from the EGL code.

Signed-off-by: Rob Herring <robh at kernel.org>
---
 Android.mk                     |  1 +
 src/gbm/Android.mk             | 51 ++++++++++++++++++++++++++++++++++++++++++
 src/gbm/Makefile.am            | 10 ++-------
 src/gbm/Makefile.sources       | 12 ++++++++++
 src/gbm/backends/dri/gbm_dri.c |  9 ++++++++
 5 files changed, 75 insertions(+), 8 deletions(-)
 create mode 100644 src/gbm/Android.mk
 create mode 100644 src/gbm/Makefile.sources

diff --git a/Android.mk b/Android.mk
index 99a0ad1..63a4184 100644
--- a/Android.mk
+++ b/Android.mk
@@ -93,6 +93,7 @@ SUBDIRS := src/gallium
 endif
 
 SUBDIRS += \
+	src/gbm \
 	src/loader \
 	src/mapi \
 	src/compiler \
diff --git a/src/gbm/Android.mk b/src/gbm/Android.mk
new file mode 100644
index 0000000..ad3de21
--- /dev/null
+++ b/src/gbm/Android.mk
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2016 Linaro, Ltd., Rob Herring <robh at kernel.org>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(LOCAL_PATH)/Makefile.sources
+
+include $(CLEAR_VARS)
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
+	$(LOCAL_PATH)/main
+
+LOCAL_C_INCLUDES := \
+	$(LOCAL_PATH)/main
+
+ifeq ($(MESA_LOLLIPOP_BUILD),true)
+LOCAL_CFLAGS_32 := -DDEFAULT_DRIVER_DIR=\"/system/lib/$(MESA_DRI_MODULE_REL_PATH)\"
+LOCAL_CFLAGS_64 := -DDEFAULT_DRIVER_DIR=\"/system/lib64/$(MESA_DRI_MODULE_REL_PATH)\"
+else
+LOCAL_CFLAGS += -DDEFAULT_DRIVER_DIR=\"/system/lib/$(MESA_DRI_MODULE_REL_PATH)\"
+endif
+
+LOCAL_SHARED_LIBRARIES := libdrm
+LOCAL_STATIC_LIBRARIES := libmesa_loader
+LOCAL_MODULE := libgbm
+
+LOCAL_SRC_FILES := \
+	$(gbm_core_FILES) \
+	$(gbm_dri_FILES)
+
+include $(MESA_COMMON_MK)
+include $(BUILD_SHARED_LIBRARY)
diff --git a/src/gbm/Makefile.am b/src/gbm/Makefile.am
index 9a584ca..68dc8f2 100644
--- a/src/gbm/Makefile.am
+++ b/src/gbm/Makefile.am
@@ -15,12 +15,7 @@ lib_LTLIBRARIES = libgbm.la
 include_HEADERS = main/gbm.h
 
 libgbm_la_SOURCES = \
-	main/backend.c \
-	main/backend.h \
-	main/common_drm.h \
-	main/gbm.c \
-	main/gbm.h \
-	main/gbmint.h
+	$(gbm_core_FILES)
 
 libgbm_la_LDFLAGS = \
 	-no-undefined \
@@ -40,8 +35,7 @@ endif
 
 if HAVE_DRI2
 libgbm_la_SOURCES += \
-	backends/dri/gbm_dri.c \
-	backends/dri/gbm_driint.h
+	$(gbm_dri_FILES)
 
 AM_CFLAGS += \
 	-DDEFAULT_DRIVER_DIR='"$(DRI_DRIVER_SEARCH_DIR)"' \
diff --git a/src/gbm/Makefile.sources b/src/gbm/Makefile.sources
new file mode 100644
index 0000000..acb3536
--- /dev/null
+++ b/src/gbm/Makefile.sources
@@ -0,0 +1,12 @@
+
+gbm_core_FILES = \
+	main/backend.c \
+	main/backend.h \
+	main/common_drm.h \
+	main/gbm.c \
+	main/gbm.h \
+	main/gbmint.h
+
+gbm_dri_FILES = \
+	backends/dri/gbm_dri.c \
+	backends/dri/gbm_driint.h
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 236f2ae..0625422 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -341,6 +341,15 @@ dri_open_driver(struct gbm_dri_device *dri)
       /* not need continue to loop all paths once the driver is found */
       if (dri->driver != NULL)
          break;
+
+#ifdef ANDROID
+      snprintf(path, sizeof path, "%.*s/gallium_dri.so", len, p);
+      dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
+      if (dri->driver == NULL)
+         sprintf("failed to open %s: %s\n", path, dlerror());
+      else
+         break;
+#endif
    }
 
    if (dri->driver == NULL) {
-- 
2.7.4



More information about the mesa-dev mailing list