Skip to content

Commit e416738

Browse files
committedApr 28, 2016
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.
1 parent 7baddd1 commit e416738

29 files changed

+291
-287
lines changed
 

‎.gitignore

+7-8
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@ locale/
7373
*.a
7474

7575
## Android build files
76-
build/android/assets
77-
build/android/bin
78-
build/android/Debug
76+
build/android/src/main/assets
77+
build/android/build
7978
build/android/deps
80-
build/android/gen
81-
build/android/jni/src
8279
build/android/libs
80+
build/android/jni/src
81+
build/android/src/main/jniLibs
8382
build/android/obj
84-
build/android/path.cfg
85-
build/android/and_env
86-
build/android/AndroidManifest.xml
83+
build/android/local.properties
84+
build/android/.gradle
8785
timestamp
86+

‎build/android/AndroidManifest.xml.template

-35
This file was deleted.

‎build/android/Makefile

+167-205
Large diffs are not rendered by default.

‎build/android/build.gradle

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
dependencies {
6+
classpath "com.android.tools.build:gradle:1.5.0"
7+
}
8+
}
9+
10+
apply plugin: "com.android.application"
11+
12+
android {
13+
compileSdkVersion 23
14+
buildToolsVersion "23.0.3"
15+
16+
defaultConfig {
17+
versionCode 13
18+
versionName "${System.env.VERSION_STR}.${versionCode}"
19+
minSdkVersion 9
20+
targetSdkVersion 9
21+
applicationId "net.minetest.minetest"
22+
manifestPlaceholders = [ package: "net.minetest.minetest", project: project.name ]
23+
}
24+
25+
lintOptions {
26+
disable "OldTargetApi", "GoogleAppIndexingWarning"
27+
}
28+
29+
Properties props = new Properties()
30+
props.load(new FileInputStream(file("local.properties")))
31+
32+
if (props.getProperty("keystore") != null) {
33+
signingConfigs {
34+
release {
35+
storeFile file(props["keystore"])
36+
storePassword props["keystore.password"]
37+
keyAlias props["key"]
38+
keyPassword props["key.password"]
39+
}
40+
}
41+
42+
buildTypes {
43+
release {
44+
signingConfig signingConfigs.release
45+
}
46+
}
47+
}
48+
}
49+

‎build/android/build.xml

-16
This file was deleted.

‎build/android/jni/Android.mk

+16-16
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ GPROF_DEF=-DGPROF
6969
endif
7070

7171
LOCAL_CFLAGS := -D_IRR_ANDROID_PLATFORM_ \
72-
-DHAVE_TOUCHSCREENGUI \
73-
-DUSE_CURL=1 \
74-
-DUSE_SOUND=1 \
75-
-DUSE_FREETYPE=1 \
76-
-DUSE_LEVELDB=$(HAVE_LEVELDB) \
77-
$(GPROF_DEF) \
78-
-pipe -fstrict-aliasing
72+
-DHAVE_TOUCHSCREENGUI \
73+
-DUSE_CURL=1 \
74+
-DUSE_SOUND=1 \
75+
-DUSE_FREETYPE=1 \
76+
-DUSE_LEVELDB=$(HAVE_LEVELDB) \
77+
$(GPROF_DEF) \
78+
-pipe -fstrict-aliasing
7979

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

98-
LOCAL_C_INCLUDES := \
99-
jni/src jni/src/sqlite \
98+
LOCAL_C_INCLUDES := \
99+
jni/src \
100100
jni/src/script \
101101
jni/src/lua/src \
102102
jni/src/json \
@@ -111,7 +111,7 @@ LOCAL_C_INCLUDES := \
111111
deps/leveldb/include \
112112
deps/sqlite/
113113

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

263263
# Network
264-
LOCAL_SRC_FILES += \
264+
LOCAL_SRC_FILES += \
265265
jni/src/network/connection.cpp \
266266
jni/src/network/networkpacket.cpp \
267267
jni/src/network/clientopcodes.cpp \
@@ -270,7 +270,7 @@ LOCAL_SRC_FILES += \
270270
jni/src/network/serverpackethandler.cpp \
271271

272272
# lua api
273-
LOCAL_SRC_FILES += \
273+
LOCAL_SRC_FILES += \
274274
jni/src/script/common/c_content.cpp \
275275
jni/src/script/common/c_converter.cpp \
276276
jni/src/script/common/c_internal.cpp \
@@ -310,11 +310,10 @@ LOCAL_SRC_FILES += \
310310
jni/src/script/scripting_mainmenu.cpp
311311

