Skip to content
Permalink
Browse files

Upgrade Android build to Gradle build system

The old Ant build system has been deprecated for a while and new development is focused on Gradle.
I also removed a hardcoded string that lint caught and moved the patch files to a subdirectory.
I left the JNI files in the root directory.
  • Loading branch information
ShadowNinja committed Apr 28, 2016
1 parent 7baddd1 commit e41673820ffe200df78b1ec185ccb9d9ca962ae1
Showing with 291 additions and 287 deletions.
  1. +7 −8 .gitignore
  2. +0 −35 build/android/AndroidManifest.xml.template
  3. +167 −205 build/android/Makefile
  4. +49 −0 build/android/build.gradle
  5. +0 −16 build/android/build.xml
  6. +16 −16 build/android/jni/Android.mk
  7. +2 −1 build/android/jni/Application.mk
  8. 0 build/android/{ → patches}/irrlicht-back_button.patch
  9. 0 build/android/{ → patches}/irrlicht-texturehack.patch
  10. 0 build/android/{ → patches}/irrlicht-touchcount.patch
  11. 0 build/android/{ → patches}/libiconv_android.patch
  12. 0 build/android/{ → patches}/libiconv_stdio.patch
  13. 0 build/android/{ → patches}/libvorbis-libogg-fpu.patch
  14. 0 build/android/{ → patches}/openssl_arch.patch
  15. +0 −1 build/android/project.properties
  16. +2 −0 build/android/settings.gradle
  17. +4 −0 build/android/src/debug/AndroidManifest.xml
  18. +34 −0 build/android/src/main/AndroidManifest.xml
  19. 0 build/android/src/{net/minetest/minetest → main/java/net.minetest.minetest}/MinetestAssetCopy.java
  20. 0 build/android/src/{net/minetest/minetest → main/java/net.minetest.minetest}/MinetestTextEntry.java
  21. 0 build/android/src/{net/minetest/minetest → main/java/net.minetest.minetest}/MtNativeActivity.java
  22. BIN build/android/{ → src/main}/res/drawable-hdpi/irr_icon.png
  23. BIN build/android/{ → src/main}/res/drawable-ldpi/irr_icon.png
  24. BIN build/android/{ → src/main}/res/drawable-mdpi/irr_icon.png
  25. BIN build/android/{ → src/main}/res/drawable-xhdpi/irr_icon.png
  26. +1 −1 build/android/{ → src/main}/res/layout/assetcopy.xml
  27. +5 −0 build/android/src/main/res/values/strings.xml
  28. 0 build/android/{ → src/main}/res/values/styles.xml
  29. +4 −4 util/bump_version.sh
@@ -73,15 +73,14 @@ locale/
*.a

## Android build files
build/android/assets
build/android/bin
build/android/Debug
build/android/src/main/assets
build/android/build
build/android/deps
build/android/gen
build/android/jni/src
build/android/libs
build/android/jni/src
build/android/src/main/jniLibs
build/android/obj
build/android/path.cfg
build/android/and_env
build/android/AndroidManifest.xml
build/android/local.properties
build/android/.gradle
timestamp

This file was deleted.

Large diffs are not rendered by default.

@@ -0,0 +1,49 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:1.5.0"
}
}

apply plugin: "com.android.application"

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
versionCode 13
versionName "${System.env.VERSION_STR}.${versionCode}"
minSdkVersion 9
targetSdkVersion 9
applicationId "net.minetest.minetest"
manifestPlaceholders = [ package: "net.minetest.minetest", project: project.name ]
}

lintOptions {
disable "OldTargetApi", "GoogleAppIndexingWarning"
}

Properties props = new Properties()
props.load(new FileInputStream(file("local.properties")))

if (props.getProperty("keystore") != null) {
signingConfigs {
release {
storeFile file(props["keystore"])
storePassword props["keystore.password"]
keyAlias props["key"]
keyPassword props["key.password"]
}
}

buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
}

This file was deleted.

