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
0f8678a7
Commit
0f8678a7
authored
Jul 12, 2011
by
Alex Brainman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/build: include processing of .c files for cgo packages
R=golang-dev, adg CC=golang-dev
https://golang.org/cl/4696041
parent
851ded96
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
2 deletions
+31
-2
build.go
src/pkg/go/build/build.go
+10
-2
cgotest.c
src/pkg/go/build/cgotest/cgotest.c
+9
-0
cgotest.go
src/pkg/go/build/cgotest/cgotest.go
+7
-0
cgotest.h
src/pkg/go/build/cgotest/cgotest.h
+5
-0
No files found.
src/pkg/go/build/build.go
View file @
0f8678a7
...
...
@@ -61,7 +61,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
...
)
outGo
,
outObj
:=
b
.
cgo
(
cgoFiles
)
cgoCFiles
:=
b
.
abss
(
info
.
CFiles
...
)
s
.
addInput
(
cgoCFiles
...
)
outGo
,
outObj
:=
b
.
cgo
(
cgoFiles
,
cgoCFiles
)
gofiles
=
append
(
gofiles
,
outGo
...
)
ofiles
=
append
(
ofiles
,
outObj
...
)
s
.
addIntermediate
(
outGo
...
)
...
...
@@ -370,7 +372,7 @@ func (b *build) gccArgs(args ...string) []string {
var
cgoRe
=
regexp
.
MustCompile
(
`[/\\:]`
)
func
(
b
*
build
)
cgo
(
cgofiles
[]
string
)
(
outGo
,
outObj
[]
string
)
{
func
(
b
*
build
)
cgo
(
cgofiles
,
cgocfiles
[]
string
)
(
outGo
,
outObj
[]
string
)
{
// cgo
// TODO(adg): CGOPKGPATH
// TODO(adg): CGO_FLAGS
...
...
@@ -413,6 +415,12 @@ func (b *build) cgo(cgofiles []string) (outGo, outObj []string) {
b
.
script
.
addIntermediate
(
ofile
)
}
}
for
_
,
cfile
:=
range
cgocfiles
{
ofile
:=
b
.
obj
+
cgoRe
.
ReplaceAllString
(
cfile
[
:
len
(
cfile
)
-
1
],
"_"
)
+
"o"
b
.
gccCompile
(
ofile
,
cfile
)
linkobj
=
append
(
linkobj
,
ofile
)
outObj
=
append
(
outObj
,
ofile
)
}
dynObj
:=
b
.
obj
+
"_cgo_.o"
b
.
gccLink
(
dynObj
,
linkobj
...
)
b
.
script
.
addIntermediate
(
dynObj
)
...
...
src/pkg/go/build/cgotest/cgotest.c
0 → 100644
View file @
0f8678a7
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
int
Add
(
int
x
,
int
y
,
int
*
sum
)
{
sum
=
x
+
y
;
}
src/pkg/go/build/cgotest/cgotest.go
View file @
0f8678a7
...
...
@@ -7,6 +7,13 @@ package cgotest
/*
char* greeting = "hello, world";
*/
// #include "cgotest.h"
import
"C"
import
"unsafe"
var
Greeting
=
C
.
GoString
(
C
.
greeting
)
func
DoAdd
(
x
,
y
int
)
(
sum
int
)
{
C
.
Add
(
C
.
int
(
x
),
C
.
int
(
y
),
(
*
C
.
int
)(
unsafe
.
Pointer
(
&
sum
)))
return
}
src/pkg/go/build/cgotest/cgotest.h
0 → 100644
View file @
0f8678a7
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
extern
int
Add
(
int
,
int
,
int
*
);
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