Fix android builds (#4432)
* Terminate android build script early if any step fails * Remove deprecated android types * Use android NDK cmake support rather than cmake android NDK support as that support is better supported * Android uses GNU strerror_r? * Fix compilation * Rebase * Fix final issues * Drop submodule changes * Revert change * Parentheses * Lower api levels * Don't use GNU strerror_r for Android Co-authored-by: Mat <mail@mathias.is>
This commit is contained in:
parent
57a248bfbf
commit
bf10b56638
1
android/.gitignore
vendored
1
android/.gitignore
vendored
@ -1 +1,2 @@
|
||||
/Cuberite/
|
||||
Server
|
@ -22,7 +22,7 @@ include_directories(SYSTEM
|
||||
)
|
||||
|
||||
# Disable some compiler warnings (the lazy way out)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-double-promotion")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-double-promotion -Wno-sign-conversion")
|
||||
|
||||
# Build the rest of the server
|
||||
add_subdirectory(../ Cuberite)
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# This script cross-compiles cuberite for the android platform. It uses
|
||||
# the following enviroment variables
|
||||
# CMAKE: Should be the path to a cmake executable of version 3.7+
|
||||
@ -13,16 +15,16 @@ function usage() {
|
||||
}
|
||||
|
||||
BASEDIR="$(realpath $(dirname $0))"
|
||||
BUILDDIR="$BASEDIR/../android-build"
|
||||
SELF="./$(basename $0)"
|
||||
|
||||
# Clean doesn't need CMAKE and NDK, so it's handled here
|
||||
if [ "$1" == "clean" ]; then
|
||||
cd $BASEDIR
|
||||
rm -rf ../android-build/
|
||||
rm -rf $BUILDDIR
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$CMAKE" -o -z "$NDK" ];then
|
||||
if [ -z "$CMAKE" -o -z "$NDK" ]; then
|
||||
usage;
|
||||
fi
|
||||
|
||||
@ -41,28 +43,17 @@ fi
|
||||
cd $BASEDIR
|
||||
|
||||
case "$1" in
|
||||
armeabi)
|
||||
APILEVEL=16
|
||||
;;
|
||||
|
||||
armeabi-v7a)
|
||||
APILEVEL=16
|
||||
APILEVEL=14
|
||||
;;
|
||||
|
||||
arm64-v8a)
|
||||
APILEVEL=21
|
||||
;;
|
||||
|
||||
mips)
|
||||
APILEVEL=16
|
||||
;;
|
||||
|
||||
mips64)
|
||||
APILEVEL=21
|
||||
;;
|
||||
|
||||
x86)
|
||||
APILEVEL=16
|
||||
APILEVEL=14
|
||||
;;
|
||||
|
||||
x86_64)
|
||||
@ -71,22 +62,22 @@ case "$1" in
|
||||
|
||||
all)
|
||||
echo "Packing server.zip ..."
|
||||
rm -rf Server
|
||||
mkdir -p Server
|
||||
cd $BASEDIR/../Server
|
||||
zip -r $BASEDIR/Server/server.zip *
|
||||
|
||||
for arch in armeabi armeabi-v7a arm64-v8a mips mips64 x86 x86_64; do
|
||||
for arch in armeabi-v7a arm64-v8a x86 x86_64; do
|
||||
echo "Doing ... $arch ..." && \
|
||||
cd $BASEDIR && \
|
||||
"$SELF" clean && \
|
||||
"$SELF" "$arch" && \
|
||||
cd Server && \
|
||||
zip "$arch".zip Cuberite && \
|
||||
rm Cuberite
|
||||
cd $BUILDDIR/Server && \
|
||||
zip $BASEDIR/Server/"$arch".zip Cuberite
|
||||
done
|
||||
|
||||
cd $BASEDIR/Server
|
||||
for file in server.zip armeabi.zip armeabi-v7a.zip arm64-v8a.zip mips.zip mips64.zip x86.zip x86_64.zip; do
|
||||
for file in server.zip armeabi-v7a.zip arm64-v8a.zip x86.zip x86_64.zip; do
|
||||
echo "Generating sha1 sum for ... $file ..." && \
|
||||
sha1sum "$file" > "$file".sha1
|
||||
done
|
||||
@ -100,7 +91,11 @@ case "$1" in
|
||||
;;
|
||||
esac
|
||||
|
||||
mkdir -p $BASEDIR/../android-build
|
||||
cd $BASEDIR/../android-build
|
||||
"$CMAKE" $BASEDIR/../android -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION="$APILEVEL" -DCMAKE_BUILD_TYPE="$TYPE" -DCMAKE_ANDROID_ARCH_ABI="$1" -DCMAKE_ANDROID_NDK="$NDK"
|
||||
mkdir -p $BUILDDIR
|
||||
cd $BUILDDIR
|
||||
"$CMAKE" $BASEDIR/../android -DCMAKE_TOOLCHAIN_FILE="$NDK/build/cmake/android.toolchain.cmake" \
|
||||
-DANDROID_ABI="$1" \
|
||||
-DANDROID_NATIVE_API_LEVEL="$APILEVEL" \
|
||||
-DCMAKE_BUILD_TYPE="$TYPE"
|
||||
|
||||
make -j "$THREADS"
|
||||
|
@ -22,7 +22,7 @@ AString GetOSErrorString( int a_ErrNo)
|
||||
|
||||
// According to https://linux.die.net/man/3/strerror_r there are two versions of strerror_r():
|
||||
|
||||
#if defined(__GLIBC__) && defined( _GNU_SOURCE) && !defined(ANDROID) // GNU version of strerror_r()
|
||||
#if defined(__GLIBC__) && defined( _GNU_SOURCE) // GNU version of strerror_r()
|
||||
|
||||
char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer));
|
||||
if (res != nullptr)
|
||||
|
Loading…
Reference in New Issue
Block a user