aboutsummaryrefslogtreecommitdiff
path: root/android/native
diff options
context:
space:
mode:
authorNeroBurner <pyro4hell@gmail.com>2021-06-21 21:51:42 +0200
committerGitHub <noreply@github.com>2021-06-21 20:51:42 +0100
commita7143c2a8c48b234d78ec666193b942ae0b62ca3 (patch)
treec6ba5317ba853536d25709f80aadc4036c14dfd3 /android/native
parent7fdbf3f231976257a1c246c6ebcdbc5bb8fa5571 (diff)
downloadminetest-a7143c2a8c48b234d78ec666193b942ae0b62ca3.tar.gz
minetest-a7143c2a8c48b234d78ec666193b942ae0b62ca3.tar.bz2
minetest-a7143c2a8c48b234d78ec666193b942ae0b62ca3.zip
Move build/android directory to root of project (#11283)
Diffstat (limited to 'android/native')
-rw-r--r--android/native/build.gradle98
-rw-r--r--android/native/jni/Android.mk206
-rw-r--r--android/native/jni/Application.mk32
-rw-r--r--android/native/src/main/AndroidManifest.xml1
4 files changed, 337 insertions, 0 deletions
diff --git a/android/native/build.gradle b/android/native/build.gradle
new file mode 100644
index 000000000..8ea6347b3
--- /dev/null
+++ b/android/native/build.gradle
@@ -0,0 +1,98 @@
+apply plugin: 'com.android.library'
+apply plugin: 'de.undercouch.download'
+
+android {
+ compileSdkVersion 29
+ buildToolsVersion '30.0.3'
+ ndkVersion '22.0.7026061'
+ defaultConfig {
+ minSdkVersion 16
+ targetSdkVersion 29
+ externalNativeBuild {
+ ndkBuild {
+ arguments '-j' + Runtime.getRuntime().availableProcessors(),
+ "versionMajor=${versionMajor}",
+ "versionMinor=${versionMinor}",
+ "versionPatch=${versionPatch}",
+ "versionExtra=${versionExtra}"
+ }
+ }
+ }
+
+ externalNativeBuild {
+ ndkBuild {
+ path file('jni/Android.mk')
+ }
+ }
+
+ // supported architectures
+ splits {
+ abi {
+ enable true
+ reset()
+ include 'armeabi-v7a', 'arm64-v8a'//, 'x86'
+ }
+ }
+
+ buildTypes {
+ release {
+ externalNativeBuild {
+ ndkBuild {
+ arguments 'NDEBUG=1'
+ }
+ }
+ }
+ }
+}
+
+// get precompiled deps
+def folder = 'minetest_android_deps_binaries'
+
+task downloadDeps(type: Download) {
+ src 'https://github.com/minetest/' + folder + '/archive/master.zip'
+ dest new File(buildDir, 'deps.zip')
+ overwrite false
+}
+
+task getDeps(dependsOn: downloadDeps, type: Copy) {
+ def deps = file('deps')
+ def f = file("$buildDir/" + folder + "-master")
+
+ if (!deps.exists() && !f.exists()) {
+ 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))
+ }
+ }
+}
+
+preBuild.dependsOn getDeps
+preBuild.dependsOn getSqlite
diff --git a/android/native/jni/Android.mk b/android/native/jni/Android.mk
new file mode 100644
index 000000000..5039f325e
--- /dev/null
+++ b/android/native/jni/Android.mk
@@ -0,0 +1,206 @@
+LOCAL_PATH := $(call my-dir)/..
+
+#LOCAL_ADDRESS_SANITIZER:=true
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := Curl
+LOCAL_SRC_FILES := deps/Android/Curl/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/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
+include $(PREBUILT_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := Irrlicht
+LOCAL_SRC_FILES := deps/Android/Irrlicht/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libIrrlichtMt.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 := LuaJIT
+LOCAL_SRC_FILES := deps/Android/LuaJIT/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libluajit.a
+include $(PREBUILT_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := mbedTLS
+LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedtls.a
+include $(PREBUILT_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := mbedx509
+LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedx509.a
+include $(PREBUILT_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := mbedcrypto
+LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedcrypto.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
+include $(PREBUILT_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := Vorbis
+LOCAL_SRC_FILES := deps/Android/Vorbis/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libvorbis.a
+include $(PREBUILT_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := Minetest
+
+LOCAL_CFLAGS += \
+ -DJSONCPP_NO_LOCALE_SUPPORT \
+ -DHAVE_TOUCHSCREENGUI \
+ -DENABLE_GLES=1 \
+ -DUSE_CURL=1 \
+ -DUSE_SOUND=1 \
+ -DUSE_FREETYPE=1 \
+ -DUSE_LEVELDB=0 \
+ -DUSE_LUAJIT=1 \
+ -DVERSION_MAJOR=${versionMajor} \
+ -DVERSION_MINOR=${versionMinor} \
+ -DVERSION_PATCH=${versionPatch} \
+ -DVERSION_EXTRA=${versionExtra} \
+ $(GPROF_DEF)
+
+ifdef NDEBUG
+ LOCAL_CFLAGS += -DNDEBUG=1
+endif
+
+ifdef GPROF
+ GPROF_DEF := -DGPROF
+ PROFILER_LIBS := android-ndk-profiler
+ LOCAL_CFLAGS += -pg
+endif
+
+LOCAL_C_INCLUDES := \
+ ../../src \
+ ../../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
+
+LOCAL_SRC_FILES := \
+ $(wildcard ../../src/client/*.cpp) \
+ $(wildcard ../../src/client/*/*.cpp) \
+ $(wildcard ../../src/content/*.cpp) \
+ ../../src/database/database.cpp \
+ ../../src/database/database-dummy.cpp \
+ ../../src/database/database-files.cpp \
+ ../../src/database/database-sqlite3.cpp \
+ $(wildcard ../../src/gui/*.cpp) \
+ $(wildcard ../../src/irrlicht_changes/*.cpp) \
+ $(wildcard ../../src/mapgen/*.cpp) \
+ $(wildcard ../../src/network/*.cpp) \
+ $(wildcard ../../src/script/*.cpp) \
+ $(wildcard ../../src/script/*/*.cpp) \
+ $(wildcard ../../src/server/*.cpp) \
+ $(wildcard ../../src/threading/*.cpp) \
+ $(wildcard ../../src/util/*.c) \
+ $(wildcard ../../src/util/*.cpp) \
+ ../../src/ban.cpp \
+ ../../src/chat.cpp \
+ ../../src/clientiface.cpp \
+ ../../src/collision.cpp \
+ ../../src/content_mapnode.cpp \
+ ../../src/content_nodemeta.cpp \
+ ../../src/convert_json.cpp \
+ ../../src/craftdef.cpp \
+ ../../src/debug.cpp \
+ ../../src/defaultsettings.cpp \
+ ../../src/emerge.cpp \
+ ../../src/environment.cpp \
+ ../../src/face_position_cache.cpp \
+ ../../src/filesys.cpp \
+ ../../src/gettext.cpp \
+ ../../src/httpfetch.cpp \
+ ../../src/hud.cpp \
+ ../../src/inventory.cpp \
+ ../../src/inventorymanager.cpp \
+ ../../src/itemdef.cpp \
+ ../../src/itemstackmetadata.cpp \
+ ../../src/light.cpp \
+ ../../src/log.cpp \
+ ../../src/main.cpp \
+ ../../src/map.cpp \
+ ../../src/map_settings_manager.cpp \
+ ../../src/mapblock.cpp \
+ ../../src/mapnode.cpp \
+ ../../src/mapsector.cpp \
+ ../../src/metadata.cpp \
+ ../../src/modchannels.cpp \
+ ../../src/nameidmapping.cpp \
+ ../../src/nodedef.cpp \
+ ../../src/nodemetadata.cpp \
+ ../../src/nodetimer.cpp \
+ ../../src/noise.cpp \
+ ../../src/objdef.cpp \
+ ../../src/object_properties.cpp \
+ ../../src/particles.cpp \
+ ../../src/pathfinder.cpp \
+ ../../src/player.cpp \
+ ../../src/porting.cpp \
+ ../../src/porting_android.cpp \
+ ../../src/profiler.cpp \
+ ../../src/raycast.cpp \
+ ../../src/reflowscan.cpp \
+ ../../src/remoteplayer.cpp \
+ ../../src/rollback.cpp \
+ ../../src/rollback_interface.cpp \
+ ../../src/serialization.cpp \
+ ../../src/server.cpp \
+ ../../src/serverenvironment.cpp \
+ ../../src/serverlist.cpp \
+ ../../src/settings.cpp \
+ ../../src/staticobject.cpp \
+ ../../src/texture_override.cpp \
+ ../../src/tileanimation.cpp \
+ ../../src/tool.cpp \
+ ../../src/translation.cpp \
+ ../../src/version.cpp \
+ ../../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
+
+LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -landroid -lOpenSLES
+
+include $(BUILD_SHARED_LIBRARY)
+
+ifdef GPROF
+$(call import-module,android-ndk-profiler)
+endif
+$(call import-module,android/native_app_glue)
diff --git a/android/native/jni/Application.mk b/android/native/jni/Application.mk
new file mode 100644
index 000000000..82f0148f0
--- /dev/null
+++ b/android/native/jni/Application.mk
@@ -0,0 +1,32 @@
+APP_PLATFORM := ${APP_PLATFORM}
+APP_ABI := ${TARGET_ABI}
+APP_STL := c++_shared
+NDK_TOOLCHAIN_VERSION := clang
+APP_SHORT_COMMANDS := true
+APP_MODULES := Minetest
+
+APP_CPPFLAGS := -Ofast -fvisibility=hidden -fexceptions -Wno-deprecated-declarations -Wno-extra-tokens
+
+ifeq ($(APP_ABI),armeabi-v7a)
+APP_CPPFLAGS += -march=armv7-a -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
+
+ifndef NDEBUG
+APP_CPPFLAGS := -g -D_DEBUG -O0 -fno-omit-frame-pointer -fexceptions
+endif
+
+APP_CFLAGS := $(APP_CPPFLAGS) -Wno-parentheses-equality #-Werror=shorten-64-to-32
+APP_CXXFLAGS := $(APP_CPPFLAGS) -frtti -std=gnu++17
+APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections,--icf=safe
+
+ifeq ($(APP_ABI),arm64-v8a)
+APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections
+endif
+
+ifndef NDEBUG
+APP_LDFLAGS :=
+endif
diff --git a/android/native/src/main/AndroidManifest.xml b/android/native/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..19451c7fd
--- /dev/null
+++ b/android/native/src/main/AndroidManifest.xml
@@ -0,0 +1 @@
+<manifest package="net.minetest" />