312312
#freetype2 support
313-
LOCAL_SRC_FILES += \
314-
jni/src/cguittfont/xCGUITTFont.cpp
313+
LOCAL_SRC_FILES += jni/src/cguittfont/xCGUITTFont.cpp
315314

316-
# lua
317-
LOCAL_SRC_FILES += \
315+
# Lua
316+
LOCAL_SRC_FILES += \
318317
jni/src/lua/src/lapi.c \
319318
jni/src/lua/src/lauxlib.c \
320319
jni/src/lua/src/lbaselib.c \
@@ -374,3 +373,4 @@ ifdef GPROF
374373
$(call import-module,android-ndk-profiler)
375374
endif
376375
$(call import-module,android/native_app_glue)
376+

‎build/android/jni/Application.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# NDK_TOOLCHAIN_VERSION := clang3.3
1+
# NDK_TOOLCHAIN_VERSION := clang3.8
22

33
APP_PLATFORM := android-9
44
APP_MODULES := minetest
55
APP_STL := gnustl_static
66

77
APP_CPPFLAGS += -fexceptions
88
APP_GNUSTL_FORCE_CPP_FEATURES := rtti
9+
File renamed without changes.
File renamed without changes.

‎build/android/project.properties

-1
This file was deleted.

‎build/android/settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rootProject.name = "Minetest"
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<uses-permission android:name="android.permission.SET_DEBUG_APP" />
4+
</manifest>
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="net.minetest.minetest"
4+
android:installLocation="auto">
5+
<uses-feature android:glEsVersion="0x00010000" android:required="true"/>
6+
<uses-permission android:name="android.permission.INTERNET" />
7+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
8+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9+
<application android:icon="@drawable/irr_icon"
10+
android:label="${project}"
11+
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
12+
android:allowBackup="true">
13+
<activity android:name=".MtNativeActivity"
14+
android:label="${project}"
15+
android:launchMode="singleTask"
16+
android:configChanges="orientation|keyboard|keyboardHidden|navigation"
17+
android:screenOrientation="sensorLandscape"
18+
android:clearTaskOnLaunch="true">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
<category android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
<meta-data android:name="android.app.lib_name" android:value="minetest" />
24+
</activity>
25+
<activity android:name=".MinetestTextEntry"
26+
android:theme="@style/Theme.Transparent"
27+
android:excludeFromRecents="true">
28+
</activity>
29+
<activity android:name=".MinetestAssetCopy"
30+
android:theme="@style/Theme.Transparent"
31+
android:excludeFromRecents="true">
32+
</activity>
33+
</application>
34+
</manifest>

‎build/android/res/layout/assetcopy.xml ‎build/android/src/main/res/layout/assetcopy.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
android:ellipsize="middle"
1919
android:singleLine="true"
2020
android:layout_gravity="center_horizontal"
21-
android:text="preparing media ..."
21+
android:text="@string/preparing_media"
2222
android:textAppearance="?android:attr/textAppearanceSmall" />
2323

2424
</LinearLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="preparing_media">Preparing media...</string>
4+
</resources>
5+

‎util/bump_version.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ cd ${0%/*}/..
3232
grep -q -E '^set\(VERSION_MAJOR [0-9]+\)$' CMakeLists.txt || die "error: Could not find CMakeLists.txt"
3333
grep -q -E '^set\(VERSION_MINOR [0-9]+\)$' CMakeLists.txt || die "error: Could not find CMakeLists.txt"
3434
grep -q -E '^set\(VERSION_PATCH [0-9]+\)$' CMakeLists.txt || die "error: Could not find CMakeLists.txt"
35-
grep -q -E '^ANDROID_VERSION_CODE = [0-9]+$' build/android/Makefile || die "error: Could not find build/android/Makefile"
35+
grep -q -E 'versionCode [0-9]+$' build/android/build.gradle || die "error: Could not find Android version code"
3636

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

4242
echo "Current Minetest version: $VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
4343
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
8989

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

92-
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"
92+
sed -i -re "s/versionCode [0-9]+$/versionCode $NEW_ANDROID_VERSION_CODE/" build/android/build.gradle || die "Failed to update Android version code"
9393

9494
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"
9595

9696
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"
9797

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.