mirror of
https://github.com/golang/go
synced 2024-11-19 20:54:39 -07:00
goinstall: handle .c files with gc when cgo isn't used
As a data point, this enables goinstall to handle the standard syscall package almost unchanged (there's one file with the _bsd extension, and a .c file which isn't supposed to be compiled in). R=rsc CC=golang-dev https://golang.org/cl/4259057
This commit is contained in:
parent
02323c0e21
commit
e08f0c18c9
@ -52,12 +52,6 @@ func makeMakefile(dir, pkg string) ([]byte, os.Error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(dirInfo.cgoFiles) == 0 && len(dirInfo.cFiles) > 0 {
|
||||
// When using cgo, .c files are compiled with gcc. Without cgo,
|
||||
// they may be intended for 6c. Just error out for now.
|
||||
return nil, os.ErrorString("C files found in non-cgo package")
|
||||
}
|
||||
|
||||
cgoFiles := dirInfo.cgoFiles
|
||||
isCgo := make(map[string]bool, len(cgoFiles))
|
||||
for _, file := range cgoFiles {
|
||||
@ -67,14 +61,6 @@ func makeMakefile(dir, pkg string) ([]byte, os.Error) {
|
||||
isCgo[file] = true
|
||||
}
|
||||
|
||||
cgoOFiles := make([]string, 0, len(dirInfo.cFiles))
|
||||
for _, file := range dirInfo.cFiles {
|
||||
if !safeName(file) {
|
||||
return nil, os.ErrorString("unsafe name: " + file)
|
||||
}
|
||||
cgoOFiles = append(cgoOFiles, file[:len(file)-2]+".o")
|
||||
}
|
||||
|
||||
goFiles := make([]string, 0, len(dirInfo.goFiles))
|
||||
for _, file := range dirInfo.goFiles {
|
||||
if !safeName(file) {
|
||||
@ -85,7 +71,21 @@ func makeMakefile(dir, pkg string) ([]byte, os.Error) {
|
||||
}
|
||||
}
|
||||
|
||||
oFiles := make([]string, 0, len(dirInfo.sFiles))
|
||||
oFiles := make([]string, 0, len(dirInfo.cFiles)+len(dirInfo.sFiles))
|
||||
cgoOFiles := make([]string, 0, len(dirInfo.cFiles))
|
||||
for _, file := range dirInfo.cFiles {
|
||||
if !safeName(file) {
|
||||
return nil, os.ErrorString("unsafe name: " + file)
|
||||
}
|
||||
// When cgo is in use, C files are compiled with gcc,
|
||||
// otherwise they're compiled with gc.
|
||||
if len(cgoFiles) > 0 {
|
||||
cgoOFiles = append(cgoOFiles, file[:len(file)-2]+".o")
|
||||
} else {
|
||||
oFiles = append(oFiles, file[:len(file)-2]+".$O")
|
||||
}
|
||||
}
|
||||
|
||||
for _, file := range dirInfo.sFiles {
|
||||
if !safeName(file) {
|
||||
return nil, os.ErrorString("unsafe name: " + file)
|
||||
|
Loading…
Reference in New Issue
Block a user