mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 16:03:23 +00:00
go1.4: Decouple tools
This commit is contained in:
parent
92398e92ff
commit
e7d4e7ebce
@ -1,26 +1,19 @@
|
||||
{ stdenv, lib, fetchurl, fetchgit, bison, glibc, bash, coreutils, makeWrapper, tzdata, iana_etc, perl, Security }:
|
||||
{ stdenv, lib, fetchurl, bison, glibc, bash, coreutils, makeWrapper, tzdata, iana_etc, perl, Security, goPackages }:
|
||||
|
||||
let
|
||||
loader386 = "${glibc}/lib/ld-linux.so.2";
|
||||
loaderAmd64 = "${glibc}/lib/ld-linux-x86-64.so.2";
|
||||
loaderArm = "${glibc}/lib/ld-linux.so.3";
|
||||
srcs = {
|
||||
golang = fetchurl {
|
||||
url = https://github.com/golang/go/archive/go1.4.2.tar.gz;
|
||||
sha256 = "3e5d07bc5214a1ffe187cf6406c5b5a80ee44f12f6bca97a5463db0afee2f6ac";
|
||||
};
|
||||
tools = fetchgit {
|
||||
url = https://github.com/golang/tools.git;
|
||||
rev = "c836fe615a448dbf9ff5448c1aa657479a0d0aeb";
|
||||
sha256 = "0q9jnhmgmm3xzjss7ndsi6nyykmmb1y984n98118c2sipi183xp5";
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "go-1.4.2";
|
||||
stdenv.mkDerivation rec {
|
||||
name = "go-${version}";
|
||||
version = "1.4.2";
|
||||
|
||||
src = srcs.golang;
|
||||
src = fetchurl {
|
||||
url = "https://github.com/golang/go/archive/go${version}.tar.gz";
|
||||
sha256 = "3e5d07bc5214a1ffe187cf6406c5b5a80ee44f12f6bca97a5463db0afee2f6ac";
|
||||
};
|
||||
|
||||
# perl is used for testing go vet
|
||||
buildInputs = [ bison bash makeWrapper perl ]
|
||||
@ -41,9 +34,6 @@ stdenv.mkDerivation {
|
||||
mv * go
|
||||
fi
|
||||
|
||||
mkdir -p $out/share/go/src/golang.org/x
|
||||
cp -r --no-preserve=mode,ownership ${srcs.tools} $out/share/go/src/golang.org/x/tools
|
||||
|
||||
cd go
|
||||
patchShebangs ./ # replace /bin/bash
|
||||
|
||||
@ -68,7 +58,10 @@ stdenv.mkDerivation {
|
||||
sed -i 's,/lib/ld-linux.so.2,${loader386},' src/cmd/8l/asm.c
|
||||
'';
|
||||
|
||||
patches = [ ./cacert-1.4.patch ];
|
||||
patches = [
|
||||
./cacert-1.4.patch
|
||||
./remove-tools.patch
|
||||
];
|
||||
|
||||
GOOS = if stdenv.isDarwin then "darwin" else "linux";
|
||||
GOARCH = if stdenv.isDarwin then "amd64"
|
||||
@ -91,13 +84,6 @@ stdenv.mkDerivation {
|
||||
export PATH="$GOBIN:$PATH"
|
||||
cd ./src
|
||||
./all.bash
|
||||
cd -
|
||||
|
||||
# Build extra tooling
|
||||
# TODO: Fix godoc tests
|
||||
TOOL_ROOT=golang.org/x/tools/cmd
|
||||
go install -v $TOOL_ROOT/cover $TOOL_ROOT/vet $TOOL_ROOT/godoc
|
||||
go test -v $TOOL_ROOT/cover $TOOL_ROOT/vet # $TOOL_ROOT/godoc
|
||||
'';
|
||||
|
||||
setupHook = ./setup-hook.sh;
|
||||
@ -107,7 +93,7 @@ stdenv.mkDerivation {
|
||||
homepage = http://golang.org/;
|
||||
description = "The Go Programming language";
|
||||
license = "BSD";
|
||||
maintainers = with stdenv.lib.maintainers; [ cstrahan ];
|
||||
maintainers = with stdenv.lib.maintainers; [ cstrahan wkennington ];
|
||||
platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
|
||||
};
|
||||
}
|
||||
|
81
pkgs/development/compilers/go/remove-tools.patch
Normal file
81
pkgs/development/compilers/go/remove-tools.patch
Normal file
@ -0,0 +1,81 @@
|
||||
diff --git a/misc/makerelease/makerelease.go b/misc/makerelease/makerelease.go
|
||||
index 3b511b1..a46ebd8 100644
|
||||
--- a/misc/makerelease/makerelease.go
|
||||
+++ b/misc/makerelease/makerelease.go
|
||||
@@ -65,9 +65,6 @@ const (
|
||||
// These must be the command that cmd/go knows to install to $GOROOT/bin
|
||||
// or $GOROOT/pkg/tool.
|
||||
var toolPaths = []string{
|
||||
- "golang.org/x/tools/cmd/cover",
|
||||
- "golang.org/x/tools/cmd/godoc",
|
||||
- "golang.org/x/tools/cmd/vet",
|
||||
}
|
||||
|
||||
var preBuildCleanFiles = []string{
|
||||
diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c
|
||||
index b6c61b4..2006bc2 100644
|
||||
--- a/src/cmd/dist/build.c
|
||||
+++ b/src/cmd/dist/build.c
|
||||
@@ -210,7 +210,9 @@ init(void)
|
||||
workdir = xworkdir();
|
||||
xatexit(rmworkdir);
|
||||
|
||||
- bpathf(&b, "%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch);
|
||||
+ xgetenv(&b, "GOTOOLDIR");
|
||||
+ if (b.len == 0)
|
||||
+ bpathf(&b, "%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch);
|
||||
tooldir = btake(&b);
|
||||
|
||||
bfree(&b);
|
||||
diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go
|
||||
index b71feb7..8468ea8 100644
|
||||
--- a/src/cmd/go/pkg.go
|
||||
+++ b/src/cmd/go/pkg.go
|
||||
@@ -401,9 +401,9 @@ var goTools = map[string]targetDir{
|
||||
"cmd/pack": toTool,
|
||||
"cmd/pprof": toTool,
|
||||
"cmd/yacc": toTool,
|
||||
- "golang.org/x/tools/cmd/cover": toTool,
|
||||
- "golang.org/x/tools/cmd/godoc": toBin,
|
||||
- "golang.org/x/tools/cmd/vet": toTool,
|
||||
+ "nixos.org/x/tools/cmd/cover": toTool,
|
||||
+ "nixos.org/x/tools/cmd/godoc": toBin,
|
||||
+ "nixos.org/x/tools/cmd/vet": toTool,
|
||||
"code.google.com/p/go.tools/cmd/cover": stalePath,
|
||||
"code.google.com/p/go.tools/cmd/godoc": stalePath,
|
||||
"code.google.com/p/go.tools/cmd/vet": stalePath,
|
||||
diff --git a/src/go/build/build.go b/src/go/build/build.go
|
||||
index 311ecb0..f151d8f 100644
|
||||
--- a/src/go/build/build.go
|
||||
+++ b/src/go/build/build.go
|
||||
@@ -1367,7 +1367,7 @@ func init() {
|
||||
}
|
||||
|
||||
// ToolDir is the directory containing build tools.
|
||||
-var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
|
||||
+var ToolDir = runtime.GOTOOLDIR()
|
||||
|
||||
// IsLocalImport reports whether the import path is
|
||||
// a local import path, like ".", "..", "./foo", or "../foo".
|
||||
diff --git a/src/runtime/extern.go b/src/runtime/extern.go
|
||||
index 6cc5df8..9a9a964 100644
|
||||
--- a/src/runtime/extern.go
|
||||
+++ b/src/runtime/extern.go
|
||||
@@ -152,6 +152,17 @@ func GOROOT() string {
|
||||
return defaultGoroot
|
||||
}
|
||||
|
||||
+// GOTOOLDIR returns the root of the Go tree.
|
||||
+// It uses the GOTOOLDIR environment variable, if set,
|
||||
+// or else the root used during the Go build.
|
||||
+func GOTOOLDIR() string {
|
||||
+ s := gogetenv("GOTOOLDIR")
|
||||
+ if s != "" {
|
||||
+ return s
|
||||
+ }
|
||||
+ return GOROOT() + "/pkg/tool/" + GOOS + "_" + GOARCH
|
||||
+}
|
||||
+
|
||||
// Version returns the Go tree's version string.
|
||||
// It is either the commit hash and date at the time of the build or,
|
||||
// when possible, a release tag like "go1.3".
|
Loading…
Reference in New Issue
Block a user