Created
June 30, 2015 06:34
-
-
Save JaciBrunning/084a340d40b9435ba3c6 to your computer and use it in GitHub Desktop.
Go Cross Compilation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ROOT_PKG = "jaci/openrio/butterknife" | |
ARCH_ALL = [ | |
"darwin_386", "darwin_amd64", | |
"freebsd_386", "freebsd_amd64", | |
"linux_386", "linux_amd64", "linux_arm", | |
"windows_386", "windows_amd64" | |
] | |
ARCH = ARCH_ALL.select {|arch| arch[/(windows|linux|darwin).*/] } # Only build what we need | |
puts "OS Build List: #{ARCH}" | |
MAKE_FILE = (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil ? "make.bat" : "make.bash" | |
ARCH.each do |arch| | |
archs = arch.split /_/ | |
puts "Build for OS: #{archs[0]} #{archs[1]}" | |
ENV["GOOS"] = archs[0] | |
ENV["GOARCH"] = archs[1] | |
ENV["GOPATH"] = File.absolute_path(".") | |
exit_code = system "go install #{ROOT_PKG}" | |
unless exit_code | |
puts "Configuring Runtime..." | |
Dir.chdir("#{ENV["GOROOT"]}/src") do | |
` #{MAKE_FILE} ` | |
end | |
system "go install #{ROOT_PKG}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment