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:
parent
976d0710d0
commit
493d0b451b
@ -15,6 +15,9 @@ gobind {
|
||||
// GOPATH
|
||||
GOPATH "/home/gopher"
|
||||
|
||||
// Optional list of architectures. Defaults to all supported architectures.
|
||||
GOARCH="arm amd64"
|
||||
|
||||
// Absolute path to the gomobile binary
|
||||
GOMOBILE "/mypath/bin/gomobile"
|
||||
|
||||
|
@ -64,6 +64,7 @@ class GobindTask extends DefaultTask implements OutputFileTask {
|
||||
def gomobile = (project.gobind.GOMOBILE ?: findExecutable("gomobile", paths))?.trim()
|
||||
def gobin = (project.gobind.GO ?: findExecutable("go", paths))?.trim()
|
||||
def gomobileFlags = project.gobind.GOMOBILEFLAGS?.trim()
|
||||
def goarch = project.gobind.GOARCH?.trim()
|
||||
|
||||
if (!gomobile || !gobin) {
|
||||
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 {
|
||||
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) {
|
||||
cmd = (cmd+gomobileFlags.split(" ")).flatten()
|
||||
cmd = cmd+gomobileFlags.split(" ")
|
||||
}
|
||||
cmd << pkg
|
||||
|
||||
@ -137,6 +143,9 @@ class GobindExtension {
|
||||
// GOPATH: necessary for gomobile tool. (required)
|
||||
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)
|
||||
def String GO = ""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user