Got TGUI working on android with the latest SFML version again

0.8
Bruno Van de Velde 2018-07-28 11:27:48 +02:00
parent a8b8c319f0
commit 84dd5e9f90
7 changed files with 48 additions and 29 deletions

View File

@ -6,7 +6,23 @@ git:
matrix:
include:
- os: linux
- name: "Linux unit tests"
os: linux
env: COMPILER=g++-6
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6
- libudev-dev
- libxrandr-dev
cache:
directories:
- $HOME/SFML-2.5.0_LINUX
- name: "Linux"
os: linux
env: COMPILER=g++-4.9
addons:
apt:
@ -21,21 +37,23 @@ matrix:
directories:
- $HOME/SFML_LINUX
- os: linux
env: COMPILER=g++-6
- name: "Android"
language: android
env:
- ANDROID_NDK=$HOME/android-ndk-r17b
android:
components:
- android-23
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6
- libudev-dev
- libxrandr-dev
- ant
cache:
directories:
- $HOME/SFML-2.5.0_LINUX
- $ANDROID_NDK/sources/sfml
- os: osx
- name: "maxOS"
os: osx
cache:
directories:
- $HOME/SFML_OSX

View File

@ -170,7 +170,7 @@ endif()
if(TGUI_OS_WINDOWS AND TGUI_COMPILER_MSVC) # Also look for the main component when using Visual Studio
find_package(SFML 2 COMPONENTS main graphics window system)
elseif(TGUI_OS_ANDROID) # Search for SFML in the android NDK (if no other directory is specified)
find_package(SFML 2 COMPONENTS graphics window system PATHS "${CMAKE_ANDROID_NDK}/sources/third_party/sfml/lib/cmake/SFML")
find_package(SFML 2 COMPONENTS graphics window system PATHS "${CMAKE_ANDROID_NDK}/sources/third_party/sfml/lib/${CMAKE_ANDROID_ARCH_ABI}/cmake/SFML")
elseif(TGUI_OS_IOS) # Use the find_host_package macro from the toolchain on iOS
find_host_package(SFML 2 COMPONENTS main graphics window system)
else()

View File

