homebrew-core/Formula/rust.rb
Martin Afanasjew fde97aa152 Revert "rust: don't rerun git submodule for HEAD builds" (#1639)
This reverts commit cb8a5f141d.

The workaround introduced in Homebrew/legacy-homebrew#49370 and
motivated by the failure in Homebrew/legacy-homebrew#48980 is no longer
necessary and/or has been fixed by Homebrew/brew#303.
2016-06-02 01:15:25 +02:00

98 lines
3.1 KiB
Ruby

class Rust < Formula
desc "Safe, concurrent, practical language"
homepage "https://www.rust-lang.org/"
stable do
url "https://static.rust-lang.org/dist/rustc-1.9.0-src.tar.gz"
sha256 "b19b21193d7d36039debeaaa1f61cbf98787e0ce94bd85c5cbe2a59462d7cfcd"
resource "cargo" do
# git required because of submodules
url "https://github.com/rust-lang/cargo.git", :tag => "0.10.0", :revision => "10ddd7d5b3080fb0fa6c720cedca64407d4ca2f9"
end
# name includes date to satisfy cache
resource "cargo-nightly-2015-09-17" do
url "https://static-rust-lang-org.s3.amazonaws.com/cargo-dist/2015-09-17/cargo-nightly-x86_64-apple-darwin.tar.gz"
sha256 "02ba744f8d29bad84c5e698c0f316f9e428962b974877f7f582cd198fdd807a8"
end
end
bottle do
sha256 "b056dfa306e29933415f9d50c6b5a1d76fe84d346f1337754c44c1a961f18409" => :el_capitan
sha256 "47bf11c39eee712e1f8276e1a77ebf70d1d87a125ea34e4a7cf00431d9deea45" => :yosemite
sha256 "d813ee35ceca6c9e125a5f950d1f7dd60ad79682064b07fa2f48cf2aa16a8dbf" => :mavericks
end
head do
url "https://github.com/rust-lang/rust.git"
resource "cargo" do
url "https://github.com/rust-lang/cargo.git"
end
end
option "with-llvm", "Build with brewed LLVM. By default, Rust's LLVM will be used."
depends_on "cmake" => :build
depends_on "pkg-config" => :run
depends_on "llvm" => :optional
depends_on "openssl"
depends_on "libssh2"
conflicts_with "multirust", :because => "both install rustc, rustdoc, cargo, rust-lldb, rust-gdb"
# According to the official readme, GCC 4.7+ is required
fails_with :gcc_4_0
fails_with :gcc
("4.3".."4.6").each do |n|
fails_with :gcc => n
end
def install
args = ["--prefix=#{prefix}"]
args << "--disable-rpath" if build.head?
args << "--enable-clang" if ENV.compiler == :clang
args << "--llvm-root=#{Formula["llvm"].opt_prefix}" if build.with? "llvm"
if build.head?
args << "--release-channel=nightly"
else
args << "--release-channel=stable"
end
system "./configure", *args
system "make"
system "make", "install"
resource("cargo").stage do
cargo_stage_path = pwd
if build.stable?
resource("cargo-nightly-2015-09-17").stage do
system "./install.sh", "--prefix=#{cargo_stage_path}/target/snapshot/cargo"
# satisfy make target to skip download
touch "#{cargo_stage_path}/target/snapshot/cargo/bin/cargo"
end
end
system "./configure", "--prefix=#{prefix}", "--local-rust-root=#{prefix}", "--enable-optimize"
system "make"
system "make", "install"
end
rm_rf prefix/"lib/rustlib/uninstall.sh"
rm_rf prefix/"lib/rustlib/install.log"
end
test do
system "#{bin}/rustdoc", "-h"
(testpath/"hello.rs").write <<-EOS.undent
fn main() {
println!("Hello World!");
}
EOS
system "#{bin}/rustc", "hello.rs"
assert_equal "Hello World!\n", `./hello`
system "#{bin}/cargo", "new", "hello_world", "--bin"
assert_equal "Hello, world!",
(testpath/"hello_world").cd { `#{bin}/cargo run`.split("\n").last }
end
end