cb8a5f141d
Fixes Homebrew/homebrew#48980. Closes Homebrew/homebrew#49370. Signed-off-by: Alex Dunn <dunn.alex@gmail.com>
104 lines
3.4 KiB
Ruby
104 lines
3.4 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.6.0-src.tar.gz"
|
|
sha256 "3002a4a00004b0727709abeefe1ab1b2731845e4dab74566f363861801bb3326"
|
|
|
|
resource "cargo" do
|
|
# git required because of submodules
|
|
url "https://github.com/rust-lang/cargo.git", :tag => "0.8.0", :revision => "28a0cbb2212c295264a7a3031a4be0113a17aa91"
|
|
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
|
|
|
|
head do
|
|
url "https://github.com/rust-lang/rust.git"
|
|
resource "cargo" do
|
|
url "https://github.com/rust-lang/cargo.git"
|
|
end
|
|
end
|
|
|
|
bottle do
|
|
sha256 "8106b9f787d3f5079de03b6cae43cc5cf03ef3bf9e4782fbb117d4a1ad489075" => :el_capitan
|
|
sha256 "21355f678c6c265630f8028495efe3d248429f0b038c18e5ba2cd24bd5bf17de" => :yosemite
|
|
sha256 "0f238aa5d836cdba1846e50696f3fb1c5d1a6a3d1b107a39489226014d86ee93" => :mavericks
|
|
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
|
|
# Because we copy the source tree to a temporary build directory,
|
|
# the absolute paths written to the `gitdir` files of the
|
|
# submodules are no longer accurate, and running `git submodule
|
|
# update` during the configure step fails.
|
|
ENV["CFG_DISABLE_MANAGE_SUBMODULES"] = "1" if build.head?
|
|
|
|
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
|