@@ -69,13 +69,13 @@ GPROF_DEF=-DGPROF
endif

LOCAL_CFLAGS := -D_IRR_ANDROID_PLATFORM_ \
-DHAVE_TOUCHSCREENGUI \
-DUSE_CURL=1 \
-DUSE_SOUND=1 \
-DUSE_FREETYPE=1 \
-DUSE_LEVELDB=$(HAVE_LEVELDB) \
$(GPROF_DEF) \
-pipe -fstrict-aliasing
-DHAVE_TOUCHSCREENGUI \
-DUSE_CURL=1 \
-DUSE_SOUND=1 \
-DUSE_FREETYPE=1 \
-DUSE_LEVELDB=$(HAVE_LEVELDB) \
$(GPROF_DEF) \
-pipe -fstrict-aliasing

ifndef NDEBUG
LOCAL_CFLAGS += -g -D_DEBUG -O0 -fno-omit-frame-pointer
@@ -95,8 +95,8 @@ ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_CFLAGS += -fno-stack-protector
endif

LOCAL_C_INCLUDES := \
jni/src jni/src/sqlite \
LOCAL_C_INCLUDES := \
jni/src \
jni/src/script \
jni/src/lua/src \
jni/src/json \
@@ -111,7 +111,7 @@ LOCAL_C_INCLUDES := \
deps/leveldb/include \
deps/sqlite/

LOCAL_SRC_FILES := \
LOCAL_SRC_FILES := \
jni/src/ban.cpp \
jni/src/camera.cpp \
jni/src/cavegen.cpp \
@@ -261,7 +261,7 @@ LOCAL_SRC_FILES := \
# intentionally kept out (we already build openssl itself): jni/src/util/sha256.c

# Network
LOCAL_SRC_FILES += \
LOCAL_SRC_FILES += \
jni/src/network/connection.cpp \
jni/src/network/networkpacket.cpp \
jni/src/network/clientopcodes.cpp \
@@ -270,7 +270,7 @@ LOCAL_SRC_FILES += \
jni/src/network/serverpackethandler.cpp \

# lua api
LOCAL_SRC_FILES += \
LOCAL_SRC_FILES += \
jni/src/script/common/c_content.cpp \
jni/src/script/common/c_converter.cpp \
jni/src/script/common/c_internal.cpp \
@@ -310,11 +310,10 @@ LOCAL_SRC_FILES += \
jni/src/script/scripting_mainmenu.cpp

#freetype2 support
LOCAL_SRC_FILES += \
jni/src/cguittfont/xCGUITTFont.cpp
LOCAL_SRC_FILES += jni/src/cguittfont/xCGUITTFont.cpp

# lua
LOCAL_SRC_FILES += \
# Lua
LOCAL_SRC_FILES += \
jni/src/lua/src/lapi.c \
jni/src/lua/src/lauxlib.c \
jni/src/lua/src/lbaselib.c \
@@ -374,3 +373,4 @@ ifdef GPROF
$(call import-module,android-ndk-profiler)
endif
$(call import-module,android/native_app_glue)

@@ -1,8 +1,9 @@
# NDK_TOOLCHAIN_VERSION := clang3.3
# NDK_TOOLCHAIN_VERSION := clang3.8

APP_PLATFORM := android-9
APP_MODULES := minetest
APP_STL := gnustl_static

APP_CPPFLAGS += -fexceptions
APP_GNUSTL_FORCE_CPP_FEATURES := rtti

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

This file was deleted.

