]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go, go/build: add build.Package.PkgTargetRoot
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Tue, 14 Apr 2015 08:20:18 +0000 (10:20 +0200)
committerIan Lance Taylor <iant@golang.org>
Wed, 15 Apr 2015 22:45:43 +0000 (22:45 +0000)
This is $GOPATH/pkg/linux_amd64 or similar.  cmd/go already had a grotty calculation
of this and I need to add another one for -buildmode=shared.

Change-Id: Ied28c9b7cce671da8d45920e124a3e0c2501258a
Reviewed-on: https://go-review.googlesource.com/8930
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/build.go
src/go/build/build.go

index 3e40394e5acc47e21b1c6e83ebd8ecb5bda31929..cbdd9d22c9d6bb372832e9ad4c37a57c6ccebe16 100644 (file)
@@ -1249,15 +1249,7 @@ func (b *builder) includeArgs(flag string, all []*action) []string {
        for _, a1 := range all {
                if dir := a1.pkgdir; dir == a1.p.build.PkgRoot && !incMap[dir] {
                        incMap[dir] = true
-                       if _, ok := buildToolchain.(gccgoToolchain); ok {
-                               dir = filepath.Join(dir, "gccgo_"+goos+"_"+goarch)
-                       } else {
-                               dir = filepath.Join(dir, goos+"_"+goarch)
-                               if buildContext.InstallSuffix != "" {
-                                       dir += "_" + buildContext.InstallSuffix
-                               }
-                       }
-                       inc = append(inc, flag, dir)
+                       inc = append(inc, flag, a1.p.build.PkgTargetRoot)
                }
        }
 
index f0fe5ae85e32c446be0b13a5b73e4e1c154501c4..155156b9a567264a484ac81e8a6e16ef612331d4 100644 (file)
@@ -354,6 +354,7 @@ type Package struct {
        Root          string   // root of Go tree where this package lives
        SrcRoot       string   // package source root directory ("" if unknown)
        PkgRoot       string   // package install root directory ("" if unknown)
+       PkgTargetRoot string   // architecture dependent install root directory ("" if unknown)
        BinDir        string   // command install directory ("" if unknown)
        Goroot        bool     // package found in Go root
        PkgObj        string   // installed .a file
@@ -462,18 +463,21 @@ func (ctxt *Context) Import(path string, srcDir string, mode ImportMode) (*Packa
                return p, fmt.Errorf("import %q: invalid import path", path)
        }
 
+       var pkgtargetroot string
        var pkga string
        var pkgerr error
        switch ctxt.Compiler {
        case "gccgo":
+               pkgtargetroot = "pkg/gccgo_" + ctxt.GOOS + "_" + ctxt.GOARCH
                dir, elem := pathpkg.Split(p.ImportPath)
-               pkga = "pkg/gccgo_" + ctxt.GOOS + "_" + ctxt.GOARCH + "/" + dir + "lib" + elem + ".a"
+               pkga = pkgtargetroot + "/" + dir + "lib" + elem + ".a"
        case "gc":
                suffix := ""
                if ctxt.InstallSuffix != "" {
                        suffix = "_" + ctxt.InstallSuffix
                }
-               pkga = "pkg/" + ctxt.GOOS + "_" + ctxt.GOARCH + suffix + "/" + p.ImportPath + ".a"
+               pkgtargetroot = "pkg/" + ctxt.GOOS + "_" + ctxt.GOARCH + suffix
+               pkga = pkgtargetroot + "/" + p.ImportPath + ".a"
        default:
                // Save error for end of function.
                pkgerr = fmt.Errorf("import %q: unknown compiler %q", path, ctxt.Compiler)
@@ -590,6 +594,7 @@ Found:
                p.PkgRoot = ctxt.joinPath(p.Root, "pkg")
                p.BinDir = ctxt.joinPath(p.Root, "bin")
                if pkga != "" {
+                       p.PkgTargetRoot = ctxt.joinPath(p.Root, pkgtargetroot)
                        p.PkgObj = ctxt.joinPath(p.Root, pkga)
                }
        }