As android and linux have significant overlap, and
because build tags are a poor way to represent an
OS target, this CL introduces an exception into
go/build: linux is treated as a synonym for android
when matching files.
http://golang.org/s/go14android
https://groups.google.com/forum/#!topic/golang-dev/P1ATVp1mun0
LGTM=rsc, minux
R=golang-codereviews, mikioh.mikioh, dave, aram, minux, gobot, rsc, aram.h, elias.naur, iant
CC=golang-codereviews, rsc
https://golang.org/cl/
105270043
"darwin",
"dragonfly",
"linux",
+ "android",
"solaris",
"freebsd",
"nacl",
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 = ',';
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));
"elf", Helf,
"freebsd", Hfreebsd,
"linux", Hlinux,
+ "android", Hlinux,
"nacl", Hnacl,
"netbsd", Hnetbsd,
"openbsd", Hopenbsd,
"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,
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 {
// 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]
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]] {
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)
// 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
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 "
--- /dev/null
+// TODO: Generate using cgo like defs_linux_{386,amd64}.h
+
+#include "defs_linux_arm.h"
--- /dev/null
+#include "os_linux.h"
--- /dev/null
+// 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)
--- /dev/null
+#include "signal_linux_386.h"
--- /dev/null
+#include "signal_linux_arm.h"
--- /dev/null
+#include "signals_linux.h"