Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
go: build/install godoc & vet
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
DomT4 authored and MikeMcQuaid committed Feb 26, 2015
1 parent a195e88 commit f86c52b
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions Library/Formula/go.rb
Expand Up @@ -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"
Expand Down Expand Up @@ -64,21 +71,35 @@ def install
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
Expand All @@ -99,5 +120,14 @@ def caveats; <<-EOS.undent
# 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

0 comments on commit f86c52b

Please sign in to comment.