mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 03:11:30 +00:00
Merge pull request #75 from Zillode/master
This commit is contained in:
commit
9b84dd8297
9 changed files with 157 additions and 31 deletions
11
.gitignore
vendored
11
.gitignore
vendored
|
@ -33,3 +33,14 @@ proguard/
|
|||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Gradle wrapper
|
||||
gradle/wrapper/gradle/
|
||||
gradle/wrapper/gradlew*
|
||||
|
||||
# Syncthing native dependencies
|
||||
ext/syncthing/pkg/
|
||||
ext/syncthing/src/code.google.com/
|
||||
ext/syncthing/src/github.com/kr/
|
||||
ext/syncthing/src/github.com/mattn/
|
||||
ext/syncthing/src/github.com/tools/
|
||||
|
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "ext/syncthing/src/github.com/syncthing/syncthing"]
|
||||
path = ext/syncthing/src/github.com/syncthing/syncthing
|
||||
url = https://github.com/syncthing/syncthing.git
|
27
README.md
27
README.md
|
@ -1,17 +1,32 @@
|
|||
## syncthing-android
|
||||
|
||||
A wrapper of [syncthing](https://github.com/calmh/syncthing) for Android.
|
||||
A wrapper of [syncthing](https://github.com/syncthing/syncthing) for Android.
|
||||
|
||||
[![Get it on Google Play](https://developer.android.com/images/brand/en_generic_rgb_wo_60.png)](https://play.google.com/store/apps/details?id=com.nutomic.syncthingandroid)
|
||||
|
||||
## Requirements
|
||||
- sudo apt-get install build-essential
|
||||
- Android SDK 19+ and the Android Support Repository are required.
|
||||
- Use `git clone --recursive https://github.com/Nutomic/syncthing-android` to download the source and its submodules.
|
||||
|
||||
## Building
|
||||
|
||||
To get syncthing app for android running on you device/emulator the native syncthing binary has to be available. There are multiple ways to get the native syncthing binary:
|
||||
- open a syncthing apk (the one taken from the play store) running on your device as a zip, extract the `lib/` folder into your project directory and rename it to `libs/`.
|
||||
- Depending on your target architecture, download `syncthing-linux-386`, `syncthing-linux-armv5`, `syncthing-linux-armv7` or `syncthing-linux-mips` from [syncthing releases](https://github.com/calmh/syncthing/releases), and extract the binary to `libs/x86/libsyncthing.so`, `libs/armeabi-v7a/libsyncthing.so`, `libs/armeabi/libsyncthing.so` or `libs/mips/libsyncthing.so` respectively.
|
||||
- Set up a syncthing compile and run `gradle buildNative` in your syncthing-android directory.
|
||||
Use `gradlew assembleDebug` to compile the APK.
|
||||
|
||||
Note: Gradlew is a gradle wrapper which allows to specify the gradle version. Use `gradle -b gradle/wrapper/build.xml wrapper` to create your own gradlew instance. Then add it to your path using `export PATH=$PATH:$(pwd)/gradle/wrapper`.
|
||||
|
||||
The build process follows three phases:
|
||||
- It downloads and compiles Golang v1.3 for x86 and ARM cross-compilation: Syncthing-android depends on Syncthing "native" (https://github.com/syncthing/syncthing) and this requires Go v1.3.
|
||||
- The Syncthing native libraries are compiled for the different architectures using `gradlew buildNative`.
|
||||
- The final APK is built using the `gradlew assembleDebug` task.
|
||||
|
||||
|
||||
## Getting Syncthing without building natively
|
||||
|
||||
To get Syncthing app for Android running on you device/emulator the native syncthing binary has to be available. There are multiple ways to get the native syncthing binary:
|
||||
- open the Syncthing apk (the one taken from the play store) running on your device as a zip, extract the `lib/` folder into your project directory and rename it to `libs/`.
|
||||
- Depending on your target architecture, download `syncthing-linux-386`, `syncthing-linux-armv5`, `syncthing-linux-armv7` or `syncthing-linux-mips` from [syncthing releases](https://github.com/calmh/syncthing/releases), and extract the binary to `libs/x86/libsyncthing.so`, `libs/armeabi/libsyncthing.so`, `libs/armeabi-v7a/libsyncthing.so` or `libs/mips/libsyncthing.so` respectively.
|
||||
|
||||
Then, run `gradle assembleDebug`.
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd "$GOPATH/src/github.com/syncthing/syncthing/"
|
||||
|
||||
rm bin/
|
||||
|
||||
./build.sh test || exit 1
|
||||
|
||||
export GOOS=linux
|
||||
export ENVIRONMENT=android
|
||||
|
||||
GOARCH=386 ./build.sh "" -tags noupgrade
|
||||
mv bin/linux_386/syncthing bin/syncthing-x86
|
||||
|
||||
GOARCH=arm GOARM=5 ./build.sh "" -tags noupgrade
|
||||
mv bin/linux_arm/syncthing bin/syncthing-armeabi
|
||||
|
||||
GOARCH=arm GOARM=7 ./build.sh "" -tags noupgrade
|
||||
mv bin/linux_arm/syncthing bin/syncthing-armeabi-v7a
|
86
build-syncthing.sh
Executable file
86
build-syncthing.sh
Executable file
|
@ -0,0 +1,86 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# Build the syncthing library
|
||||
ORIG=$(pwd)
|
||||
mkdir -p bin
|
||||
|
||||
# Load submodules
|
||||
if [ ! -f "ext/syncthing/src/github.com/syncthing/syncthing/.git" ]; then
|
||||
git submodule update --init --recursive
|
||||
fi
|
||||
|
||||
# Check for GOLANG installation
|
||||
if [ -z $GOROOT ]; then
|
||||
mkdir -p "build"
|
||||
tmpgo='build/go'
|
||||
if [ ! -f "$tmpgo/bin/go" ]; then
|
||||
# Download GOLANG v1.3
|
||||
wget -O go.src.tar.gz https://golang.org/dl/go1.3.src.tar.gz
|
||||
sha1=$(sha1sum go.src.tar.gz)
|
||||
if [ "$sha1" != "9f9dfcbcb4fa126b2b66c0830dc733215f2f056e go.src.tar.gz" ]; then
|
||||
echo "go.src.tar.gz SHA1 checksum does not match!"
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p $tmpgo
|
||||
tar -xzf go.src.tar.gz --strip=1 -C $tmpgo
|
||||
rm go.src.tar.gz
|
||||
# Build GO for host
|
||||
pushd $tmpgo/src
|
||||
./make.bash --no-clean
|
||||
popd
|
||||
fi
|
||||
# Add GO to the environment
|
||||
export GOROOT="$(readlink -e $tmpgo)"
|
||||
fi
|
||||
|
||||
# Add GO compiler to PATH
|
||||
export PATH=$PATH:$GOROOT/bin
|
||||
|
||||
# Check whether GOLANG is compiled with cross-compilation for 386
|
||||
if [ ! -f $GOROOT/bin/linux_386/go ]; then
|
||||
pushd $GOROOT/src
|
||||
# Build GO for cross-compilation
|
||||
GOOS=linux GOARCH=386 ./make.bash --no-clean
|
||||
popd
|
||||
fi
|
||||
|
||||
# Check whether GOLANG is compiled with cross-compilation for arm
|
||||
if [ ! -f $GOROOT/bin/linux_arm/go ]; then
|
||||
pushd $GOROOT/src
|
||||
# Build GO for cross-compilation
|
||||
GOOS=linux GOARCH=arm ./make.bash --no-clean
|
||||
popd
|
||||
fi
|
||||
|
||||
# Setup GOPATH
|
||||
cd "ext/syncthing/"
|
||||
export GOPATH="$(pwd)"
|
||||
|
||||
# Install godep
|
||||
$GOROOT/bin/go get github.com/tools/godep
|
||||
export PATH="$(readlink -e bin)":$PATH
|
||||
|
||||
# Install dependencies
|
||||
cd src/github.com/syncthing/syncthing
|
||||
./build.sh setup || true
|
||||
|
||||
# Build test
|
||||
#./build.sh test || exit 1
|
||||
|
||||
export GOOS=linux
|
||||
export ENVIRONMENT=android
|
||||
|
||||
# X86
|
||||
$GOROOT/bin/go run build.go -goos linux -goarch 386 -no-upgrade build
|
||||
mv syncthing $ORIG/bin/syncthing-x86
|
||||
$GOROOT/bin/go run build.go clean
|
||||
|
||||
# ARM-7
|
||||
$GOROOT/bin/go run build.go -goos linux -goarch armv7 -no-upgrade build
|
||||
mv syncthing $ORIG/bin/syncthing-armeabi-v7a
|
||||
$GOROOT/bin/go run build.go clean
|
||||
|
||||
# ARM-5
|
||||
$GOROOT/bin/go run build.go -goos linux -goarch armv5 -no-upgrade build
|
||||
mv syncthing $ORIG/bin/syncthing-armeabi
|
||||
$GOROOT/bin/go run build.go clean
|
32
build.gradle
32
build.gradle
|
@ -22,6 +22,10 @@ dependencies {
|
|||
compile 'com.android.support:appcompat-v7:19.1.+'
|
||||
}
|
||||
|
||||
preBuild {
|
||||
dependsOn 'buildNative'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "19.1.0"
|
||||
|
@ -84,6 +88,9 @@ android {
|
|||
abiFilter "mips"
|
||||
}
|
||||
}
|
||||
fat {
|
||||
versionCode Integer.parseInt("0" + defaultConfig.versionCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,19 +104,32 @@ def getVersionCodeFromManifest() {
|
|||
|
||||
task buildNative(type: Exec) {
|
||||
outputs.upToDateWhen { false }
|
||||
executable = './build-native.sh'
|
||||
executable = './build-syncthing.sh'
|
||||
}
|
||||
|
||||
task copyNative(type: Copy) {
|
||||
def st_dir = System.getenv("GOPATH") + "/src/github.com/syncthing/syncthing/bin/";
|
||||
from st_dir + 'syncthing-x86', st_dir + 'syncthing-armeabi-v7a', st_dir + 'syncthing-armeabi';
|
||||
into 'libs/'
|
||||
def lib_dir = "libs/"
|
||||
new File(lib_dir).mkdirs()
|
||||
def st_dir = "bin/";
|
||||
from st_dir + 'syncthing-x86', st_dir + 'syncthing-armeabi', st_dir + 'syncthing-armeabi-v7a';
|
||||
into lib_dir
|
||||
rename('syncthing-x86', 'x86/libsyncthing.so')
|
||||
rename('syncthing-armeabi-v7a', 'armeabi-v7a/libsyncthing.so')
|
||||
rename('syncthing-armeabi', 'armeabi/libsyncthing.so')
|
||||
}
|
||||
buildNative.finalizedBy copyNative
|
||||
|
||||
task cleanNative(type: Delete) {
|
||||
delete 'libs/'
|
||||
task cleanBin(type: Delete) {
|
||||
delete 'bin/'
|
||||
}
|
||||
copyNative.finalizedBy cleanBin
|
||||
|
||||
task cleanNative(type: Delete) {
|
||||
delete 'bin/'
|
||||
delete 'build/'
|
||||
delete 'libs/'
|
||||
delete 'ext/syncthing/bin/'
|
||||
delete 'ext/syncthing/pkg/'
|
||||
}
|
||||
clean.dependsOn cleanNative
|
||||
|
||||
|
|
1
ext/syncthing/src/github.com/syncthing/syncthing
Submodule
1
ext/syncthing/src/github.com/syncthing/syncthing
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit c57656e4c3162fcdfc99eaee95bf4b2473dbbb72
|
3
gradle/wrapper/build.xml
vendored
Normal file
3
gradle/wrapper/build.xml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '1.12'
|
||||
}
|
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
#Mon Aug 04 01:49:45 CEST 2014
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-bin.zip
|
Loading…
Reference in a new issue