Skip to content

Commit

Permalink
math can build, try to cgo-build goroot pkgs, added some more exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
skelterjohn committed Dec 16, 2011
1 parent 8b930a4 commit a1eedb5
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 15 deletions.
27 changes: 17 additions & 10 deletions gb/cgo.go
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion gb/files.go
Expand Up @@ -30,6 +30,7 @@ var (
"windows": true,
"darwin": true,
"freebsd": true,
"openbsd": true,
"linux": true,
"plan9": true,
}
Expand All @@ -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
Expand Down
28 changes: 24 additions & 4 deletions gb/gb.go
Expand Up @@ -80,28 +80,48 @@ 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
*/
var ForceMakePkgs = map[string]bool{
//"math": true,
"go/build": true,
"os": true,
"os/user": true,
"net": true,
"hash/crc32": true,
"syscall": true,
"runtime": true,
"crypto/tls": true,
"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"
Expand Down
5 changes: 5 additions & 0 deletions gb/pkg.go
Expand Up @@ -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
Expand Down

0 comments on commit a1eedb5

Please sign in to comment.