ANDROID3D: Get it working again (#2529)

This commit is contained in:
Cameron Cawley 2020-10-15 08:59:11 +01:00 committed by GitHub
parent 9fb035b10a
commit 3e7948cf6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 139 additions and 162 deletions

View File

@ -229,6 +229,11 @@ MODULE_OBJS += \
mutex/pthread/pthread-mutex.o
endif
ifeq ($(BACKEND),android3d)
MODULE_OBJS += \
mutex/pthread/pthread-mutex.o
endif
ifeq ($(BACKEND),androidsdl)
MODULE_OBJS += \
events/androidsdl/androidsdl-events.o

View File

@ -400,7 +400,7 @@ bool OSystem_Android::hasFeature(Feature f) {
f == kFeatureTouchpadMode ||
f == kFeatureOnScreenControl ||
f == kFeatureClipboardSupport ||
f == kFeatureOpenGL ||
f == kFeatureOpenGLForGame ||
f == kFeatureOverlaySupportsAlpha ||
f == kFeatureClipboardSupport) {
return true;

View File

@ -1,88 +1,88 @@
# Android specific build targets
# These must be incremented for each market upload
ANDROID_VERSIONCODE ?= 50000
ANDROID_VERSIONNAME ?= 0.4
PATH_DIST = $(srcdir)/dists/android3d
PORT_DISTFILES = $(PATH_DIST)/README.Android
DIST_ANDROID_CONTROLS = $(PATH_DIST)/assets/arrows.tga
GRADLE = $(PATH_DIST)/gradlew
GRADLE_FILES = $(shell find $(PATH_DIST)/gradle -type f) $(PATH_DIST)/gradlew $(PATH_DIST)/build.gradle
PATH_BUILD = ./android3d
PATH_BUILD = ./android_project
PATH_BUILD_GRADLE = $(PATH_BUILD)/build.gradle
PATH_BUILD_ASSETS = $(PATH_BUILD)/assets
PATH_BUILD_JNI = $(PATH_BUILD)/jni/$(ABI)/libresidualvm.so
PATH_BUILD_GRADLE = $(PATH_BUILD)/settings.gradle
PATH_BUILD_SETUPAPK = $(PATH_BUILD)/.setupapk
PATH_BUILD_LIB = $(PATH_BUILD)/lib/$(ABI)
PATH_BUILD_LIBSCUMMVM = $(PATH_BUILD)/lib/$(ABI)/libscummvm.so
APK_MAIN = $(PATH_BUILD)/build/outputs/apk/debug/ResidualVM-debug.apk
APK_MAIN_RELEASE = $(PATH_BUILD)/build/outputs/apk/release/ResidualVM-release$(if $(KEYSTORE),,-unsigned).apk
APK_MAIN = ResidualVM-debug.apk
APK_MAIN_RELEASE = ResidualVM-release-unsigned.apk
$(PATH_BUILD_ASSETS): $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_SHADERS) $(DIST_ANDROID_CONTROLS) | $(PATH_BUILD)
$(PATH_BUILD):
$(MKDIR) $(PATH_BUILD)
$(PATH_BUILD_GRADLE): $(GRADLE_FILES) | $(PATH_BUILD)
$(CP) -r $(PATH_DIST)/gradle/ $(PATH_BUILD)/gradle/
$(INSTALL) -c -m 755 $(PATH_DIST)/gradlew $(PATH_BUILD)
$(INSTALL) -c -m 644 $(PATH_DIST)/build.gradle $(PATH_BUILD)
$(ECHO) "srcdir=$(realpath $(srcdir))\n" > $(PATH_BUILD)/gradle.properties
$(ECHO) "org.gradle.jvmargs=-Xmx4096m\n" >> $(PATH_BUILD)/gradle.properties
# $(ECHO) "android.useAndroidX=true\n" >> $(PATH_BUILD)/gradle.properties
# $(ECHO) "android.enableJetifier=true\n" >> $(PATH_BUILD)/gradle.properties
$(ECHO) "sdk.dir=$(realpath $(ANDROID_SDK_ROOT))\n" > $(PATH_BUILD)/local.properties
$(ECHO) "ndk.dir=$(realpath $(ANDROID_NDK_ROOT))\n" >> $(PATH_BUILD)/local.properties
$(PATH_BUILD_ASSETS): $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_NETWORKING) $(DIST_FILES_VKEYBD) $(DIST_FILES_DOCS) $(DIST_ANDROID_CONTROLS) $(PORT_DISTFILES) | $(PATH_BUILD)
$(INSTALL) -d $(PATH_BUILD_ASSETS)
$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_ANDROID_CONTROLS) $(PATH_BUILD_ASSETS)/
ifdef USE_OPENGL_SHADERS
$(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_NETWORKING) $(DIST_FILES_VKEYBD) $(DIST_FILES_DOCS) $(DIST_ANDROID_CONTROLS) $(PORT_DISTFILES) $(PATH_BUILD_ASSETS)/
ifneq ($(DIST_FILES_SHADERS),)
$(INSTALL) -d $(PATH_BUILD_ASSETS)/shaders
$(INSTALL) -c -m 644 $(DIST_FILES_SHADERS) $(PATH_BUILD_ASSETS)/shaders
endif
$(PATH_BUILD):
$(INSTALL) -d $(PATH_BUILD_ASSETS)
$(PATH_BUILD_LIBSCUMMVM): libscummvm.so | $(PATH_BUILD)
$(INSTALL) -d $(PATH_BUILD_LIB)
$(INSTALL) -c -m 644 libscummvm.so $(PATH_BUILD_LIBSCUMMVM)
$(PATH_BUILD_JNI): libresidualvm.so
$(INSTALL) -d $(dir $(PATH_BUILD_JNI))
$(INSTALL) -C -m 644 libresidualvm.so $(PATH_BUILD_JNI)
$(APK_MAIN): $(PATH_BUILD_GRADLE) $(PATH_BUILD_ASSETS) $(PATH_BUILD_LIBSCUMMVM) | $(PATH_BUILD)
(cd $(PATH_BUILD); ./gradlew assembleDebug)
$(CP) $(PATH_BUILD)/build/outputs/apk/debug/ResidualVM-debug.apk $@
$(PATH_BUILD_GRADLE): $(PATH_BUILD_ASSETS) $(PATH_DIST)/build.gradle
$(eval ABIS = $(notdir $(wildcard $(PATH_BUILD)/jni/*)))
@echo "gradle.ext.versionCode = $(ANDROID_VERSIONCODE)" > $@
@echo "gradle.ext.versionName = '$(ANDROID_VERSIONNAME)'" >> $@
@echo "gradle.ext.sourceDir = '$(abspath $(srcdir))'" >> $@
@echo "gradle.ext.buildDir = '$(CURDIR)'" >> $@
@echo "gradle.ext.androidAbi = '$(ABIS)'" >> $@
@echo "include ':ResidualVM'" >> $@
@echo "project(':ResidualVM').projectDir = new File('$(abspath $(PATH_DIST))')" >> $@
@echo "ndk.dir=$(ANDROID_NDK)" > $(PATH_BUILD)/local.properties
@echo "sdk.dir=$(ANDROID_SDK)" >> $(PATH_BUILD)/local.properties
$(PATH_BUILD_SETUPAPK): $(PATH_BUILD_ASSETS) $(PATH_BUILD_JNI) $(PATH_BUILD_GRADLE) | $(PATH_BUILD)
touch $(PATH_BUILD_SETUPAPK)
$(APK_MAIN): $(PATH_BUILD_SETUPAPK) libresidualvm.so
$(GRADLE) assembleDebug -p "$(PATH_BUILD)" && touch $@
$(APK_MAIN_RELEASE): $(PATH_BUILD_SETUPAPK) libresidualvm.so
$(GRADLE) assembleRelease -p "$(PATH_BUILD)" && touch $@
$(APK_MAIN_RELEASE): $(PATH_BUILD_GRADLE) $(PATH_BUILD_ASSETS) $(PATH_BUILD_LIBSCUMMVM) | $(PATH_BUILD)
(cd $(PATH_BUILD); ./gradlew build)
$(CP) $(PATH_BUILD)/build/outputs/apk/release/ResidualVM-release-unsigned.apk $@
all: $(APK_MAIN)
clean: androidclean
androidclean:
@$(RM) -rf $(PATH_BUILD)
@$(RM) -rf $(PATH_BUILD) *.apk
androiddebug: $(APK_MAIN)
androidrelease: $(APK_MAIN_RELEASE)
androidtestmain: $(APK_MAIN)
$(GRADLE) installDebug -p "$(PATH_BUILD)"
$(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.residualvm.residualvm/.Unpacker
(cd $(PATH_BUILD); ./gradlew installDebug)
# $(ADB) install -g -r $(APK_MAIN)
# $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.residualvm.residualvm/.ResidualVMActivity
androidtest: $(APK_MAIN) $(APK_PLUGINS)
@set -e; for apk in $^; do \
$(ADB) install -r $$apk; \
done
$(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.residualvm.residualvm/.Unpacker
androidtest: $(APK_MAIN)
# @set -e; for apk in $^; do \
# $(ADB) install -g -r $$apk; \
# done
# $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.residualvm.residualvm/.ResidualVMActivity
(cd $(PATH_BUILD); ./gradlew installDebug)
# used by buildbot!
androiddistdebug: all
$(MKDIR) debug
$(CP) $(APK_MAIN) $(APK_PLUGINS) debug/
$(CP) $(APK_MAIN) debug/
for i in $(DIST_FILES_DOCS) $(PORT_DISTFILES); do \
sed 's/$$/\r/' < $$i > debug/`basename $$i`.txt; \
done
.PHONY: androidrelease androidtest
androiddistrelease: androidrelease
$(MKDIR) release
$(CP) $(APK_MAIN_RELEASE) release/
for i in $(DIST_FILES_DOCS) $(PORT_DISTFILES); do \
sed 's/$$/\r/' < $$i > release/`basename $$i`.txt; \
done
.PHONY: androidrelease androidtest $(PATH_BUILD_SRC)

View File

@ -15,6 +15,7 @@ import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.LinkedHashMap;
import java.util.List;
@ -57,13 +58,14 @@ public abstract class ResidualVM implements SurfaceHolder.Callback, Runnable {
abstract protected void displayMessageOnOSD(String msg);
abstract protected void openUrl(String url);
abstract protected boolean hasTextInClipboard();
abstract protected byte[] getTextFromClipboard();
abstract protected boolean setTextInClipboard(byte[] text);
abstract protected String getTextFromClipboard();
abstract protected boolean setTextInClipboard(String text);
abstract protected boolean isConnectionLimited();
abstract protected void setWindowCaption(String caption);
abstract protected void showVirtualKeyboard(boolean enable);
abstract protected void showKeyboardControl(boolean enable);
abstract protected String[] getSysArchives();
abstract protected byte[] convertEncoding(String to, String from, byte[] string) throws UnsupportedEncodingException;
abstract protected String[] getAllStorageLocations();
public ResidualVM(AssetManager asset_manager, SurfaceHolder holder) {
@ -461,6 +463,6 @@ public abstract class ResidualVM implements SurfaceHolder.Callback, Runnable {
}
}
System.loadLibrary("residualvm");
System.loadLibrary("scummvm");
}
}

View File

@ -35,6 +35,7 @@ import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Arrays;
import java.util.HashSet;
@ -171,33 +172,17 @@ public class ResidualVMActivity extends Activity {
}
@Override
protected byte[] getTextFromClipboard() {
protected String getTextFromClipboard() {
CharSequence text = _clipboard.getText();
if (text != null) {
String encoding = getCurrentCharset();
byte[] out;
Log.d(LOG_TAG, String.format("Converting from UTF-8 to %s", encoding));
try {
out = text.toString().getBytes(encoding);
} catch (java.io.UnsupportedEncodingException e) {
out = text.toString().getBytes();
}
return out;
return text.toString();
}
return null;
}
@Override
protected boolean setTextInClipboard(byte[] text) {
String encoding = getCurrentCharset();
String out;
Log.d(LOG_TAG, String.format("Converting from %s to UTF-8", encoding));
try {
out = new String(text, encoding);
} catch (java.io.UnsupportedEncodingException e) {
out = new String(text);
}
_clipboard.setText(out);
protected boolean setTextInClipboard(String text) {
_clipboard.setText(text);
return true;
}
@ -243,6 +228,12 @@ public class ResidualVMActivity extends Activity {
return new String[0];
}
@Override
protected byte[] convertEncoding(String to, String from, byte[] string) throws UnsupportedEncodingException {
String str = new String(string, from);
return str.getBytes(to);
}
@Override
protected String[] getAllStorageLocations() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
@ -322,7 +313,7 @@ public class ResidualVMActivity extends Activity {
"ResidualVM",
"--config=" + getFileStreamPath("residualvmrc").getPath(),
"--path=" + Environment.getExternalStorageDirectory().getPath(),
"--gui-theme=modern",
"--gui-theme=residualvm",
"--savepath=" + savePath
});

18
configure vendored
View File

@ -3251,8 +3251,10 @@ if test -n "$_host"; then
append_var LDFLAGS "-static-libstdc++"
HOSTEXEPRE=lib
HOSTEXEEXT=.so
_backend="android"
_port_mk="backends/platform/android/android.mk"
if test "$_backend" != android3d; then
_backend="android"
fi
_port_mk="backends/platform/$_backend/android.mk"
_build_scalers=no
_seq_midi=no
_timidity=no
@ -3652,10 +3654,10 @@ fi
case $_backend in
3ds)
;;
android)
android | android3d)
append_var DEFINES "-DREDUCE_MEMORY_USAGE"
append_var DEFINES "-DNONSTANDARD_PORT"
append_var INCLUDES '-I$(srcdir)/backends/platform/android'
append_var INCLUDES '-I$(srcdir)/backends/platform/'$_backend
append_var CXXFLAGS "-Wa,--noexecstack"
append_var LDFLAGS "-Wl,-z,noexecstack"
# removed the following directive - was causing compilation issues when not also explicitly using --disable-mt32emu
@ -3924,7 +3926,7 @@ fi
# Enable 16bit support only for backends which support it
#
case $_backend in
3ds | android | androidsdl | dingux | dc | gph | iphone | ios7 | maemo | null | openpandora | psp | psp2 | samsungtv | sdl | switch | wii)
3ds | android | android3d | androidsdl | dingux | dc | gph | iphone | ios7 | maemo | null | openpandora | psp | psp2 | samsungtv | sdl | switch | wii)
if test "$_16bit" = auto ; then
_16bit=yes
else
@ -5382,9 +5384,9 @@ define_in_config_if_yes "$_glew" "USE_GLEW"
#
echocheck "OpenGL for game"
if test "$_opengl_game" = auto && test "$_opengl" = yes ; then
if test "$_opengl_game" = auto ; then
_opengl_game=no
if test "$_backend" = "sdl" || test "$_backend" = "android"; then
if (test "$_backend" = "sdl" && test "$_opengl" = yes) || test "$_backend" = "android3d"; then
# Try different header filenames
# 1) GL/gl.h This is usually used on POSIX and Windows systems
# 2) OpenGL/gl.h This is used on Mac OS X
@ -5410,7 +5412,7 @@ EOF
fi
fi
if test "$_opengl_game" = yes && test "$_opengl" = yes ; then
if test "$_opengl_game" = yes ; then
# Our simple test case
cat > $TMPC << EOF
int main(void) { return 0; }

View File

@ -1,70 +1,63 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
buildDir = "${gradle.buildDir}/android3d/build"
dependencies {
repositories {
google()
jcenter()
}
}
// Enable to see use of depracted API
// tasks.withType(JavaCompile) {
// options.compilerArgs << "-Xlint:deprecation"
// }
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
ndkVersion "21.3.6528147"
defaultConfig {
applicationId 'com.residualvm.residualvm'
minSdkVersion 16
targetSdkVersion 28
versionCode gradle.versionCode
versionName gradle.versionName
ndk {
abiFilters gradle.androidAbi.split(" ")
}
aaptOptions {
noCompress "zip", "lab"
}
}
lintOptions {
disable 'GoogleAppIndexingWarning'
}
compileSdkVersion 29
buildToolsVersion "29.0.3"
ndkVersion "21.3.6528147"
sourceSets {
main {
assets.srcDirs = ["${gradle.buildDir}/android3d/assets"]
java.srcDirs = ["${gradle.sourceDir}/backends/platform/android3d"]
res.srcDirs = ["${gradle.sourceDir}/dists/android3d/res"]
manifest.srcFile "${gradle.sourceDir}/dists/android3d/AndroidManifest.xml"
jniLibs.srcDirs = ["${gradle.buildDir}/android3d/jni"]
}
}
if ("KEYSTORE" in System.env) {
signingConfigs {
release {
storeFile file(System.env["KEYSTORE"])
keyAlias "upload_key"
storePassword "ResidualVM"
keyPassword "ResidualVM"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
defaultConfig {
applicationId "org.residualvm.residualvm"
setProperty("archivesBaseName", "ResidualVM")
minSdkVersion 16
targetSdkVersion 28
versionName "0.4"
versionCode 50000
}
buildTypes {
release {
minifyEnabled false
}
}
sourceSets {
main {
assets.srcDirs 'assets/'
java.srcDirs srcdir + '/backends/platform/android3d/'
jniLibs.srcDirs 'lib/'
res.srcDirs srcdir + '/dists/android3d/res/'
manifest.srcFile srcdir + '/dists/android3d/AndroidManifest.xml'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation "com.android.support:appcompat-v7:28.0.0"
// implementation "androidx.annotation:annotation:1.1.0"
implementation "com.android.support:appcompat-v7:28.0.0"
}

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

View File

@ -1,21 +1,5 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
@ -44,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

View File

@ -3,7 +3,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
APP_ABI := $(ABI)
LOCAL_MODULE := residualvm
LOCAL_SRC_FILES := ../../libresidualvm.so
LOCAL_MODULE := scummvm
LOCAL_SRC_FILES := ../libscummvm.so
include $(PREBUILT_SHARED_LIBRARY)