aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula
diff options
context:
space:
mode:
authorDominyk Tiller2015-02-24 20:25:31 +0000
committerMike McQuaid2015-02-26 11:23:52 +0000
commitf86c52bee40d4a97d9c211d1b69d3c24a0a197d3 (patch)
treefd5ace5cbe253640cfc31a374cc811f9e1723ae5 /Library/Formula
parenta195e8853dbf01c75ac5c0cff2b0ed5d768d4b18 (diff)
downloadhomebrew-f86c52bee40d4a97d9c211d1b69d3c24a0a197d3.tar.bz2
go: build/install godoc & vet
Bottles and installs `godoc` and `go vet` unless requested otherwise. Closes #37133 Past references: 1) #23281 2) #25210 Closes #37159. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Formula')
-rw-r--r--Library/Formula/go.rb48
1 files changed, 39 insertions, 9 deletions
diff --git a/Library/Formula/go.rb b/Library/Formula/go.rb
index 1d76a29ce..664ad10ef 100644
--- a/Library/Formula/go.rb
+++ b/Library/Formula/go.rb
@@ -18,10 +18,17 @@ class Go < Formula
option "with-cc-all", "Build with cross-compilers and runtime support for all supported platforms"
option "with-cc-common", "Build with cross-compilers and runtime support for darwin, linux and windows"
option "without-cgo", "Build without cgo"
+ option "without-godoc", "godoc will not be installed for you"
+ option "without-vet", "vet will not be installed for you"
deprecated_option "cross-compile-all" => "with-cc-all"
deprecated_option "cross-compile-common" => "with-cc-common"
+ resource "gotools" do
+ url "https://go.googlesource.com/tools.git",
+ :revision => "69db398fe0e69396984e3967724820c1f631e971"
+ end
+
def install
# host platform (darwin) must come last in the targets list
if build.with? "cc-all"
@@ -64,21 +71,35 @@ class Go < Formula
end
(buildpath/"pkg/obj").rmtree
-
libexec.install Dir["*"]
bin.install_symlink Dir["#{libexec}/bin/go*"]
+
+ if build.with?("godoc") || build.with?("vet")
+ ENV.prepend_path "PATH", bin
+ ENV["GOPATH"] = buildpath
+ (buildpath/"src/golang.org/x/tools").install resource("gotools")
+
+ if build.with? "godoc"
+ cd "src/golang.org/x/tools/cmd/godoc/" do
+ system "go", "build"
+ (libexec/"bin").install "godoc"
+ end
+ bin.install_symlink libexec/"bin/godoc"
+ end
+
+ if build.with? "vet"
+ cd "src/golang.org/x/tools/cmd/vet/" do
+ system "go", "build"
+ # This is where Go puts vet natively; not in the bin.
+ (libexec/"pkg/tool/darwin_amd64/").install "vet"
+ end
+ end
+ end
end
def caveats; <<-EOS.undent
As of go 1.2, a valid GOPATH is required to use the `go get` command:
- http://golang.org/doc/code.html#GOPATH
-
- `go vet` and `go doc` are now part of the go.tools sub repo:
- http://golang.org/doc/go1.2#go_tools_godoc
-
- To get `go vet` and `go doc` run:
- go get golang.org/x/tools/cmd/vet
- go get golang.org/x/tools/cmd/godoc
+ https://golang.org/doc/code.html#GOPATH
You may wish to add the GOROOT-based install location to your PATH:
export PATH=$PATH:#{opt_libexec}/bin
@@ -99,5 +120,14 @@ class Go < Formula
# This is a a bare minimum of go working as it uses fmt, build, and run.
system "#{bin}/go", "fmt", "hello.go"
assert_equal "Hello World\n", `#{bin}/go run hello.go`
+
+ if build.with? "godoc"
+ assert File.exist?(libexec/"bin/godoc")
+ assert File.executable?(libexec/"bin/godoc")
+ end
+ if build.with? "vet"
+ assert File.exist?(libexec/"pkg/tool/darwin_amd64/vet")
+ assert File.executable?(libexec/"pkg/tool/darwin_amd64/vet")
+ end
end
end