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 {
// 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
......
......@@ -46,6 +46,7 @@ being passed to the template is:
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
......
......@@ -40,6 +40,7 @@ type Package struct {
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
......
......@@ -284,6 +284,7 @@ type Package struct {
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
......
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