Android compile fix (#4395)

* Fix compile for Android, set API to 24

* Update Android Studio project to API 24

* Fixed project file to latest Android Studio

* fix build with gradle alone
This commit is contained in:
Miodrag Milanović 2018-12-12 01:38:28 +01:00 committed by ajrhacker
parent ff08c8cd4e
commit a45221458d
11 changed files with 30 additions and 96 deletions

View file

@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <limits.h>
#include <string.h>
#include "opensl_io.h"
#define CONV16BIT 32768
#define CONVMYFLT (1./32768.)

View file

@ -1,14 +1,12 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
compileSdkVersion 24
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "org.mamedev.mame"
minSdkVersion 21
targetSdkVersion 21
minSdkVersion 24
ndk {
moduleName 'main'
}

View file

@ -8,9 +8,6 @@
android:versionName="0.204"
android:installLocation="auto">
<!-- Android 5.0 -->
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />
<!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" />

View file

@ -1,15 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}

View file

@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Tue Dec 11 19:45:09 CET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

0
android-project/gradlew vendored Normal file → Executable file
View file

View file

@ -1,3 +1,3 @@
gradle.ext.sdkVersion = 21
gradle.ext.sdkVersion = 24
include ':app'

View file

@ -907,7 +907,7 @@ endif
ifeq (posix,$(SHELLTYPE))
MKDIR = $(SILENT) mkdir -p "$(1)"
COPY = $(SILENT) cp -fR "$(1)" "$(2)"
COPY = $(SILENT) cp -fR "$(1)"/* "$(2)"
else
MKDIR = $(SILENT) mkdir "$(subst /,\\,$(1))" 2> nul || exit 0
COPY = $(SILENT) copy /Y "$(subst /,\\,$(1))" "$(subst /,\\,$(2))" > nul || exit 0
@ -1210,36 +1210,6 @@ android-arm64: android-ndk generate $(PROJECTDIR_SDL)/$(MAKETYPE)-android-arm64/
$(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/$(MAKETYPE)-android-arm64 config=$(CONFIG) precompile
$(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/$(MAKETYPE)-android-arm64 config=$(CONFIG)
#-------------------------------------------------
# android-mips
#-------------------------------------------------
$(PROJECTDIR_SDL)/$(MAKETYPE)-android-mips/Makefile: makefile $(SCRIPTS) $(GENIE)
ifndef ANDROID_NDK_MIPS
$(error ANDROID_NDK_MIPS is not set)
endif
$(SILENT) $(GENIE) $(PARAMS) --gcc=android-mips --gcc_version=3.8.0 --osd=sdl --targetos=android --PLATFORM=mips --NO_USE_MIDI=1 --NO_OPENGL=1 --USE_QTDEBUG=0 --NO_X11=1 --DONT_USE_NETWORK=1 --NOASM=1 $(MAKETYPE)
.PHONY: android-mips
android-mips: android-ndk generate $(PROJECTDIR_SDL)/$(MAKETYPE)-android-mips/Makefile
$(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/$(MAKETYPE)-android-mips config=$(CONFIG) precompile
$(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/$(MAKETYPE)-android-mips config=$(CONFIG)
#-------------------------------------------------
# android-mips64
#-------------------------------------------------
$(PROJECTDIR_SDL)/$(MAKETYPE)-android-mips64/Makefile: makefile $(SCRIPTS) $(GENIE)
ifndef ANDROID_NDK_MIPS64
$(error ANDROID_NDK_MIPS64 is not set)
endif
$(SILENT) $(GENIE) $(PARAMS) --gcc=android-mips64 --gcc_version=3.8.0 --osd=sdl --targetos=android --PLATFORM=mips64 --NO_USE_MIDI=1 --NO_OPENGL=1 --USE_QTDEBUG=0 --NO_X11=1 --DONT_USE_NETWORK=1 --NOASM=1 $(MAKETYPE)
.PHONY: android-mips64
android-mips64: android-ndk generate $(PROJECTDIR_SDL)/$(MAKETYPE)-android-mips64/Makefile
$(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/$(MAKETYPE)-android-mips64 config=$(CONFIG) precompile
$(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/$(MAKETYPE)-android-mips64 config=$(CONFIG)
#-------------------------------------------------
# android-x86
#-------------------------------------------------

View file

@ -94,11 +94,11 @@ function toolchain(_buildDir, _subDir)
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION)
local androidPlatform = "android-21"
local androidPlatform = "android-24"
if _OPTIONS["with-android"] then
androidPlatform = "android-" .. _OPTIONS["with-android"]
elseif _OPTIONS["PLATFORM"]:find("64", -2) then
androidPlatform = "android-21"
androidPlatform = "android-24"
end
local iosPlatform = ""
@ -847,6 +847,7 @@ function toolchain(_buildDir, _subDir)
MAME_DIR .. "3rdparty/bgfx/3rdparty/khronos",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libcxx/include",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/include",
"$(ANDROID_NDK_ROOT)/sysroot/usr/include",
"$(ANDROID_NDK_ROOT)/sources/android/support/include",
"$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
}
@ -864,10 +865,12 @@ function toolchain(_buildDir, _subDir)
"log",
"c++_static",
"c++abi",
"android_support",
"stdc++",
"gcc",
}
buildoptions_c {
"-Wno-strict-prototypes",
}
buildoptions {
"-fpic",
"-ffunction-sections",
@ -880,6 +883,8 @@ function toolchain(_buildDir, _subDir)
"-Wno-cast-align",
"-Wno-unknown-attributes",
"-Wno-macro-redefined",
"-DASIO_HAS_STD_STRING_VIEW",
"-Wno-unused-function",
}
linkoptions {
"-no-canonical-prefixes",
@ -893,11 +898,10 @@ function toolchain(_buildDir, _subDir)
configuration { "android-arm" }
libdirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
"$(ANDROID_NDK_ARM)/lib/gcc/arm-linux-androideabi/4.9.x/armv7-a",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib",
}
includedirs {
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/include",
"$(ANDROID_NDK_ROOT)/sysroot/usr/include/arm-linux-androideabi",
}
buildoptions {
"-gcc-toolchain $(ANDROID_NDK_ARM)",
@ -926,7 +930,7 @@ function toolchain(_buildDir, _subDir)
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm64/usr/lib64",
}
includedirs {
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm64/usr/include",
"$(ANDROID_NDK_ROOT)/sysroot/usr/include/aarch64-linux-android",
}
buildoptions {
"-gcc-toolchain $(ANDROID_NDK_ARM64)",
@ -940,53 +944,13 @@ function toolchain(_buildDir, _subDir)
"-target aarch64-none-linux-android",
}
configuration { "android-mips" }
libdirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/",
}
includedirs {
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/include",
}
buildoptions {
"-gcc-toolchain $(ANDROID_NDK_MIPS)",
"-target mipsel-none-linux-android",
}
linkoptions {
"-gcc-toolchain $(ANDROID_NDK_MIPS)",
"-target mipsel-none-linux-android",
"--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtbegin_so.o",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtend_so.o",
}
configuration { "android-mips64" }
libdirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips64",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips64/usr/lib64/",
}
includedirs {
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips64/usr/include",
}
buildoptions {
"-gcc-toolchain $(ANDROID_NDK_MIPS64)",
"-target mips64el-none-linux-android",
}
linkoptions {
"-gcc-toolchain $(ANDROID_NDK_MIPS64)",
"-target mips64el-none-linux-android",
"--sysroot=$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips64",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips64/usr/lib64/crtbegin_so.o",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips64/usr/lib64/crtend_so.o",
}
configuration { "android-x86" }
libdirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib",
}
includedirs {
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/include",
"$(ANDROID_NDK_ROOT)/sysroot/usr/include/i686-linux-android",
}
buildoptions {
"-gcc-toolchain $(ANDROID_NDK_X86)",
@ -1008,7 +972,7 @@ function toolchain(_buildDir, _subDir)
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86_64/usr/lib64",
}
includedirs {
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86_64/usr/include",
"$(ANDROID_NDK_ROOT)/sysroot/usr/include/x86_64-linux-android",
}
buildoptions {
"-gcc-toolchain $(ANDROID_NDK_X64)",

View file

@ -22,9 +22,11 @@
#if defined(__FreeBSD_kernel__) || defined(__DragonFly__)
#include <termios.h>
#include <libutil.h>
#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__ANDROID__)
#elif defined(__NetBSD__) || defined(__OpenBSD__)
#include <termios.h>
#include <util.h>
#elif defined(__APPLE__)
#include <termios.h>
#elif defined(__linux__) || defined(EMSCRIPTEN)
#include <pty.h>
#elif defined(__HAIKU__)

View file

@ -304,7 +304,7 @@ void sound_sdl::update_audio_stream(bool is_throttled, const int16_t *buffer, in
if (stream_buffer->free_size() < bytes_this_frame) {
if (LOG_SOUND)
fprintf(sound_log, "Overflow: DS=%lu FS=%lu BTF=%lu\n", data_size, free_size, bytes_this_frame);
fprintf(sound_log, "Overflow: DS=%zu FS=%zu BTF=%zu\n", data_size, free_size, bytes_this_frame);
buffer_overflows++;
return;
}
@ -314,7 +314,7 @@ void sound_sdl::update_audio_stream(bool is_throttled, const int16_t *buffer, in
size_t nfree_size = stream_buffer->free_size();
size_t ndata_size = stream_buffer->data_size();
if (LOG_SOUND)
fprintf(sound_log, "Appended data: DS=%lu(%lu) FS=%lu(%lu) BTF=%lu\n", data_size, ndata_size, free_size, nfree_size, bytes_this_frame);
fprintf(sound_log, "Appended data: DS=%zu(%zu) FS=%zu(%zu) BTF=%zu\n", data_size, ndata_size, free_size, nfree_size, bytes_this_frame);
}
@ -350,7 +350,7 @@ static void sdl_callback(void *userdata, Uint8 *stream, int len)
{
thiz->buffer_underflows++;
if (LOG_SOUND)
fprintf(sound_log, "Underflow at sdl_callback: DS=%lu FS=%lu Len=%d\n", data_size, free_size, len);
fprintf(sound_log, "Underflow at sdl_callback: DS=%zu FS=%zu Len=%d\n", data_size, free_size, len);
// Maybe read whatever is left in the stream_buffer anyway?
memset(stream, 0, len);
@ -364,7 +364,7 @@ static void sdl_callback(void *userdata, Uint8 *stream, int len)
thiz->attenuate((int16_t *)stream, len);
if (LOG_SOUND)
fprintf(sound_log, "callback: xfer DS=%lu FS=%lu Len=%d\n", data_size, free_size, len);
fprintf(sound_log, "callback: xfer DS=%zu FS=%zu Len=%d\n", data_size, free_size, len);
}