1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 03:11:30 +00:00

Added gradle flavors for different native platforms, and buildNative task.

This commit is contained in:
Felix Ableitner 2014-05-17 22:57:04 +02:00
parent e3219ef80d
commit c78c6a51f1
2 changed files with 69 additions and 2 deletions

View file

@ -6,7 +6,9 @@ A port of [syncthing](https://github.com/calmh/syncthing) to Android.
## Building
Download or execute syncthing for your target platform, put the binary in `libs/armeabi`, `libs/armeabi-v7a`, `libs/mips`, `libs/x86`, (depending on target platform) and rename it to `libsyncthing.so`.
There are multiple ways to get the native syncthing binary:
- Depending on your target architecture, download `syncthing-linux-386`, `syncthing-linux-armv5` or `syncthing-linux-armv7` from [syncthing releases](https://github.com/calmh/syncthing/releases), and extract the binary to `libs/x86/libsyncthing.so`, `libs/armeabi-v7a/libsyncthing.so` or `libs/armeabi/libsyncthing.so` respectively.
- Set up a syncthing compile and run `gradle buildNative` in your syncthing-android directory.
Then, run `gradle assembleDebug`.

View file

@ -9,6 +9,8 @@ buildscript {
}
}
import java.util.regex.Pattern
apply plugin: 'android'
apply plugin: 'android_sign'
@ -23,12 +25,17 @@ dependencies {
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig{
versionCode getVersionCodeFromManifest()
}
sourceSets {
main {
jniLibs.srcDir file("libs/")
jniLibs.srcDir file("obj/")
}
}
signingConfigs {
release {
// Android Studio does not pass environment variables.
@ -51,4 +58,62 @@ android {
signingConfig signingConfigs.release
}
}
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))
}
ext.st_dir = System.getenv("GOPATH") + "/src/github.com/calmh/syncthing/";
task buildNative(type:Exec) {
outputs.upToDateWhen { false }
executable = st_dir + 'build.sh'
workingDir = st_dir;
args = ['android']
}
task copyNative(type: Copy) {
outputs.upToDateWhen { false }
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/'
}