diff options
Diffstat (limited to 'android/native')
-rw-r--r-- | android/native/build.gradle | 51 | ||||
-rw-r--r-- | android/native/jni/Android.mk | 123 | ||||
-rw-r--r-- | android/native/jni/Application.mk | 16 |
3 files changed, 86 insertions, 104 deletions
diff --git a/android/native/build.gradle b/android/native/build.gradle index d58a2dcc5..2ddc77135 100644 --- a/android/native/build.gradle +++ b/android/native/build.gradle @@ -2,12 +2,12 @@ apply plugin: 'com.android.library' apply plugin: 'de.undercouch.download' android { - compileSdkVersion 29 + compileSdkVersion 30 buildToolsVersion '30.0.3' - ndkVersion '22.0.7026061' + ndkVersion "$ndk_version" defaultConfig { minSdkVersion 16 - targetSdkVersion 29 + targetSdkVersion 30 externalNativeBuild { ndkBuild { arguments '-j' + Runtime.getRuntime().availableProcessors(), @@ -50,54 +50,19 @@ android { } // get precompiled deps -def folder = 'minetest_android_deps_binaries' -def deps_ref = "342eb18b7512462585a33bc9eef0b68298087151" - task downloadDeps(type: Download) { - src 'https://github.com/minetest/' + folder + '/archive/' + deps_ref + '.zip' + src 'https://github.com/minetest/minetest_android_deps/releases/download/latest/deps.zip' dest new File(buildDir, 'deps.zip') overwrite false } task getDeps(dependsOn: downloadDeps, type: Copy) { - def deps = file('deps') - def f = file("$buildDir/" + folder + "-" + deps_ref) - - if (!deps.exists() && !f.exists()) { + def deps = new File(buildDir.parent, 'deps') + if (!deps.exists()) { + deps.mkdir() from zipTree(downloadDeps.dest) - into buildDir - } - - doLast { - if (!deps.exists()) { - file(f).renameTo(file(deps)) - } - } -} - -// get sqlite -def sqlite_ver = '3340000' -task downloadSqlite(dependsOn: getDeps, type: Download) { - src 'https://www.sqlite.org/2020/sqlite-amalgamation-' + sqlite_ver + '.zip' - dest new File(buildDir, 'sqlite.zip') - overwrite false -} - -task getSqlite(dependsOn: downloadSqlite, type: Copy) { - def sqlite = file('deps/Android/sqlite') - def f = file("$buildDir/sqlite-amalgamation-" + sqlite_ver) - - if (!sqlite.exists() && !f.exists()) { - from zipTree(downloadSqlite.dest) - into buildDir - } - - doLast { - if (!sqlite.exists()) { - file(f).renameTo(file(sqlite)) - } + into deps } } preBuild.dependsOn getDeps -preBuild.dependsOn getSqlite diff --git a/android/native/jni/Android.mk b/android/native/jni/Android.mk index 73df04945..f8ca74d3c 100644 --- a/android/native/jni/Android.mk +++ b/android/native/jni/Android.mk @@ -4,64 +4,82 @@ LOCAL_PATH := $(call my-dir)/.. include $(CLEAR_VARS) LOCAL_MODULE := Curl -LOCAL_SRC_FILES := deps/Android/Curl/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libcurl.a +LOCAL_SRC_FILES := deps/$(APP_ABI)/Curl/libcurl.a include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) -LOCAL_MODULE := Freetype -LOCAL_SRC_FILES := deps/Android/Freetype/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libfreetype.a +LOCAL_MODULE := libmbedcrypto +LOCAL_SRC_FILES := deps/$(APP_ABI)/Curl/libmbedcrypto.a include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) -LOCAL_MODULE := Irrlicht -LOCAL_SRC_FILES := deps/Android/Irrlicht/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libIrrlicht.a +LOCAL_MODULE := libmbedtls +LOCAL_SRC_FILES := deps/$(APP_ABI)/Curl/libmbedtls.a include $(PREBUILT_STATIC_LIBRARY) -#include $(CLEAR_VARS) -#LOCAL_MODULE := LevelDB -#LOCAL_SRC_FILES := deps/Android/LevelDB/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libleveldb.a -#include $(PREBUILT_STATIC_LIBRARY) +include $(CLEAR_VARS) +LOCAL_MODULE := libmbedx509 +LOCAL_SRC_FILES := deps/$(APP_ABI)/Curl/libmbedx509.a +include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) -LOCAL_MODULE := LuaJIT -LOCAL_SRC_FILES := deps/Android/LuaJIT/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libluajit.a +LOCAL_MODULE := Freetype +LOCAL_SRC_FILES := deps/$(APP_ABI)/Freetype/libfreetype.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := Iconv +LOCAL_SRC_FILES := deps/$(APP_ABI)/Iconv/libiconv.a include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) -LOCAL_MODULE := mbedTLS -LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedtls.a +LOCAL_MODULE := libcharset +LOCAL_SRC_FILES := deps/$(APP_ABI)/Iconv/libcharset.a include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) -LOCAL_MODULE := mbedx509 -LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedx509.a +LOCAL_MODULE := Irrlicht +LOCAL_SRC_FILES := deps/$(APP_ABI)/Irrlicht/libIrrlichtMt.a include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) -LOCAL_MODULE := mbedcrypto -LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedcrypto.a +LOCAL_MODULE := LuaJIT +LOCAL_SRC_FILES := deps/$(APP_ABI)/LuaJIT/libluajit.a include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := OpenAL -LOCAL_SRC_FILES := deps/Android/OpenAL-Soft/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libopenal.a +LOCAL_SRC_FILES := deps/$(APP_ABI)/OpenAL-Soft/libopenal.a include $(PREBUILT_STATIC_LIBRARY) -# You can use `OpenSSL and Crypto` instead `mbedTLS mbedx509 mbedcrypto`, -#but it increase APK size on ~0.7MB -#include $(CLEAR_VARS) -#LOCAL_MODULE := OpenSSL -#LOCAL_SRC_FILES := deps/Android/OpenSSL/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libssl.a -#include $(PREBUILT_STATIC_LIBRARY) +include $(CLEAR_VARS) +LOCAL_MODULE := Gettext +LOCAL_SRC_FILES := deps/$(APP_ABI)/Gettext/libintl.a +include $(PREBUILT_STATIC_LIBRARY) -#include $(CLEAR_VARS) -#LOCAL_MODULE := Crypto -#LOCAL_SRC_FILES := deps/Android/OpenSSL/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libcrypto.a -#include $(PREBUILT_STATIC_LIBRARY) +include $(CLEAR_VARS) +LOCAL_MODULE := SQLite3 +LOCAL_SRC_FILES := deps/$(APP_ABI)/SQLite/libsqlite3.a +include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := Vorbis -LOCAL_SRC_FILES := deps/Android/Vorbis/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libvorbis.a +LOCAL_SRC_FILES := deps/$(APP_ABI)/Vorbis/libvorbis.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libvorbisfile +LOCAL_SRC_FILES := deps/$(APP_ABI)/Vorbis/libvorbisfile.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libogg +LOCAL_SRC_FILES := deps/$(APP_ABI)/Vorbis/libogg.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := Zstd +LOCAL_SRC_FILES := deps/$(APP_ABI)/Zstd/libzstd.a include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) @@ -73,9 +91,9 @@ LOCAL_CFLAGS += \ -DENABLE_GLES=1 \ -DUSE_CURL=1 \ -DUSE_SOUND=1 \ - -DUSE_FREETYPE=1 \ -DUSE_LEVELDB=0 \ -DUSE_LUAJIT=1 \ + -DUSE_GETTEXT=1 \ -DVERSION_MAJOR=${versionMajor} \ -DVERSION_MINOR=${versionMinor} \ -DVERSION_PATCH=${versionPatch} \ @@ -97,16 +115,16 @@ LOCAL_C_INCLUDES := \ ../../src/script \ ../../lib/gmp \ ../../lib/jsoncpp \ - deps/Android/Curl/include \ - deps/Android/Freetype/include \ - deps/Android/Irrlicht/include \ - deps/Android/LevelDB/include \ - deps/Android/libiconv/include \ - deps/Android/libiconv/libcharset/include \ - deps/Android/LuaJIT/src \ - deps/Android/OpenAL-Soft/include \ - deps/Android/sqlite \ - deps/Android/Vorbis/include + deps/$(APP_ABI)/Curl/include \ + deps/$(APP_ABI)/Freetype/include/freetype2 \ + deps/$(APP_ABI)/Irrlicht/include \ + deps/$(APP_ABI)/Gettext/include \ + deps/$(APP_ABI)/Iconv/include \ + deps/$(APP_ABI)/LuaJIT/include \ + deps/$(APP_ABI)/OpenAL-Soft/include \ + deps/$(APP_ABI)/SQLite/include \ + deps/$(APP_ABI)/Vorbis/include \ + deps/$(APP_ABI)/Zstd/include LOCAL_SRC_FILES := \ $(wildcard ../../src/client/*.cpp) \ @@ -189,25 +207,24 @@ LOCAL_SRC_FILES := \ ../../src/voxel.cpp \ ../../src/voxelalgorithms.cpp -# LevelDB backend is disabled -# ../../src/database/database-leveldb.cpp - # GMP LOCAL_SRC_FILES += ../../lib/gmp/mini-gmp.c # JSONCPP LOCAL_SRC_FILES += ../../lib/jsoncpp/jsoncpp.cpp -# iconv -LOCAL_SRC_FILES += \ - deps/Android/libiconv/lib/iconv.c \ - deps/Android/libiconv/libcharset/lib/localcharset.c - -# SQLite3 -LOCAL_SRC_FILES += deps/Android/sqlite/sqlite3.c - -LOCAL_STATIC_LIBRARIES += Curl Freetype Irrlicht OpenAL mbedTLS mbedx509 mbedcrypto Vorbis LuaJIT android_native_app_glue $(PROFILER_LIBS) #LevelDB -#OpenSSL Crypto +LOCAL_STATIC_LIBRARIES += \ + Curl libmbedcrypto libmbedtls libmbedx509 \ + Freetype \ + Iconv libcharset \ + Irrlicht \ + LuaJIT \ + OpenAL \ + Gettext \ + SQLite3 \ + Vorbis libvorbisfile libogg \ + Zstd +LOCAL_STATIC_LIBRARIES += android_native_app_glue $(PROFILER_LIBS) LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -landroid -lOpenSLES diff --git a/android/native/jni/Application.mk b/android/native/jni/Application.mk index 82f0148f0..e21bca61c 100644 --- a/android/native/jni/Application.mk +++ b/android/native/jni/Application.mk @@ -5,22 +5,22 @@ NDK_TOOLCHAIN_VERSION := clang APP_SHORT_COMMANDS := true APP_MODULES := Minetest -APP_CPPFLAGS := -Ofast -fvisibility=hidden -fexceptions -Wno-deprecated-declarations -Wno-extra-tokens +APP_CPPFLAGS := -O2 -fvisibility=hidden ifeq ($(APP_ABI),armeabi-v7a) -APP_CPPFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb +APP_CPPFLAGS += -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb endif -#ifeq ($(APP_ABI),x86) -#APP_CPPFLAGS += -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -funroll-loops -#endif +ifeq ($(APP_ABI),x86) +APP_CPPFLAGS += -mssse3 -mfpmath=sse -funroll-loops +endif ifndef NDEBUG -APP_CPPFLAGS := -g -D_DEBUG -O0 -fno-omit-frame-pointer -fexceptions +APP_CPPFLAGS := -g -Og -fno-omit-frame-pointer endif -APP_CFLAGS := $(APP_CPPFLAGS) -Wno-parentheses-equality #-Werror=shorten-64-to-32 -APP_CXXFLAGS := $(APP_CPPFLAGS) -frtti -std=gnu++17 +APP_CFLAGS := $(APP_CPPFLAGS) -Wno-inconsistent-missing-override -Wno-parentheses-equality +APP_CXXFLAGS := $(APP_CPPFLAGS) -fexceptions -frtti -std=gnu++17 APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections,--icf=safe ifeq ($(APP_ABI),arm64-v8a) |