summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2016-06-15 15:21:18 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2016-06-27 10:49:15 +0200
commite7b2626707457fe1d6af36da3d7a1ec3863cd52f (patch)
treee26d425d30bc9ce108ab260e8aff8fca181a3dba
parent2c59f778850dc4450481680e859efd66660c9119 (diff)
Make Android build smarter (SCons + Gradle)
Upgrade Gradle and Android plugin for Gradle Disable all signing and zip-aligning for the export templates Give correct names to generated APKs Put .so files built by SCons right where Gradle has to pick them according to arch & build type Downgrade NDK platform to 14 to match minSdkVersion
-rw-r--r--.gitignore9
-rw-r--r--platform/android/SCsub20
-rw-r--r--platform/android/build.gradle.template22
-rw-r--r--platform/android/detect.py2
-rw-r--r--platform/android/export/export.cpp2
-rw-r--r--platform/android/java/gradle/wrapper/gradle-wrapper.properties2
6 files changed, 41 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index e1941b18df..f3a4e9714c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,17 +37,10 @@ platform/android/java/.gradle
platform/android/java/.gradletasknamecache
platform/android/java/local.properties
platform/android/java/project.properties
+platform/android/java/build.gradle
platform/android/java/AndroidManifest.xml
-platform/android/java/bin/*
platform/android/java/libs/*
-platform/android/java/gen/*
platform/android/java/assets
-platform/android/libs/apk_expansion/bin/*
-platform/android/libs/apk_expansion/gen/*
-platform/android/libs/google_play_services/bin/*
-platform/android/libs/google_play_services/gen/*
-platform/android/libs/play_licensing/bin/*
-platform/android/libs/play_licensing/gen/*
# General c++ generated files
*.lib
diff --git a/platform/android/SCsub b/platform/android/SCsub
index c8feac8690..9fcf73972f 100644
--- a/platform/android/SCsub
+++ b/platform/android/SCsub
@@ -103,4 +103,22 @@ pp_baseout.write( manifest )
env_android.SharedLibrary("#bin/libgodot",[android_objects],SHLIBSUFFIX=env["SHLIBSUFFIX"])
-#env.Command('#bin/libgodot_android.so', '#platform/android/libgodot_android.so', Copy('bin/libgodot_android.so', 'platform/android/libgodot_android.so'))
+
+lib_arch_dir = ''
+if env['android_arch'] == 'armv6':
+ lib_arch_dir = 'armeabi'
+elif env['android_arch'] == 'armv7':
+ lib_arch_dir = 'armeabi-v7a'
+elif env['android_arch'] == 'x86':
+ lib_arch_dir = 'x86'
+else:
+ print 'WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin'
+
+if lib_arch_dir != '':
+ if env['target'] == 'release':
+ lib_type_dir = 'release'
+ else: # release_debug, debug
+ lib_type_dir = 'debug'
+
+ out_dir = '#platform/android/java/libs/'+lib_type_dir+'/'+lib_arch_dir
+ env_android.Command(out_dir+'/libgodot_android.so', '#bin/libgodot'+env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE"))
diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template
index 1e1461ef29..d7bc615e37 100644
--- a/platform/android/build.gradle.template
+++ b/platform/android/build.gradle.template
@@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.3.1'
+ classpath 'com.android.tools.build:gradle:2.1.0'
}
}
@@ -40,6 +40,11 @@ android {
minSdkVersion 14
targetSdkVersion 23
}
+ // Both signing and zip-aligning will be done at export time
+ buildTypes.all { buildType ->
+ buildType.zipAlignEnabled false
+ buildType.signingConfig null
+ }
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
@@ -65,8 +70,17 @@ android {
$$GRADLE_JNI_DIRS$$
]
}
-
+ debug.jniLibs.srcDirs = [
+ 'libs/debug'
+ $$GRADLE_JNI_DIRS$$
+ ]
+ release.jniLibs.srcDirs = [
+ 'libs/release'
+ $$GRADLE_JNI_DIRS$$
+ ]
+ }
+ applicationVariants.all { variant ->
+ // ApplicationVariant is undocumented, but this method is widely used; may break with another version of the Android Gradle plugin
+ variant.outputs.get(0).setOutputFile(new File("${projectDir}/../../../bin", "android_${variant.name}.apk"))
}
-
-
}
diff --git a/platform/android/detect.py b/platform/android/detect.py
index ba6b73a89f..6fd0b81d91 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -23,7 +23,7 @@ def get_opts():
('ANDROID_NDK_ROOT', 'the path to Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)),
('NDK_TARGET', 'toolchain to use for the NDK',os.environ.get("NDK_TARGET", "arm-linux-androideabi-4.9")),
('NDK_TARGET_X86', 'toolchain to use for the NDK x86',os.environ.get("NDK_TARGET_X86", "x86-4.9")),
- ('ndk_platform', 'compile for platform: (android-<api> , example: android-15)',"android-15"),
+ ('ndk_platform', 'compile for platform: (android-<api> , example: android-14)',"android-14"),
('android_arch', 'select compiler architecture: (armv7/armv6/x86)',"armv7"),
('android_neon','enable neon (armv7 only)',"yes"),
('android_stl','enable STL support in android port (for modules)',"no")
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 872f047c95..83f7292716 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -1166,7 +1166,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
skip=true;
}
- if (file=="lib/armeabi/libgodot_android.so" && !export_arm) {
+ if (file.match("lib/armeabi*/libgodot_android.so") && !export_arm) {
skip=true;
}
diff --git a/platform/android/java/gradle/wrapper/gradle-wrapper.properties b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
index 0c71e760dc..d57051703e 100644
--- a/platform/android/java/gradle/wrapper/gradle-wrapper.properties
+++ b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip