2014-05-12 16:54:26 +00:00
|
|
|
buildscript {
|
2014-05-14 15:08:19 +00:00
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
2014-05-12 16:54:26 +00:00
|
|
|
|
2014-05-14 15:08:19 +00:00
|
|
|
dependencies {
|
2014-07-13 14:15:35 +00:00
|
|
|
classpath 'com.android.tools.build:gradle:0.12.+'
|
2014-06-09 21:49:58 +00:00
|
|
|
classpath 'com.alexvasilkov:android_sign:0.2+'
|
2014-05-14 15:08:19 +00:00
|
|
|
}
|
2014-05-12 16:54:26 +00:00
|
|
|
}
|
|
|
|
|
2014-05-17 20:57:04 +00:00
|
|
|
import java.util.regex.Pattern
|
|
|
|
|
2014-05-12 16:54:26 +00:00
|
|
|
apply plugin: 'android'
|
|
|
|
apply plugin: 'android_sign'
|
|
|
|
|
2014-05-13 08:40:54 +00:00
|
|
|
repositories {
|
2014-05-14 15:08:19 +00:00
|
|
|
mavenCentral()
|
2014-05-13 08:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2014-05-14 21:02:33 +00:00
|
|
|
compile 'com.android.support:appcompat-v7:19.1.+'
|
2014-05-13 08:40:54 +00:00
|
|
|
}
|
|
|
|
|
2014-05-12 16:54:26 +00:00
|
|
|
android {
|
2014-05-14 15:08:19 +00:00
|
|
|
compileSdkVersion 19
|
2014-06-09 21:49:58 +00:00
|
|
|
buildToolsVersion "19.1.0"
|
2014-05-17 20:57:04 +00:00
|
|
|
|
2014-05-18 23:21:13 +00:00
|
|
|
defaultConfig {
|
2014-05-17 20:57:04 +00:00
|
|
|
versionCode getVersionCodeFromManifest()
|
|
|
|
}
|
|
|
|
|
2014-05-14 15:08:19 +00:00
|
|
|
sourceSets {
|
2014-05-12 16:54:26 +00:00
|
|
|
main {
|
|
|
|
jniLibs.srcDir file("libs/")
|
|
|
|
}
|
|
|
|
}
|
2014-05-17 20:57:04 +00:00
|
|
|
|
2014-05-14 15:08:19 +00:00
|
|
|
signingConfigs {
|
|
|
|
release {
|
|
|
|
// Android Studio does not pass environment variables.
|
|
|
|
// This means you have to use the command line for release builds.
|
|
|
|
def ks = System.getenv("KEYSTORE")
|
|
|
|
def ka = System.getenv("KEY_ALIAS")
|
|
|
|
if (ks != null && ka != null) {
|
|
|
|
storeFile file(ks)
|
|
|
|
keyAlias ka
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-12 16:54:26 +00:00
|
|
|
|
2014-05-14 15:08:19 +00:00
|
|
|
buildTypes {
|
|
|
|
debug {
|
2014-06-09 21:49:58 +00:00
|
|
|
applicationIdSuffix ".debug"
|
2014-05-14 15:08:19 +00:00
|
|
|
debuggable true
|
|
|
|
}
|
|
|
|
release {
|
|
|
|
signingConfig signingConfigs.release
|
|
|
|
}
|
|
|
|
}
|
2014-05-17 20:57:04 +00:00
|
|
|
|
|
|
|
productFlavors {
|
|
|
|
x86 {
|
|
|
|
versionCode Integer.parseInt("4" + defaultConfig.versionCode)
|
|
|
|
ndk {
|
|
|
|
abiFilter "x86"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
armeabi_v7a {
|
|
|
|
versionCode Integer.parseInt("3" + defaultConfig.versionCode)
|
|
|
|
ndk {
|
|
|
|
abiFilter "armeabi-v7a"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
armeabi {
|
|
|
|
versionCode Integer.parseInt("2" + defaultConfig.versionCode)
|
|
|
|
ndk {
|
|
|
|
abiFilter "armeabi"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mips {
|
|
|
|
versionCode Integer.parseInt("1" + defaultConfig.versionCode)
|
|
|
|
ndk {
|
|
|
|
abiFilter "mips"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def getVersionCodeFromManifest() {
|
|
|
|
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
|
|
|
|
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
|
|
|
|
def matcher = pattern.matcher(manifestFile.getText())
|
|
|
|
matcher.find()
|
|
|
|
return Integer.parseInt(matcher.group(1))
|
2014-05-12 16:54:26 +00:00
|
|
|
}
|
2014-05-17 20:57:04 +00:00
|
|
|
|
2014-06-27 15:24:23 +00:00
|
|
|
task buildNative(type: Exec) {
|
2014-05-17 20:57:04 +00:00
|
|
|
outputs.upToDateWhen { false }
|
2014-05-18 13:18:42 +00:00
|
|
|
executable = './build-native.sh'
|
2014-05-17 20:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
task copyNative(type: Copy) {
|
|
|
|
outputs.upToDateWhen { false }
|
2014-05-18 13:18:42 +00:00
|
|
|
def st_dir = System.getenv("GOPATH") + "/src/github.com/calmh/syncthing/";
|
2014-05-17 20:57:04 +00:00
|
|
|
from st_dir + 'syncthing-x86', st_dir + 'syncthing-armeabi', st_dir + 'syncthing-armeabi-v7a';
|
|
|
|
into 'libs/'
|
|
|
|
rename('syncthing-x86', 'x86/libsyncthing.so')
|
|
|
|
rename('syncthing-armeabi-v7a', 'armeabi-v7a/libsyncthing.so')
|
|
|
|
rename('syncthing-armeabi', 'armeabi/libsyncthing.so')
|
|
|
|
rename('syncthing-mips', 'mips/libsyncthing.so')
|
|
|
|
}
|
|
|
|
buildNative.finalizedBy copyNative
|
|
|
|
|
|
|
|
task cleanNative(type: Delete) {
|
|
|
|
delete 'libs/'
|
2014-05-18 13:18:42 +00:00
|
|
|
}
|