mirror of
https://github.com/golang/go
synced 2024-11-17 20:54:48 -07:00
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
This commit is contained in:
parent
cfe007e1b6
commit
b0996334c1
@ -727,6 +727,11 @@ func (b *builder) build(a *action) error {
|
||||
// http://golang.org/issue/2601
|
||||
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
|
||||
if err := buildToolchain.pack(b, a.p, obj, a.objpkg, objects); err != nil {
|
||||
return err
|
||||
|
@ -41,11 +41,12 @@ being passed to the template is:
|
||||
Root string // Go root or Go path dir containing this package
|
||||
|
||||
// Source files
|
||||
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
|
||||
CgoFiles []string // .go sources files that import "C"
|
||||
CFiles []string // .c source files
|
||||
HFiles []string // .h source files
|
||||
SFiles []string // .s source files
|
||||
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
|
||||
CgoFiles []string // .go sources files that import "C"
|
||||
CFiles []string // .c source files
|
||||
HFiles []string // .h source files
|
||||
SFiles []string // .s source files
|
||||
SysoFiles []string // .syso object files to add to archive
|
||||
|
||||
// Cgo directives
|
||||
CgoCFLAGS []string // cgo: flags for C compiler
|
||||
|
@ -35,11 +35,12 @@ type Package struct {
|
||||
Root string `json:",omitempty"` // Go root or Go path dir containing this package
|
||||
|
||||
// Source files
|
||||
GoFiles []string `json:",omitempty"` // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
|
||||
CgoFiles []string `json:",omitempty"` // .go sources files that import "C"
|
||||
CFiles []string `json:",omitempty"` // .c source files
|
||||
HFiles []string `json:",omitempty"` // .h source files
|
||||
SFiles []string `json:",omitempty"` // .s source files
|
||||
GoFiles []string `json:",omitempty"` // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
|
||||
CgoFiles []string `json:",omitempty"` // .go sources files that import "C"
|
||||
CFiles []string `json:",omitempty"` // .c source files
|
||||
HFiles []string `json:",omitempty"` // .h source files
|
||||
SFiles []string `json:",omitempty"` // .s source files
|
||||
SysoFiles []string `json:",omitempty"` // .syso system object files added to package
|
||||
|
||||
// Cgo directives
|
||||
CgoCFLAGS []string `json:",omitempty"` // cgo: flags for C compiler
|
||||
@ -90,6 +91,7 @@ func (p *Package) copyBuild(pp *build.Package) {
|
||||
p.CFiles = pp.CFiles
|
||||
p.HFiles = pp.HFiles
|
||||
p.SFiles = pp.SFiles
|
||||
p.SysoFiles = pp.SysoFiles
|
||||
p.CgoCFLAGS = pp.CgoCFLAGS
|
||||
p.CgoLDFLAGS = pp.CgoLDFLAGS
|
||||
p.CgoPkgConfig = pp.CgoPkgConfig
|
||||
@ -487,7 +489,7 @@ func isStale(p *Package, topRoot map[string]bool) bool {
|
||||
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 {
|
||||
if olderThan(filepath.Join(p.Dir, src)) {
|
||||
return true
|
||||
|
@ -279,11 +279,12 @@ type Package struct {
|
||||
PkgObj string // installed .a file
|
||||
|
||||
// Source files
|
||||
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
|
||||
CgoFiles []string // .go source files that import "C"
|
||||
CFiles []string // .c source files
|
||||
HFiles []string // .h source files
|
||||
SFiles []string // .s source files
|
||||
GoFiles []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
|
||||
CgoFiles []string // .go source files that import "C"
|
||||
CFiles []string // .c source files
|
||||
HFiles []string // .h source files
|
||||
SFiles []string // .s source files
|
||||
SysoFiles []string // .syso system object files to add to archive
|
||||
|
||||
// Cgo directives
|
||||
CgoPkgConfig []string // Cgo pkg-config directives
|
||||
@ -476,7 +477,12 @@ Found:
|
||||
ext := name[i:]
|
||||
switch ext {
|
||||
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:
|
||||
// skip
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user