forked from x0b/rcx
-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/gopath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
def repository = 'github.com/rclone/rclone' | ||
def buildTag = 'v1.51.0' | ||
|
||
import java.nio.file.Paths | ||
def osName = System.properties['os.name'].toLowerCase() | ||
def osArch = System.properties['os.arch'] | ||
def String os | ||
if (osName.contains('windows')) { | ||
if(osArch.equals('amd64')) { | ||
os = "windows-x86_64" | ||
} else if (osArch.equals('x86')) { | ||
os = "windows" | ||
} | ||
} else if (osName.contains("linux")) { | ||
os = "linux-x86_64" | ||
} else if (osName.contains('mac')) { | ||
os = "darwin-x86_64" | ||
} | ||
|
||
task fetchRclone(type: Exec) { | ||
mkdir "gopath" | ||
environment 'GOPATH', Paths.get(projectDir.absolutePath, 'gopath') | ||
commandLine 'go', 'get', '-d', repository | ||
} | ||
|
||
task checkoutRclone(type: Exec) { | ||
dependsOn fetchRclone | ||
workingDir Paths.get(System.getenv('GOPATH'), "src/${repository}".split('/')) | ||
commandLine 'git', 'checkout', buildTag | ||
} | ||
|
||
task cleanNative { | ||
enabled = false | ||
doLast { | ||
delete '../app/lib/armeabi-v7a/librclone.so' | ||
delete '../app/lib/arm64-v8a/librclone.so' | ||
delete '../app/lib/x86/librclone.so' | ||
delete '../app/lib/x86_64/librclone.so' | ||
} | ||
} | ||
|
||
task buildArm(type: Exec) { | ||
dependsOn checkoutRclone | ||
environment 'GOPATH', Paths.get(projectDir.absolutePath, 'gopath') | ||
def String crossCompiler = Paths.get(System.getenv('ANDROID_HOME'), 'ndk-bundle', 'toolchains', 'llvm', 'prebuilt', os, 'bin', 'armv7a-linux-androideabi21-clang') | ||
environment 'CC', crossCompiler | ||
environment 'CC_FOR_TARGET', crossCompiler | ||
environment 'GOOS', 'android' | ||
environment 'GOARCH', 'arm' | ||
environment 'GOARM', '7' | ||
environment 'CGO_ENABLED', '1' | ||
commandLine 'go', 'build', '-v', '-tags', 'linux', '-o', '../app/lib/armeabi-v7a/librclone.so', repository | ||
} | ||
|
||
task buildArm64(type: Exec) { | ||
dependsOn checkoutRclone | ||
environment 'GOPATH', Paths.get(projectDir.absolutePath, 'gopath') | ||
def String crossCompiler = Paths.get(System.getenv('ANDROID_HOME'), 'ndk-bundle', 'toolchains', 'llvm', 'prebuilt', os, 'bin', 'aarch64-linux-android21-clang') | ||
environment 'CC', crossCompiler | ||
environment 'CC_FOR_TARGET', crossCompiler | ||
environment 'GOOS', 'android' | ||
environment 'GOARCH', 'arm64' | ||
environment 'CGO_ENABLED', '1' | ||
commandLine 'go', 'build', '-v', '-tags', 'linux', '-o', '../app/lib/arm64-v8a/librclone.so', repository | ||
} | ||
|
||
task buildx86(type: Exec) { | ||
dependsOn checkoutRclone | ||
environment 'GOPATH', Paths.get(projectDir.absolutePath, 'gopath') | ||
def String crossCompiler = Paths.get(System.getenv('ANDROID_HOME'), 'ndk-bundle', 'toolchains', 'llvm', 'prebuilt', os, 'bin', 'i686-linux-android21-clang') | ||
environment 'CC', crossCompiler | ||
environment 'CC_FOR_TARGET', crossCompiler | ||
environment 'GOOS', 'android' | ||
environment 'GOARCH', '386' | ||
environment 'CGO_ENABLED', '1' | ||
commandLine 'go', 'build', '-v', '-tags', 'linux', '-o', '../app/lib/x86/librclone.so', repository | ||
} | ||
|
||
task buildx64(type: Exec) { | ||
dependsOn checkoutRclone | ||
environment 'GOPATH', Paths.get(projectDir.absolutePath, 'gopath') | ||
def String crossCompiler = Paths.get(System.getenv('ANDROID_HOME'), 'ndk-bundle', 'toolchains', 'llvm', 'prebuilt', os, 'bin', 'x86_64-linux-android21-clang') | ||
environment 'CC', crossCompiler | ||
environment 'CC_FOR_TARGET', crossCompiler | ||
environment 'GOOS', 'android' | ||
environment 'GOARCH', 'amd64' | ||
environment 'CGO_ENABLED', '1' | ||
commandLine 'go', 'build', '-v', '-tags', 'linux', '-o', '../app/lib/x86_64/librclone.so', repository | ||
} | ||
|
||
task buildNative { | ||
dependsOn fetchRclone | ||
dependsOn checkoutRclone | ||
dependsOn buildArm | ||
dependsOn buildArm64 | ||
dependsOn buildx86 | ||
dependsOn buildx64 | ||
} | ||
|
||
buildNative.mustRunAfter(buildArm, buildArm64, buildx86, buildx64) | ||
defaultTasks 'buildNative' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
include ':app', ':safdav' | ||
include ':app', ':safdav', ':rclone' |