2
0
mirror of synced 2025-02-24 07:18:15 +00:00

modbile/misc/androidstudio: add GOARCH to the gradle plugin

Add GOARCH to the gobind gradle plugin to limit the architectures to
include in the fat .aar file. If GOARCH is empty or not specified,
every supported architecture is included.

GobindPlugin.groovy was indented with both tabs and (a varying number
of) spaces, so it is re-indented here with tabs. Sorry.

For golang/go#12819

Change-Id: I8b2cb72068df7750d20f474395944ca2968a2f1b
Reviewed-on: https://go-review.googlesource.com/20305
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Elias Naur 2016-03-07 18:46:38 +01:00
parent 976d0710d0
commit 493d0b451b
2 changed files with 85 additions and 73 deletions

View File

@ -15,6 +15,9 @@ gobind {
// GOPATH // GOPATH
GOPATH "/home/gopher" GOPATH "/home/gopher"
// Optional list of architectures. Defaults to all supported architectures.
GOARCH="arm amd64"
// Absolute path to the gomobile binary // Absolute path to the gomobile binary
GOMOBILE "/mypath/bin/gomobile" GOMOBILE "/mypath/bin/gomobile"

View File

@ -64,6 +64,7 @@ class GobindTask extends DefaultTask implements OutputFileTask {
def gomobile = (project.gobind.GOMOBILE ?: findExecutable("gomobile", paths))?.trim() def gomobile = (project.gobind.GOMOBILE ?: findExecutable("gomobile", paths))?.trim()
def gobin = (project.gobind.GO ?: findExecutable("go", paths))?.trim() def gobin = (project.gobind.GO ?: findExecutable("go", paths))?.trim()
def gomobileFlags = project.gobind.GOMOBILEFLAGS?.trim() def gomobileFlags = project.gobind.GOMOBILEFLAGS?.trim()
def goarch = project.gobind.GOARCH?.trim()
if (!gomobile || !gobin) { if (!gomobile || !gobin) {
throw new GradleException('failed to find gomobile/go tools. Set gobind.GOMOBILE and gobind.GO') throw new GradleException('failed to find gomobile/go tools. Set gobind.GOMOBILE and gobind.GO')
@ -87,9 +88,14 @@ class GobindTask extends DefaultTask implements OutputFileTask {
project.exec { project.exec {
executable(gomobile) executable(gomobile)
def cmd = ["bind", "-target=android", "-i", "-o", project.name+".aar"] def cmd = ["bind", "-i", "-o", project.name+".aar", "-target"]
if (goarch) {
cmd = cmd+goarch.split(" ").collect{ 'android/'+it }.join(",")
} else {
cmd << "android"
}
if (gomobileFlags) { if (gomobileFlags) {
cmd = (cmd+gomobileFlags.split(" ")).flatten() cmd = cmd+gomobileFlags.split(" ")
} }
cmd << pkg cmd << pkg
@ -137,6 +143,9 @@ class GobindExtension {
// GOPATH: necessary for gomobile tool. (required) // GOPATH: necessary for gomobile tool. (required)
def String GOPATH = System.getenv("GOPATH") def String GOPATH = System.getenv("GOPATH")
// GOARCH: (List of) GOARCH to include.
def String GOARCH = ""
// GO: path to go tool. (can omit if 'go' is in the paths visible by Android Studio) // GO: path to go tool. (can omit if 'go' is in the paths visible by Android Studio)
def String GO = "" def String GO = ""