Commit b0996334 authored by Russ Cox's avatar Russ Cox

go/build, cmd/go: add support for .syso files

.syso files are system objects copied directly
into the package archive.

Fixes #1552.

R=alex.brainman, iant, r, minux.ma, remyoudompheng
CC=golang-dev
https://golang.org/cl/5778043
parent cfe007e1
...@@ -727,6 +727,11 @@ func (b *builder) build(a *action) error { ...@@ -727,6 +727,11 @@ func (b *builder) build(a *action) error {
// http://golang.org/issue/2601 // http://golang.org/issue/2601
objects = append(objects, cgoObjects...) objects = append(objects, cgoObjects...)
// Add system object files.
for _, syso := range a.p.SysoFiles {
objects = append(objects, filepath.Join(a.p.Dir, syso))
}
// Pack into archive in obj directory // Pack into archive in obj directory
if err := buildToolchain.pack(b, a.p, obj, a.objpkg, objects); err != nil { if err := buildToolchain.pack(b, a.p, obj, a.objpkg, objects); err != nil {
return err return err
......
...@@ -41,11 +41,12 @@ being passed to the template is: ...@@ -41,11 +41,12 @@ being passed to the template is:
Root string // Go root or Go path dir containing this package Root string // Go root or Go path dir containing this package
// Source files // Source files
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles) GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
CgoFiles []string // .go sources files that import "C" CgoFiles []string // .go sources files that import "C"
CFiles []string // .c source files CFiles []string // .c source files
HFiles []string // .h source files HFiles []string // .h source files
SFiles []string // .s source files SFiles []string // .s source files
SysoFiles []string // .syso object files to add to archive
// Cgo directives // Cgo directives
CgoCFLAGS []string // cgo: flags for C compiler CgoCFLAGS []string // cgo: flags for C compiler
......
...@@ -35,11 +35,12 @@ type Package struct { ...@@ -35,11 +35,12 @@ type Package struct {
Root string `json:",omitempty"` // Go root or Go path dir containing this package Root string `json:",omitempty"` // Go root or Go path dir containing this package
// Source files // Source files
GoFiles []string `json:",omitempty"` // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles) GoFiles []string `json:",omitempty"` // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
CgoFiles []string `json:",omitempty"` // .go sources files that import "C" CgoFiles []string `json:",omitempty"` // .go sources files that import "C"
CFiles []string `json:",omitempty"` // .c source files CFiles []string `json:",omitempty"` // .c source files
HFiles []string `json:",omitempty"` // .h source files HFiles []string `json:",omitempty"` // .h source files
SFiles []string `json:",omitempty"` // .s source files SFiles []string `json:",omitempty"` // .s source files
SysoFiles []string `json:",omitempty"` // .syso system object files added to package
// Cgo directives // Cgo directives
CgoCFLAGS []string `json:",omitempty"` // cgo: flags for C compiler CgoCFLAGS []string `json:",omitempty"` // cgo: flags for C compiler
...@@ -90,6 +91,7 @@ func (p *Package) copyBuild(pp *build.Package) { ...@@ -90,6 +91,7 @@ func (p *Package) copyBuild(pp *build.Package) {
p.CFiles = pp.CFiles p.CFiles = pp.CFiles
p.HFiles = pp.HFiles p.HFiles = pp.HFiles
p.SFiles = pp.SFiles p.SFiles = pp.SFiles
p.SysoFiles = pp.SysoFiles
p.CgoCFLAGS = pp.CgoCFLAGS p.CgoCFLAGS = pp.CgoCFLAGS
p.CgoLDFLAGS = pp.CgoLDFLAGS p.CgoLDFLAGS = pp.CgoLDFLAGS
p.CgoPkgConfig = pp.CgoPkgConfig p.CgoPkgConfig = pp.CgoPkgConfig
...@@ -487,7 +489,7 @@ func isStale(p *Package, topRoot map[string]bool) bool { ...@@ -487,7 +489,7 @@ func isStale(p *Package, topRoot map[string]bool) bool {
return false return false
} }
srcs := stringList(p.GoFiles, p.CFiles, p.HFiles, p.SFiles, p.CgoFiles) srcs := stringList(p.GoFiles, p.CFiles, p.HFiles, p.SFiles, p.CgoFiles, p.SysoFiles)
for _, src := range srcs { for _, src := range srcs {
if olderThan(filepath.Join(p.Dir, src)) { if olderThan(filepath.Join(p.Dir, src)) {
return true return true
......
...@@ -279,11 +279,12 @@ type Package struct { ...@@ -279,11 +279,12 @@ type Package struct {
PkgObj string // installed .a file PkgObj string // installed .a file
// Source files // Source files
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles) GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
CgoFiles []string // .go source files that import "C" CgoFiles []string // .go source files that import "C"
CFiles []string // .c source files CFiles []string // .c source files
HFiles []string // .h source files HFiles []string // .h source files
SFiles []string // .s source files SFiles []string // .s source files
SysoFiles []string // .syso system object files to add to archive
// Cgo directives // Cgo directives
CgoPkgConfig []string // Cgo pkg-config directives CgoPkgConfig []string // Cgo pkg-config directives
...@@ -476,7 +477,12 @@ Found: ...@@ -476,7 +477,12 @@ Found:
ext := name[i:] ext := name[i:]
switch ext { switch ext {
case ".go", ".c", ".s", ".h", ".S": case ".go", ".c", ".s", ".h", ".S":
// tentatively okay // tentatively okay - read to make sure
case ".syso":
// binary objects to add to package archive
// Likely of the form foo_windows.syso, but
// the name was vetted above with goodOSArchFile.
p.SysoFiles = append(p.SysoFiles, name)
default: default:
// skip // skip
continue continue
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment