diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c index 6884e0aae9ba947ce413e324686046f6a85b2d2c..a994367351c30f00edc63ac45b58c960d426afcd 100644 --- a/src/cmd/dist/build.c +++ b/src/cmd/dist/build.c @@ -56,6 +56,7 @@ static char *okgoos[] = { "darwin", "dragonfly", "linux", + "android", "solaris", "freebsd", "nacl", @@ -1149,7 +1150,7 @@ matchfield(char *f) p = xstrrchr(f, ','); if(p == nil) - return streq(f, goos) || streq(f, goarch) || streq(f, "cmd_go_bootstrap") || streq(f, "go1.1"); + return streq(f, goos) || streq(f, goarch) || streq(f, "cmd_go_bootstrap") || streq(f, "go1.1") || (streq(goos, "android") && streq(f, "linux")); *p = 0; res = matchfield(f) && matchfield(p+1); *p = ','; diff --git a/src/cmd/dist/buildruntime.c b/src/cmd/dist/buildruntime.c index 008554d5494905c6833ab8368e5f21a47805c405..b36454f809fc585a12bf6670aefa44ac9435a7a0 100644 --- a/src/cmd/dist/buildruntime.c +++ b/src/cmd/dist/buildruntime.c @@ -108,10 +108,14 @@ mkzgoos(char *dir, char *file) binit(&b); binit(&out); + + bwritestr(&out, "// auto generated by go tool dist\n\n"); + + if (streq(goos, "linux")) { + bwritestr(&out, "// +build !android\n\n"); + } bwritestr(&out, bprintf(&b, - "// auto generated by go tool dist\n" - "\n" "package runtime\n" "\n" "const theGoos = `%s`\n", goos)); diff --git a/src/liblink/sym.c b/src/liblink/sym.c index cba50e9c7eb624d6b59dd388c6fbedaa1410eac1..2b029ce4dcb8a11d76ba1a80bd2fc18766927259 100644 --- a/src/liblink/sym.c +++ b/src/liblink/sym.c @@ -49,6 +49,7 @@ static struct { "elf", Helf, "freebsd", Hfreebsd, "linux", Hlinux, + "android", Hlinux, "nacl", Hnacl, "netbsd", Hnetbsd, "openbsd", Hopenbsd, diff --git a/src/pkg/go/build/build.go b/src/pkg/go/build/build.go index 412abea3a9375d62ab136a30b2ccbc12baeff581..09730d6351b979d65b09dff02dda187cf8e415a1 100644 --- a/src/pkg/go/build/build.go +++ b/src/pkg/go/build/build.go @@ -268,6 +268,9 @@ var cgoEnabled = map[string]bool{ "linux/386": true, "linux/amd64": true, "linux/arm": true, + "android/386": true, + "android/amd64": true, + "android/arm": true, "netbsd/386": true, "netbsd/amd64": true, "netbsd/arm": true, @@ -1124,6 +1127,9 @@ func (ctxt *Context) match(name string, allTags map[string]bool) bool { if name == ctxt.GOOS || name == ctxt.GOARCH || name == ctxt.Compiler { return true } + if ctxt.GOOS == "android" && name == "linux" { + return true + } // other tags for _, tag := range ctxt.BuildTags { @@ -1151,6 +1157,7 @@ func (ctxt *Context) match(name string, allTags map[string]bool) bool { // name_$(GOARCH)_test.* // name_$(GOOS)_$(GOARCH)_test.* // +// An exception: if GOOS=android, then files with GOOS=linux are also matched. func (ctxt *Context) goodOSArchFile(name string, allTags map[string]bool) bool { if dot := strings.Index(name, "."); dot != -1 { name = name[:dot] @@ -1165,12 +1172,21 @@ func (ctxt *Context) goodOSArchFile(name string, allTags map[string]bool) bool { allTags[l[n-2]] = true allTags[l[n-1]] = true } - return l[n-2] == ctxt.GOOS && l[n-1] == ctxt.GOARCH + if l[n-1] != ctxt.GOARCH { + return false + } + if ctxt.GOOS == "android" && l[n-2] == "linux" { + return true + } + return l[n-2] == ctxt.GOOS } if n >= 1 && knownOS[l[n-1]] { if allTags != nil { allTags[l[n-1]] = true } + if ctxt.GOOS == "android" && l[n-1] == "linux" { + return true + } return l[n-1] == ctxt.GOOS } if n >= 1 && knownArch[l[n-1]] { diff --git a/src/pkg/go/build/build_test.go b/src/pkg/go/build/build_test.go index fca8d4bdb27d42da2cdc380d52b129439fd56a21..f0d243cd53fa2fac7957a784a8f3cfe0940d3faf 100644 --- a/src/pkg/go/build/build_test.go +++ b/src/pkg/go/build/build_test.go @@ -153,22 +153,31 @@ func (r readNopCloser) Close() error { return nil } +var ( + ctxtP9 = Context{GOARCH: "arm", GOOS: "plan9"} + ctxtAndroid = Context{GOARCH: "arm", GOOS: "android"} +) + var matchFileTests = []struct { + ctxt Context name string data string match bool }{ - {"foo_arm.go", "", true}, - {"foo1_arm.go", "// +build linux\n\npackage main\n", false}, - {"foo_darwin.go", "", false}, - {"foo.go", "", true}, - {"foo1.go", "// +build linux\n\npackage main\n", false}, - {"foo.badsuffix", "", false}, + {ctxtP9, "foo_arm.go", "", true}, + {ctxtP9, "foo1_arm.go", "// +build linux\n\npackage main\n", false}, + {ctxtP9, "foo_darwin.go", "", false}, + {ctxtP9, "foo.go", "", true}, + {ctxtP9, "foo1.go", "// +build linux\n\npackage main\n", false}, + {ctxtP9, "foo.badsuffix", "", false}, + {ctxtAndroid, "foo_linux.go", "", true}, + {ctxtAndroid, "foo_android.go", "", true}, + {ctxtAndroid, "foo_plan9.go", "", false}, } func TestMatchFile(t *testing.T) { for _, tt := range matchFileTests { - ctxt := Context{GOARCH: "arm", GOOS: "plan9"} + ctxt := tt.ctxt ctxt.OpenFile = func(path string) (r io.ReadCloser, err error) { if path != "x+"+tt.name { t.Fatalf("OpenFile asked for %q, expected %q", path, "x+"+tt.name) diff --git a/src/pkg/go/build/doc.go b/src/pkg/go/build/doc.go index f17f76ccc7bb0566bd134966eb2f28713267429b..d78ef3f1c897625ac8e480de65f16677771a3c37 100644 --- a/src/pkg/go/build/doc.go +++ b/src/pkg/go/build/doc.go @@ -134,4 +134,7 @@ // building the package for Windows; similarly, math_386.s will be included // only when building the package for 32-bit x86. // +// Using GOOS=android matches build tags and files as for GOOS=linux +// in addition to android tags and files. +// package build diff --git a/src/pkg/go/build/syslist.go b/src/pkg/go/build/syslist.go index 5c42b946b09434d060eb70565a22cd71a24880a8..965f873dfb7afeffb509e66ee0fd139b71492196 100644 --- a/src/pkg/go/build/syslist.go +++ b/src/pkg/go/build/syslist.go @@ -4,5 +4,5 @@ package build -const goosList = "darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows " +const goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows " const goarchList = "386 amd64 amd64p32 arm " diff --git a/src/pkg/runtime/defs_android_arm.h b/src/pkg/runtime/defs_android_arm.h new file mode 100644 index 0000000000000000000000000000000000000000..3611b3a1033be9b406192ee544badcb493eae8fe --- /dev/null +++ b/src/pkg/runtime/defs_android_arm.h @@ -0,0 +1,3 @@ +// TODO: Generate using cgo like defs_linux_{386,amd64}.h + +#include "defs_linux_arm.h" diff --git a/src/pkg/runtime/os_android.h b/src/pkg/runtime/os_android.h new file mode 100644 index 0000000000000000000000000000000000000000..c7c1098e8dec91e56c1dc65d003e2d70dc404df3 --- /dev/null +++ b/src/pkg/runtime/os_android.h @@ -0,0 +1 @@ +#include "os_linux.h" diff --git a/src/pkg/runtime/rt0_android_arm.s b/src/pkg/runtime/rt0_android_arm.s new file mode 100644 index 0000000000000000000000000000000000000000..3eecbbddc58cba45c61b971df119b674c1453b38 --- /dev/null +++ b/src/pkg/runtime/rt0_android_arm.s @@ -0,0 +1,11 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "../../cmd/ld/textflag.h" + +TEXT _rt0_arm_android(SB),NOSPLIT,$-4 + MOVW (R13), R0 // argc + MOVW $4(R13), R1 // argv + MOVW $_rt0_arm_linux1(SB), R4 + B (R4) diff --git a/src/pkg/runtime/signal_android_386.h b/src/pkg/runtime/signal_android_386.h new file mode 100644 index 0000000000000000000000000000000000000000..2a1bb4b3e4774b91ecae8f2b3296deb53d85aee6 --- /dev/null +++ b/src/pkg/runtime/signal_android_386.h @@ -0,0 +1 @@ +#include "signal_linux_386.h" diff --git a/src/pkg/runtime/signal_android_arm.h b/src/pkg/runtime/signal_android_arm.h new file mode 100644 index 0000000000000000000000000000000000000000..8a05e21e598dc1ad6d0c9c29ac5dcdfae0e3c169 --- /dev/null +++ b/src/pkg/runtime/signal_android_arm.h @@ -0,0 +1 @@ +#include "signal_linux_arm.h" diff --git a/src/pkg/runtime/signals_android.h b/src/pkg/runtime/signals_android.h new file mode 100644 index 0000000000000000000000000000000000000000..5140d8a1844464d0ab634abe301a36bb8d51682f --- /dev/null +++ b/src/pkg/runtime/signals_android.h @@ -0,0 +1 @@ +#include "signals_linux.h"