Browse Source

Platform: the Android app_dummy() workaround only got worse.

What to expect with Android, eh?!
pull/205/head
Vladimír Vondruš 8 years ago
parent
commit
97a39d7947
  1. 23
      src/Magnum/Platform/AndroidApplication.cpp
  2. 4
      src/Magnum/Platform/CMakeLists.txt

23
src/Magnum/Platform/AndroidApplication.cpp

@ -34,6 +34,10 @@
#include "Implementation/Egl.h"
/* This function would be stripped by the linker otherwise. Search for the name
below for the complete rant. */
extern "C" void ANativeActivity_onCreate(struct ANativeActivity*, void*, size_t);
namespace Magnum { namespace Platform {
struct AndroidApplication::LogOutput {
@ -155,10 +159,12 @@ void AndroidApplication::mouseMoveEvent(MouseMoveEvent&) {}
namespace {
struct Data {
Data(std::unique_ptr<AndroidApplication>(*instancer)(const AndroidApplication::Arguments&)): instancer(instancer) {}
Data(std::unique_ptr<AndroidApplication>(*instancer)(const AndroidApplication::Arguments&), void(*nativeActivity)(ANativeActivity*,void*,size_t)): instancer(instancer), nativeActivity{nativeActivity} {}
std::unique_ptr<AndroidApplication>(*instancer)(const AndroidApplication::Arguments&);
std::unique_ptr<AndroidApplication> instance;
void(*nativeActivity)(ANativeActivity*,void*,size_t);
};
}
@ -220,12 +226,17 @@ void AndroidApplication::exec(android_app* state, std::unique_ptr<AndroidApplica
state->onAppCmd = commandEvent;
state->onInputEvent = inputEvent;
/* Make sure the glue isn't stripped. WHY WHYYY CAN'T THIS BE DONE SOME
SANE WAY WHYY */
app_dummy();
/* Long time ago there was a call to app_dummy() that prevented stripping
the ANativeActivity_onCreate() symbol. It was awful enough on its own,
but they decided that it's no longer needed and the PROPER AND BETTER
SOLUTION is to pollute all downstream build scripts with
`-u ANativeActivity_onCreate` passed to linker. That's just fucking
awful. I can't use app_dummy() as it's deprecated, so I'm simply
retrieving the function pointer to the ANativeActivity_onCreate function
and saving it somewhere to convince the linker it's really needed. I
WANT TO SCREAM. https://github.com/android-ndk/ndk/issues/381 */
/** @todo Make use of saved state */
Data data{instancer};
Data data{instancer, ANativeActivity_onCreate};
state->userData = &data;
for(;;) {

4
src/Magnum/Platform/CMakeLists.txt

@ -75,10 +75,6 @@ if(WITH_ANDROIDAPPLICATION)
set_target_properties(MagnumAndroidApplicationGlue PROPERTIES
CORRADE_USE_PEDANTIC_FLAGS OFF
FOLDER "Magnum/Platform")
# They just don't care, so of course the ANativeActivity_onCreate()
# function is not exported and thus the app startup fails if I don't
# disable hidden visibility for the file.
target_compile_options(MagnumAndroidApplicationGlue PRIVATE "-fvisibility=default")
add_library(MagnumAndroidApplication STATIC
${MagnumAndroidApplication_SRCS}

Loading…
Cancel
Save