@@ -0,0 +1,2 @@
rootProject.name = "Minetest"

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.SET_DEBUG_APP" />
</manifest>
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.minetest.minetest"
android:installLocation="auto">
<uses-feature android:glEsVersion="0x00010000" android:required="true"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:icon="@drawable/irr_icon"
android:label="${project}"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:allowBackup="true">
<activity android:name=".MtNativeActivity"
android:label="${project}"
android:launchMode="singleTask"
android:configChanges="orientation|keyboard|keyboardHidden|navigation"
android:screenOrientation="sensorLandscape"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="minetest" />
</activity>
<activity android:name=".MinetestTextEntry"
android:theme="@style/Theme.Transparent"
android:excludeFromRecents="true">
</activity>
<activity android:name=".MinetestAssetCopy"
android:theme="@style/Theme.Transparent"
android:excludeFromRecents="true">
</activity>
</application>
</manifest>
@@ -18,7 +18,7 @@
android:ellipsize="middle"
android:singleLine="true"
android:layout_gravity="center_horizontal"
android:text="preparing media ..."
android:text="@string/preparing_media"
android:textAppearance="?android:attr/textAppearanceSmall" />

</LinearLayout>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="preparing_media">Preparing media...</string>
</resources>

File renamed without changes.
@@ -32,12 +32,12 @@ cd ${0%/*}/..
grep -q -E '^set\(VERSION_MAJOR [0-9]+\)$' CMakeLists.txt || die "error: Could not find CMakeLists.txt"
grep -q -E '^set\(VERSION_MINOR [0-9]+\)$' CMakeLists.txt || die "error: Could not find CMakeLists.txt"
grep -q -E '^set\(VERSION_PATCH [0-9]+\)$' CMakeLists.txt || die "error: Could not find CMakeLists.txt"
grep -q -E '^ANDROID_VERSION_CODE = [0-9]+$' build/android/Makefile || die "error: Could not find build/android/Makefile"
grep -q -E 'versionCode [0-9]+$' build/android/build.gradle || die "error: Could not find Android version code"

VERSION_MAJOR=$(grep -E '^set\(VERSION_MAJOR [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
VERSION_MINOR=$(grep -E '^set\(VERSION_MINOR [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
VERSION_PATCH=$(grep -E '^set\(VERSION_PATCH [0-9]+\)$' CMakeLists.txt | tr -dC 0-9)
ANDROID_VERSION_CODE=$(grep -E '^ANDROID_VERSION_CODE = [0-9]+$' build/android/Makefile | tr -dC 0-9)
ANDROID_VERSION_CODE=$(grep -E 'versionCode [0-9]+$' build/android/build.gradle | tr -dC 0-9)

echo "Current Minetest version: $VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
echo "Current Android version code: $ANDROID_VERSION_CODE"
@@ -89,13 +89,13 @@ sed -i -re "s/^set\(VERSION_PATCH [0-9]+\)$/set(VERSION_PATCH $NEW_VERSION_PATCH

sed -i -re "s/^set\(DEVELOPMENT_BUILD TRUE\)$/set(DEVELOPMENT_BUILD FALSE)/" CMakeLists.txt || die "Failed to unset DEVELOPMENT_BUILD"

sed -i -re "s/^ANDROID_VERSION_CODE = [0-9]+$/ANDROID_VERSION_CODE = $NEW_ANDROID_VERSION_CODE/" build/android/Makefile || die "Failed to update ANDROID_VERSION_CODE"
sed -i -re "s/versionCode [0-9]+$/versionCode $NEW_ANDROID_VERSION_CODE/" build/android/build.gradle || die "Failed to update Android version code"

sed -i -re "1s/[0-9]+\.[0-9]+\.[0-9]+/$NEW_VERSION/g" doc/lua_api.txt || die "Failed to update doc/lua_api.txt"

sed -i -re "1s/[0-9]+\.[0-9]+\.[0-9]+/$NEW_VERSION/g" doc/menu_lua_api.txt || die "Failed to update doc/menu_lua_api.txt"

git add -f CMakeLists.txt build/android/Makefile doc/lua_api.txt doc/menu_lua_api.txt || die "git add failed"
git add -f CMakeLists.txt build/android/build.gradle doc/lua_api.txt doc/menu_lua_api.txt || die "git add failed"

git commit -m "Bump version to $NEW_VERSION" || die "git commit failed"

0 comments on commit e416738

Please sign in to comment.
You can’t perform that action at this time.