From a1eedb529376dcc64cac380e407291102420d848 Mon Sep 17 00:00:00 2001 From: John Asmuth Date: Fri, 16 Dec 2011 12:35:55 -0500 Subject: [PATCH] math can build, try to cgo-build goroot pkgs, added some more exceptions --- gb/cgo.go | 27 +++++++++++++++++---------- gb/files.go | 3 ++- gb/gb.go | 28 ++++++++++++++++++++++++---- gb/pkg.go | 5 +++++ 4 files changed, 48 insertions(+), 15 deletions(-) diff --git a/gb/cgo.go b/gb/cgo.go index 3444cf9..c4cbcb8 100644 --- a/gb/cgo.go +++ b/gb/cgo.go @@ -50,9 +50,11 @@ var TestCGO = true func BuildCgoPackage(pkg *Package) (err error) { //defer fmt.Println(err) - if pkg.IsInGOROOT { - return MakeBuild(pkg) - } + /* + if pkg.IsInGOROOT { + return MakeBuild(pkg) + } + */ if !TestCGO { return MakeBuild(pkg) @@ -109,15 +111,20 @@ func BuildCgoPackage(pkg *Package) (err error) { err = Copy(pkg.Dir, cgosrc, cgd) cgo_argv = append(cgo_argv, cgb) } - if Verbose { - fmt.Printf("%s:", cgodir) - } - err = RunExternal(CGoCMD, cgodir, cgo_argv) - if err != nil { - return + if len(pkg.CGoSources) != 0 { + if Verbose { + fmt.Printf("%s:", cgodir) + } + err = RunExternal(CGoCMD, cgodir, cgo_argv) + if err != nil { + return + } } - var allsrc = []string{filepath.Join("_cgo", "_obj", "_cgo_gotypes.go")} + var allsrc []string + if len(pkg.CGoSources) != 0 { + allsrc = append(allsrc, filepath.Join("_cgo", "_obj", "_cgo_gotypes.go")) + } for _, src := range cgobases { gs := src[:len(src)-3] + ".cgo1.go" allsrc = append(allsrc, filepath.Join("_cgo", "_obj", gs)) diff --git a/gb/files.go b/gb/files.go index 53fa2a6..05b83b1 100644 --- a/gb/files.go +++ b/gb/files.go @@ -30,6 +30,7 @@ var ( "windows": true, "darwin": true, "freebsd": true, + "openbsd": true, "linux": true, "plan9": true, } @@ -53,7 +54,7 @@ func CheckCGOFlag(flag string) bool { return true } if flag == "bsd" && - (GOOS == "darwin" || GOOS == "freebsd" || GOOS == "bsd") { + (GOOS == "darwin" || GOOS == "freebsd" || GOOS == "bsd" || GOOS == "openbsd") { return true } return false diff --git a/gb/gb.go b/gb/gb.go index ea7605a..6d49b2e 100644 --- a/gb/gb.go +++ b/gb/gb.go @@ -80,14 +80,11 @@ var WarnLog = log.New(os.Stderr, "gb warning: ", 0) /* gb doesn't know how to build these packages - math has both pure go and asm versions of many functions, and which is used depends - on the architexture - go/build has a source-generation step that uses make variables os has source generation - syscall has crazy pure go/asm versions and unused source files + syscall has files type_$(GOOS).go that aren't build, but can't reasonably be filtered crypto/tls has a file root_stub.go which is excluded */ @@ -95,6 +92,8 @@ var ForceMakePkgs = map[string]bool{ //"math": true, "go/build": true, "os": true, + "os/user": true, + "net": true, "hash/crc32": true, "syscall": true, "runtime": true, @@ -102,6 +101,27 @@ var ForceMakePkgs = map[string]bool{ "godoc": true, } +var DoNotBuildGOROOT = map[string]bool{ + "src/cmd/5a": true, + "src/cmd/5c": true, + "src/cmd/5g": true, + "src/cmd/5l": true, + "src/cmd/6a": true, + "src/cmd/6c": true, + "src/cmd/6g": true, + "src/cmd/6l": true, + "src/cmd/8a": true, + "src/cmd/8c": true, + "src/cmd/8g": true, + "src/cmd/8l": true, + "src/cmd/cc": true, + "src/cmd/gc": true, + "src/cmd/cov": true, + "src/cmd/gopack": true, + "src/cmd/nm": true, + "src/cmd/prof": true, +} + const ( ObjDir = "_obj" TestDir = "_test" diff --git a/gb/pkg.go b/gb/pkg.go index 8b75f2d..98cae70 100644 --- a/gb/pkg.go +++ b/gb/pkg.go @@ -163,6 +163,11 @@ func NewPackage(base, dir string, inTestData string, cfg Config) (this *Package, return } + if this.IsInGOROOT && DoNotBuildGOROOT[GetRelative(GOROOT, this.Dir, CWD)] { + err = errors.New("can't build GOROOT core tools") + return + } + if len(this.Sources) == 0 { err = errors.New("no source") return