@ -9,9 +9,9 @@ For more information, take a look at the [website](https://tgui.eu).
Status
------
| Linux | macOS | Windows | Test coverage |
|-------|-------|---------|---------------|
| [![Build Status](https://travis-matrix-badges.herokuapp.com/repos/texus/TGUI/branches/0.8-dev/2)](https://travis-ci.org/texus/TGUI) | [![Build Status](https://travis-matrix-badges.herokuapp.com/repos/texus/TGUI/branches/0.8-dev/3)](https://travis-ci.org/texus/TGUI) | [![Build status](https://ci.appveyor.com/api/projects/status/16e3yl71hq8x0c46/branch/0.8-dev?svg=true)](https://ci.appveyor.com/project/texus/tgui/branch/0.8-dev) | [![codecov](https://codecov.io/gh/texus/TGUI/branch/0.8-dev/graph/badge.svg)](https://codecov.io/gh/texus/TGUI/branch/0.8-dev) |
| Linux | macOS | Windows | Android | Test coverage |
|-------|-------|---------|---------|---------------|
| [![Build Status](https://travis-matrix-badges.herokuapp.com/repos/texus/TGUI/branches/0.8-dev/2)](https://travis-ci.org/texus/TGUI) | [![Build Status](https://travis-matrix-badges.herokuapp.com/repos/texus/TGUI/branches/0.8-dev/4)](https://travis-ci.org/texus/TGUI) | [![Build status](https://ci.appveyor.com/api/projects/status/16e3yl71hq8x0c46/branch/0.8-dev?svg=true)](https://ci.appveyor.com/project/texus/tgui/branch/0.8-dev) | [![Build Status](https://travis-matrix-badges.herokuapp.com/repos/texus/TGUI/branches/0.8-dev/3)](https://travis-ci.org/texus/TGUI) | [![codecov](https://codecov.io/gh/texus/TGUI/branch/0.8-dev/graph/badge.svg)](https://codecov.io/gh/texus/TGUI/branch/0.8-dev) |
Download

View File

@ -20,8 +20,8 @@
android:icon="@drawable/tgui_logo"
android:configChanges="keyboardHidden|orientation|screenSize">
<meta-data android:name="android.app.lib_name" android:value="sfml-activity" />
<meta-data android:name="sfml.app.lib_name" android:value="tgui-activity" />
<meta-data android:name="android.app.lib_name" android:value="sfml-activity-d" />
<meta-data android:name="sfml.app.lib_name" android:value="tgui-activity-d" />
<meta-data android:name="tgui.app.lib_name" android:value="tgui-example" />
<intent-filter>

View File

@ -6,13 +6,13 @@ LOCAL_MODULE := tgui-example
LOCAL_SRC_FILES := main.cpp
LOCAL_SHARED_LIBRARIES := sfml-system
LOCAL_SHARED_LIBRARIES += sfml-window
LOCAL_SHARED_LIBRARIES += sfml-graphics
LOCAL_SHARED_LIBRARIES += sfml-audio
LOCAL_SHARED_LIBRARIES += sfml-network
LOCAL_SHARED_LIBRARIES += tgui
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main
LOCAL_SHARED_LIBRARIES := sfml-system-d
LOCAL_SHARED_LIBRARIES += sfml-window-d
LOCAL_SHARED_LIBRARIES += sfml-graphics-d
LOCAL_SHARED_LIBRARIES += sfml-audio-d
LOCAL_SHARED_LIBRARIES += sfml-network-d
LOCAL_SHARED_LIBRARIES += tgui-d
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main-d
include $(BUILD_SHARED_LIBRARY)

View File

@ -1,6 +1,6 @@
NDK_TOOLCHAIN_VERSION := 4.9
APP_PLATFORM := android-19
APP_STL := c++_shared
APP_STL := c++_static
APP_ABI := x86
APP_MODULES := sfml-activity tgui-activity tgui-example
APP_CPPFLAGS += -fexceptions -frtti
APP_MODULES := sfml-activity-d tgui-activity-d tgui-example
APP_CPPFLAGS += -fexceptions -frtti -std=c++14

View File

@ -54,6 +54,7 @@
#include <dlfcn.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <jni.h>
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_INFO, "tgui-activity", __VA_ARGS__))
@ -81,7 +82,7 @@ const char* getLibraryName(JNIEnv* lJNIEnv, jobject& objectActivityInfo)
// Get the value of meta-data named "tgui.app.lib_name"
jclass classBundle = lJNIEnv->FindClass("android/os/Bundle");
jmethodID methodGetString = lJNIEnv->GetMethodID(classBundle, "getString", "(Ljava/lang/String;)Ljava/lang/String;");
jstring valueString = (jstring)lJNIEnv->CallObjectMethod(objectMetaData, methodGetString, objectName);
jstring valueString = static_cast<jstring>(lJNIEnv->CallObjectMethod(objectMetaData, methodGetString, objectName));
// No meta-data "tgui.app.lib_name" was found so we abort and inform the user
if (valueString == NULL)
@ -148,7 +149,7 @@ void* loadLibrary(const char* libraryName, JNIEnv* lJNIEnv, jobject& ObjectActiv
return handle;
}
void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize)
JNIEXPORT void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize)
{
// Before we can load a library, we need to find out its location. As
// we're powerless here in C/C++, we need the JNI interface to communicate
@ -209,7 +210,7 @@ void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_
// Call the original ANativeActivity_onCreate function
void* handle = loadLibrary(getLibraryName(lJNIEnv, ObjectActivityInfo), lJNIEnv, ObjectActivityInfo);
activityOnCreatePointer ANativeActivity_onCreate = (activityOnCreatePointer)dlsym(handle, "ANativeActivity_onCreate");
activityOnCreatePointer ANativeActivity_onCreate = reinterpret_cast<activityOnCreatePointer>(dlsym(handle, "ANativeActivity_onCreate"));
if (!ANativeActivity_onCreate)
{