diff options
author | Eric Anholt <eric@anholt.net> | 2020-09-21 14:27:24 -0700 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2020-09-22 17:09:22 +0000 |
commit | 25b36d900acb0d3d923bd0b99a6d8443b4616c73 (patch) | |
tree | b4e1f3246b6cb743d3edf19bc3794abe22d71426 /src/android_stub | |
parent | 283686ad6762182037b708f1b5187129aff0a5dd (diff) | |
download | mesa-25b36d900acb0d3d923bd0b99a6d8443b4616c73.tar.gz |
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>
Diffstat (limited to 'src/android_stub')
-rw-r--r-- | src/android_stub/README.md | 5 | ||||
-rw-r--r-- | src/android_stub/android_stub.cpp | 54 | ||||
-rw-r--r-- | src/android_stub/backtrace_stub.cpp | 14 | ||||
-rw-r--r-- | src/android_stub/cutils_stub.cpp | 10 | ||||
-rw-r--r-- | src/android_stub/hardware_stub.cpp | 10 | ||||
-rw-r--r-- | src/android_stub/log_stub.cpp | 15 | ||||
-rw-r--r-- | src/android_stub/meson.build | 18 | ||||
-rw-r--r-- | src/android_stub/sync_stub.cpp | 20 |
8 files changed, 85 insertions, 61 deletions
diff --git a/src/android_stub/README.md b/src/android_stub/README.md new file mode 100644 index 00000000000..9c85e75c7a3 --- /dev/null +++ b/src/android_stub/README.md @@ -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. diff --git a/src/android_stub/android_stub.cpp b/src/android_stub/android_stub.cpp deleted file mode 100644 index f31e3cc0c37..00000000000 --- a/src/android_stub/android_stub.cpp +++ /dev/null @@ -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 ""; -} - diff --git a/src/android_stub/backtrace_stub.cpp b/src/android_stub/backtrace_stub.cpp new file mode 100644 index 00000000000..1b7f7efd644 --- /dev/null +++ b/src/android_stub/backtrace_stub.cpp @@ -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 ""; +} + diff --git a/src/android_stub/cutils_stub.cpp b/src/android_stub/cutils_stub.cpp new file mode 100644 index 00000000000..b660ec9d6d7 --- /dev/null +++ b/src/android_stub/cutils_stub.cpp @@ -0,0 +1,10 @@ +#include <cutils/properties.h> + +extern "C" { + +int property_get(const char* key, char* value, const char* default_value) +{ + return 0; +} + +} diff --git a/src/android_stub/hardware_stub.cpp b/src/android_stub/hardware_stub.cpp new file mode 100644 index 00000000000..4cb973fd2ac --- /dev/null +++ b/src/android_stub/hardware_stub.cpp @@ -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; +} + +} diff --git a/src/android_stub/log_stub.cpp b/src/android_stub/log_stub.cpp new file mode 100644 index 00000000000..29ba87b3748 --- /dev/null +++ b/src/android_stub/log_stub.cpp @@ -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; +} + +} diff --git a/src/android_stub/meson.build b/src/android_stub/meson.build index ad9abf50e03..a4dc349d28f 100644 --- a/src/android_stub/meson.build +++ b/src/android_stub/meson.build @@ -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 diff --git a/src/android_stub/sync_stub.cpp b/src/android_stub/sync_stub.cpp new file mode 100644 index 00000000000..963d928a47f --- /dev/null +++ b/src/android_stub/sync_stub.cpp @@ -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; +} + +} |