Skip to content

Commit

Permalink
Upgrade Android build to Gradle build system
Browse files Browse the repository at this point in the history
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 e416738
Show file tree
Hide file tree
Showing 29 changed files with 291 additions and 287 deletions.
15 changes: 7 additions & 8 deletions .gitignore
Expand Up @@ -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

35 changes: 0 additions & 35 deletions build/android/AndroidManifest.xml.template

This file was deleted.

372 changes: 167 additions & 205 deletions build/android/Makefile

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions build/android/build.gradle
@@ -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
}
}
}
}

16 changes: 0 additions & 16 deletions build/android/build.xml

This file was deleted.

32 changes: 16 additions & 16 deletions build/android/jni/Android.mk
Expand Up @@ -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
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -374,3 +373,4 @@ ifdef GPROF
$(call import-module,android-ndk-profiler)
endif
$(call import-module,android/native_app_glue)

3 changes: 2 additions & 1 deletion build/android/jni/Application.mk
@@ -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.
1 change: 0 additions & 1 deletion build/android/project.properties

This file was deleted.

2 changes: 2 additions & 0 deletions build/android/settings.gradle
@@ -0,0 +1,2 @@
rootProject.name = "Minetest"

4 changes: 4 additions & 0 deletions build/android/src/debug/AndroidManifest.xml
@@ -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>
34 changes: 34 additions & 0 deletions build/android/src/main/AndroidManifest.xml
@@ -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>
Expand Up @@ -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>
5 changes: 5 additions & 0 deletions build/android/src/main/res/values/strings.xml
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="preparing_media">Preparing media...</string>
</resources>

File renamed without changes.
8 changes: 4 additions & 4 deletions util/bump_version.sh
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit e416738

Please sign in to comment.