Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
c562fbc4
Commit
c562fbc4
authored
Jun 17, 2011
by
Alex Brainman
Committed by
Andrew Gerrand
Jun 17, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgo: make file path work for windows
R=golang-dev, mattn.jp, adg CC=golang-dev
https://golang.org/cl/4634043
parent
380e5a37
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
10 deletions
+14
-10
src/cmd/cgo/gcc.go
src/cmd/cgo/gcc.go
+1
-1
src/cmd/cgo/main.go
src/cmd/cgo/main.go
+2
-1
src/cmd/cgo/out.go
src/cmd/cgo/out.go
+10
-7
src/cmd/cgo/util.go
src/cmd/cgo/util.go
+1
-1
No files found.
src/cmd/cgo/gcc.go
View file @
c562fbc4
...
...
@@ -697,7 +697,7 @@ func (p *Package) gccMachine() []string {
return
nil
}
const
gccTmp
=
"_obj/
_cgo_.o"
var
gccTmp
=
objDir
+
"
_cgo_.o"
// gccCmd returns the gcc command line to use for compiling
// the input.
...
...
src/cmd/cgo/main.go
View file @
c562fbc4
...
...
@@ -18,6 +18,7 @@ import (
"go/token"
"io"
"os"
"path/filepath"
"reflect"
"strings"
)
...
...
@@ -228,7 +229,7 @@ func main() {
}
pkg
:=
f
.
Package
if
dir
:=
os
.
Getenv
(
"CGOPKGPATH"
);
dir
!=
""
{
pkg
=
dir
+
"/"
+
pkg
pkg
=
filepath
.
Join
(
dir
,
pkg
)
}
p
.
PackagePath
=
pkg
p
.
writeOutput
(
f
,
input
)
...
...
src/cmd/cgo/out.go
View file @
c562fbc4
...
...
@@ -14,17 +14,20 @@ import (
"go/printer"
"go/token"
"os"
"path/filepath"
"strings"
)
var
objDir
=
"_obj"
+
string
(
filepath
.
Separator
)
// writeDefs creates output files to be compiled by 6g, 6c, and gcc.
// (The comments here say 6g and 6c but the code applies to the 8 and 5 tools too.)
func
(
p
*
Package
)
writeDefs
()
{
fgo2
:=
creat
(
"_obj/
_cgo_gotypes.go"
)
fc
:=
creat
(
"_obj/
_cgo_defun.c"
)
fm
:=
creat
(
"_obj/
_cgo_main.c"
)
fgo2
:=
creat
(
objDir
+
"
_cgo_gotypes.go"
)
fc
:=
creat
(
objDir
+
"
_cgo_defun.c"
)
fm
:=
creat
(
objDir
+
"
_cgo_main.c"
)
fflg
:=
creat
(
"_obj/
_cgo_flags"
)
fflg
:=
creat
(
objDir
+
"
_cgo_flags"
)
for
k
,
v
:=
range
p
.
CgoFlags
{
fmt
.
Fprintf
(
fflg
,
"_CGO_%s=%s
\n
"
,
k
,
v
)
}
...
...
@@ -285,8 +288,8 @@ func (p *Package) writeOutput(f *File, srcfile string) {
base
=
base
[
0
:
len
(
base
)
-
3
]
}
base
=
strings
.
Map
(
slashToUnderscore
,
base
)
fgo1
:=
creat
(
"_obj/"
+
base
+
".cgo1.go"
)
fgcc
:=
creat
(
"_obj/"
+
base
+
".cgo2.c"
)
fgo1
:=
creat
(
objDir
+
base
+
".cgo1.go"
)
fgcc
:=
creat
(
objDir
+
base
+
".cgo2.c"
)
p
.
GoFiles
=
append
(
p
.
GoFiles
,
base
+
".cgo1.go"
)
p
.
GccFiles
=
append
(
p
.
GccFiles
,
base
+
".cgo2.c"
)
...
...
@@ -361,7 +364,7 @@ func (p *Package) writeOutputFunc(fgcc *os.File, n *Name) {
// Write out the various stubs we need to support functions exported
// from Go so that they are callable from C.
func
(
p
*
Package
)
writeExports
(
fgo2
,
fc
,
fm
*
os
.
File
)
{
fgcc
:=
creat
(
"_obj/
_cgo_export.c"
)
fgcc
:=
creat
(
objDir
+
"
_cgo_export.c"
)
fgcch
:=
creat
(
"_cgo_export.h"
)
fmt
.
Fprintf
(
fgcch
,
"/* Created by cgo - DO NOT EDIT. */
\n
"
)
...
...
src/cmd/cgo/util.go
View file @
c562fbc4
...
...
@@ -103,7 +103,7 @@ func creat(name string) *os.File {
}
func
slashToUnderscore
(
c
int
)
int
{
if
c
==
'/'
{
if
c
==
'/'
||
c
==
'\\'
||
c
==
':'
{
c
=
'_'
}
return
c
...
...
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