mesa: Make the android_stub be a set of non-installed shared libraries.

Previously, we included the stubs in our driver binaries, so they didn't
call the actual system libraries for these functions.  This was enough to
build-test the Android code in CI without even the NDK.

To make NDK-built Mesa drivers useful, we need to link against these
system libraries that aren't present in the NDK.  Split the symbols to
separate non-installed shared libraries and link against those, so that
when you drop the resulting .so in your /vendor/lib64/hw/, it just works
out.

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6805>
This commit is contained in:
Eric Anholt 2020-09-21 14:27:24 -07:00 committed by Marge Bot
parent 283686ad67
commit 25b36d900a
8 changed files with 85 additions and 61 deletions

View File

@ -0,0 +1,5 @@
The Android NDK doesn't come with enough of the platform libraries we
need to build Mesa drivers out of tree, so android_stub has stub
versions of those library that aren't installed which we link against,
relying on the real libraries to be present when the Mesa driver is
deployed.

View File

@ -1,54 +0,0 @@
#include <cutils/properties.h>
#include <sync/sync.h>
#include <hardware/hardware.h>
#include <android/log.h>
#include <backtrace/Backtrace.h>
extern "C" {
int property_get(const char* key, char* value, const char* default_value)
{
return 0;
}
/* timeout in msecs */
int sync_wait(int fd, int timeout)
{
return 0;
}
/* From hardware/hardware.h */
int hw_get_module(const char *id, const struct hw_module_t **module)
{
return 0;
}
/* From android/log.h */
int __android_log_print(int prio, const char* tag, const char* fmt, ...)
{
return 0;
}
int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap)
{
return 0;
}
}
/* From backtrace/Backtrace.h */
Backtrace*
Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map)
{
return NULL;
}
std::string
backtrace_map_t::Name() const
{
return "";
}

View File

@ -0,0 +1,14 @@
#include <backtrace/Backtrace.h>
Backtrace*
Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map)
{
return NULL;
}
std::string
backtrace_map_t::Name() const
{
return "";
}

View File

@ -0,0 +1,10 @@
#include <cutils/properties.h>
extern "C" {
int property_get(const char* key, char* value, const char* default_value)
{
return 0;
}
}

View File

@ -0,0 +1,10 @@
#include <hardware/hardware.h>
extern "C" {
int hw_get_module(const char *id, const struct hw_module_t **module)
{
return 0;
}
}

View File

@ -0,0 +1,15 @@
#include <android/log.h>
extern "C" {
int __android_log_print(int prio, const char* tag, const char* fmt, ...)
{
return 0;
}
int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap)
{
return 0;
}
}

View File

@ -1,12 +1,16 @@
if with_android_stub
_libmesa_android_stub = static_library(
'mesa_android_stub',
files('android_stub.cpp'),
include_directories : inc_include,
gnu_symbol_visibility : 'hidden',
)
stub_libs = []
foreach lib : ['backtrace', 'cutils', 'hardware', 'log', 'sync']
stub_libs += shared_library(
lib,
files(lib + '_stub.cpp'),
include_directories : inc_include,
install : false,
)
endforeach
dep_android = declare_dependency(
link_with : _libmesa_android_stub,
link_with : stub_libs,
)
endif

View File

@ -0,0 +1,20 @@
#include <cutils/properties.h>
#include <sync/sync.h>
#include <hardware/hardware.h>
#include <android/log.h>
#include <backtrace/Backtrace.h>
extern "C" {
/* timeout in msecs */
int sync_wait(int fd, int timeout)
{
return 0;
}
int sync_merge(const char *name, int fd, int fd2)
{
return 0;
}
}