Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(736)

Delta Between Two Patch Sets: src/pkg/go/build/build.go

Issue 4636044: code review 4636044: goinstall, go/build: support building cgo packages (Closed)
Left Patch Set: diff -r 4795e1786223 https://go.googlecode.com/hg/ Created 12 years, 9 months ago
Right Patch Set: diff -r 12cc5b3cc379 https://go.googlecode.com/hg/ Created 12 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/goinstall/main.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package build provides tools for building Go packages. 5 // Package build provides tools for building Go packages.
6 package build 6 package build
7 7
8 import ( 8 import (
9 "bytes" 9 "bytes"
10 "exec" 10 "exec"
11 "fmt" 11 "fmt"
12 "os" 12 "os"
13 "path/filepath" 13 "path/filepath"
14 "regexp" 14 "regexp"
15 "runtime" 15 "runtime"
16 "strings" 16 "strings"
17 ) 17 )
18 18
19 // Build produces a build Script for the given package. 19 // Build produces a build Script for the given package.
20 func Build(tree *Tree, pkg string, info *DirInfo) (*Script, os.Error) { 20 func Build(tree *Tree, pkg string, info *DirInfo) (*Script, os.Error) {
21 s := &Script{} 21 s := &Script{}
22 b := &build{ 22 b := &build{
23 script: s, 23 script: s,
24 path: filepath.Join(tree.SrcDir(), pkg), 24 path: filepath.Join(tree.SrcDir(), pkg),
25 } 25 }
26 » b.obj = b.abs("_obj") + "/" 26 » b.obj = b.abs("_obj") + string(filepath.Separator)
27 27
28 b.goarch = runtime.GOARCH 28 b.goarch = runtime.GOARCH
29 if g := os.Getenv("GOARCH"); g != "" { 29 if g := os.Getenv("GOARCH"); g != "" {
30 b.goarch = g 30 b.goarch = g
31 } 31 }
32 var err os.Error 32 var err os.Error
33 b.arch, err = ArchChar(b.goarch) 33 b.arch, err = ArchChar(b.goarch)
34 if err != nil { 34 if err != nil {
35 return nil, err 35 return nil, err
36 } 36 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 if len(ofiles) == 0 { 77 if len(ofiles) == 0 {
78 return nil, os.NewError("make: no object files to build") 78 return nil, os.NewError("make: no object files to build")
79 } 79 }
80 80
81 // choose target file 81 // choose target file
82 var targ string 82 var targ string
83 if info.IsCommand() { 83 if info.IsCommand() {
84 // use the last part of the import path as binary name 84 // use the last part of the import path as binary name
85 _, bin := filepath.Split(pkg) 85 _, bin := filepath.Split(pkg)
86 if runtime.GOOS == "windows" {
87 bin += ".exe"
88 }
86 targ = filepath.Join(tree.BinDir(), bin) 89 targ = filepath.Join(tree.BinDir(), bin)
87 } else { 90 } else {
88 targ = filepath.Join(tree.PkgDir(), pkg+".a") 91 targ = filepath.Join(tree.PkgDir(), pkg+".a")
89 } 92 }
90 93
91 // make target directory 94 // make target directory
92 targDir, _ := filepath.Split(targ) 95 targDir, _ := filepath.Split(targ)
93 b.mkdir(targDir) 96 b.mkdir(targDir)
94 97
95 // link binary or pack object 98 // link binary or pack object
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 }) 407 })
405 b.script.addIntermediate(importC) 408 b.script.addIntermediate(importC)
406 409
407 // cc _cgo_import.ARCH 410 // cc _cgo_import.ARCH
408 importObj := b.obj + "_cgo_import." + b.arch 411 importObj := b.obj + "_cgo_import." + b.arch
409 b.cc(importObj, importC) 412 b.cc(importObj, importC)
410 outObj = append(outObj, importObj) 413 outObj = append(outObj, importObj)
411 414
412 return 415 return
413 } 416 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b