homebrew-core/Formula/go.rb

62 lines
1.6 KiB
Ruby
Raw Normal View History

2009-11-11 05:39:01 +00:00
require 'formula'
2010-05-21 03:06:46 +00:00
require 'hardware'
2009-11-11 05:39:01 +00:00
class Go <Formula
if ARGV.include? "--use-git-head"
head 'https://github.com/tav/go.git', :tag => 'release'
else
head 'http://go.googlecode.com/hg/', :revision => 'release'
end
2009-11-11 05:39:01 +00:00
homepage 'http://golang.org'
def options
2010-10-24 20:21:57 +00:00
[["--use-git-head", "Use git mirror instead of official hg repository"]]
end
2009-11-11 05:39:01 +00:00
skip_clean 'bin'
2010-05-21 03:06:46 +00:00
def which_arch
Hardware.is_64_bit? ? 'amd64' : '386'
end
2009-11-11 05:39:01 +00:00
def install
ENV.j1 # https://github.com/mxcl/homebrew/issues/#issue/237
prefix.install %w[src include test doc misc lib favicon.ico]
2009-11-11 05:39:01 +00:00
Dir.chdir prefix
mkdir %w[pkg bin]
2009-11-11 05:39:01 +00:00
ENV['GOROOT'] = Dir.getwd
2010-05-21 03:06:46 +00:00
ENV['GOBIN'] = bin
ENV['GOARCH'] = which_arch
2009-11-11 05:39:01 +00:00
ENV['GOOS'] = 'darwin'
ENV.prepend 'PATH', ENV['GOBIN'], ':'
Dir.chdir 'src' do
system "./all.bash"
# Keep the makefiles - https://github.com/mxcl/homebrew/issues/issue/1404
2009-11-11 05:39:01 +00:00
end
Dir['src/*'].each{|f| rm_rf f unless f.match(/^src\/(pkg|Make)/) }
rm_rf %w[include test]
2009-11-11 05:39:01 +00:00
end
2010-05-21 03:06:46 +00:00
def caveats
<<-EOS.undent
2010-10-24 20:21:57 +00:00
The official Go code repository uses mercurial, but a reasonably
up-to-date git mirror is available at https://github.com/tav/go.git.
To use the git mirror for Go builds, use the --use-git-head option.
2010-05-21 03:06:46 +00:00
In order to use Go, set the following in your ~/.profile:
2009-11-11 05:39:01 +00:00
2010-11-21 23:59:54 +00:00
export GOROOT=`brew --prefix go`
2010-05-21 03:06:46 +00:00
export GOBIN=#{HOMEBREW_PREFIX}/bin
export GOARCH=#{which_arch}
export GOOS=darwin
2009-11-11 05:39:01 +00:00
2010-05-21 03:06:46 +00:00
Presumably at some point the Go developers won't require us to
mutilate our shell environments in order to compile Go code...
2009-11-11 05:39:01 +00:00
EOS
end
end