Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
7c248ae0
Commit
7c248ae0
authored
Jun 15, 2011
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/build: fix build and clean ups
R=rsc CC=golang-dev
https://golang.org/cl/4620045
parent
4a8de670
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
build.go
src/pkg/go/build/build.go
+10
-9
No files found.
src/pkg/go/build/build.go
View file @
7c248ae0
...
...
@@ -48,10 +48,9 @@ func Build(tree *Tree, pkg string, info *DirInfo) (*Script, os.Error) {
if
len
(
info
.
CgoFiles
)
>
0
{
cgoFiles
:=
b
.
abss
(
info
.
CgoFiles
...
)
s
.
addInput
(
cgoFiles
...
)
out
Inter
,
out
Go
,
outObj
:=
b
.
cgo
(
cgoFiles
)
outGo
,
outObj
:=
b
.
cgo
(
cgoFiles
)
gofiles
=
append
(
gofiles
,
outGo
...
)
ofiles
=
append
(
ofiles
,
outObj
...
)
s
.
addIntermediate
(
outInter
...
)
s
.
addIntermediate
(
outGo
...
)
s
.
addIntermediate
(
outObj
...
)
}
...
...
@@ -71,7 +70,7 @@ func Build(tree *Tree, pkg string, info *DirInfo) (*Script, os.Error) {
s
.
addInput
(
sfile
)
b
.
asm
(
ofile
,
sfile
)
ofiles
=
append
(
ofiles
,
ofile
)
s
.
addIntermediate
(
sfile
,
ofile
)
s
.
addIntermediate
(
ofile
)
}
if
len
(
ofiles
)
==
0
{
...
...
@@ -158,6 +157,7 @@ func (s *Script) Stale() bool {
// Clean removes the Script's Intermediate files.
// It tries to remove every file and returns the first error it encounters.
func
(
s
*
Script
)
Clean
()
(
err
os
.
Error
)
{
// Reverse order so that directories get removed after the files they contain.
for
i
:=
len
(
s
.
Intermediate
)
-
1
;
i
>=
0
;
i
--
{
if
e
:=
os
.
Remove
(
s
.
Intermediate
[
i
]);
err
==
nil
{
err
=
e
...
...
@@ -169,6 +169,7 @@ func (s *Script) Clean() (err os.Error) {
// Clean removes the Script's Intermediate and Output files.
// It tries to remove every file and returns the first error it encounters.
func
(
s
*
Script
)
Nuke
()
(
err
os
.
Error
)
{
// Reverse order so that directories get removed after the files they contain.
for
i
:=
len
(
s
.
Output
)
-
1
;
i
>=
0
;
i
--
{
if
e
:=
os
.
Remove
(
s
.
Output
[
i
]);
err
==
nil
{
err
=
e
...
...
@@ -337,7 +338,7 @@ func (b *build) gccArgs(args ...string) []string {
return
append
([]
string
{
"gcc"
,
m
,
"-I"
,
b
.
path
,
"-g"
,
"-fPIC"
,
"-O2"
},
args
...
)
}
func
(
b
*
build
)
cgo
(
cgofiles
[]
string
)
(
out
Inter
,
out
Go
,
outObj
[]
string
)
{
func
(
b
*
build
)
cgo
(
cgofiles
[]
string
)
(
outGo
,
outObj
[]
string
)
{
// cgo
// TODO(adg): CGOPKGPATH
// TODO(adg): CGO_FLAGS
...
...
@@ -359,8 +360,8 @@ func (b *build) cgo(cgofiles []string) (outInter, outGo, outObj []string) {
})
outGo
=
append
(
outGo
,
gofiles
...
)
exportH
:=
filepath
.
Join
(
b
.
path
,
"_cgo_export.h"
)
outInter
=
append
(
outInter
,
exportH
,
defunC
,
b
.
obj
+
"_cgo_flags"
)
outInter
=
append
(
outInter
,
cfiles
...
)
b
.
script
.
addIntermediate
(
defunC
,
exportH
,
b
.
obj
+
"_cgo_flags"
)
b
.
script
.
addIntermediate
(
cfiles
...
)
// cc _cgo_defun.c
defunObj
:=
b
.
obj
+
"_cgo_defun."
+
b
.
arch
...
...
@@ -376,12 +377,12 @@ func (b *build) cgo(cgofiles []string) (outInter, outGo, outObj []string) {
if
!
strings
.
HasSuffix
(
ofile
,
"_cgo_main.o"
)
{
outObj
=
append
(
outObj
,
ofile
)
}
else
{
outInter
=
append
(
outInter
,
ofile
)
b
.
script
.
addIntermediate
(
ofile
)
}
}
dynObj
:=
b
.
obj
+
"_cgo_.o"
b
.
gccLink
(
dynObj
,
linkobj
...
)
outInter
=
append
(
outInter
,
dynObj
)
b
.
script
.
addIntermediate
(
dynObj
)
// cgo -dynimport
importC
:=
b
.
obj
+
"_cgo_import.c"
...
...
@@ -391,7 +392,7 @@ func (b *build) cgo(cgofiles []string) (outInter, outGo, outObj []string) {
Input
:
[]
string
{
dynObj
},
Output
:
[]
string
{
importC
},
})
outInter
=
append
(
outInter
,
importC
)
b
.
script
.
addIntermediate
(
importC
)
// cc _cgo_import.ARCH
importObj
:=
b
.
obj
+
"_cgo_import."
+
b
.
arch
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment