Skip to content

Commit 25b36d9

Browse files
anholtMarge Bot
authored and
Marge Bot
committedSep 22, 2020
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 <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6805>
1 parent 283686a commit 25b36d9

8 files changed

+85
-61
lines changed
 

‎src/android_stub/README.md

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

‎src/android_stub/android_stub.cpp

-54
This file was deleted.

‎src/android_stub/backtrace_stub.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <backtrace/Backtrace.h>
2+
3+
Backtrace*
4+
Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map)
5+
{
6+
return NULL;
7+
}
8+
9+
std::string
10+
backtrace_map_t::Name() const
11+
{
12+
return "";
13+
}
14+

‎src/android_stub/cutils_stub.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <cutils/properties.h>
2+
3+
extern "C" {
4+
5+
int property_get(const char* key, char* value, const char* default_value)
6+
{
7+
return 0;
8+
}
9+
10+
}

‎src/android_stub/hardware_stub.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <hardware/hardware.h>
2+
3+
extern "C" {
4+
5+
int hw_get_module(const char *id, const struct hw_module_t **module)
6+
{
7+
return 0;
8+
}
9+
10+
}

‎src/android_stub/log_stub.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <android/log.h>
2+
3+
extern "C" {
4+
5+
int __android_log_print(int prio, const char* tag, const char* fmt, ...)
6+
{
7+
return 0;
8+
}
9+
10+
int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap)
11+
{
12+
return 0;
13+
}
14+
15+
}

‎src/android_stub/meson.build

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
if with_android_stub
2-
_libmesa_android_stub = static_library(
3-
'mesa_android_stub',
4-
files('android_stub.cpp'),
5-
include_directories : inc_include,
6-
gnu_symbol_visibility : 'hidden',
7-
)
2+
stub_libs = []
3+
4+
foreach lib : ['backtrace', 'cutils', 'hardware', 'log', 'sync']
5+
stub_libs += shared_library(
6+
lib,
7+
files(lib + '_stub.cpp'),
8+
include_directories : inc_include,
9+
install : false,
10+
)
11+
endforeach
812

913
dep_android = declare_dependency(
10-
link_with : _libmesa_android_stub,
14+
link_with : stub_libs,
1115
)
1216
endif

‎src/android_stub/sync_stub.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <cutils/properties.h>
2+
#include <sync/sync.h>
3+
#include <hardware/hardware.h>
4+
#include <android/log.h>
5+
#include <backtrace/Backtrace.h>
6+
7+
extern "C" {
8+
9+
/* timeout in msecs */
10+
int sync_wait(int fd, int timeout)
11+
{
12+
return 0;
13+
}
14+
15+
int sync_merge(const char *name, int fd, int fd2)
16+
{
17+
return 0;
18+
}
19+
20+
}

0 commit comments

Comments
 (0)