class Ldc < Formula desc "Portable D programming language compiler" homepage "https://wiki.dlang.org/LDC" stable do url "https://github.com/ldc-developers/ldc/releases/download/v1.1.1/ldc-1.1.1-src.tar.gz" sha256 "3d35253a76288a78939fea467409462f0b87461ffb89550eb0d9958e59eb7e97" resource "ldc-lts" do url "https://github.com/ldc-developers/ldc/releases/download/v0.17.3/ldc-0.17.3-src.tar.gz" sha256 "325bd540f7eb71c309fa0ee9ef6d196a75ee2c3ccf323076053e6b7b295c2dad" end end bottle do sha256 "786db8b395c0fdac2ca5a870b452501fb79b3882489463fe29f0a6c2503ed234" => :sierra sha256 "deb0762cd588a6847c288f356dcc872d2509fed19645c3f79dd76512ba1cf133" => :el_capitan sha256 "215d80adf9ef45ffc425d6aa0b4834e56b20eeeb197e6a662e25ceb1a0291471" => :yosemite end head do url "https://github.com/ldc-developers/ldc.git", :shallow => false resource "ldc-lts" do url "https://github.com/ldc-developers/ldc.git", :shallow => false, :branch => "ltsmaster" end end needs :cxx11 depends_on "cmake" => :build depends_on "llvm" depends_on "libconfig" def install ENV.cxx11 (buildpath/"ldc-lts").install resource("ldc-lts") cd "ldc-lts" do mkdir "build" do args = std_cmake_args + %W[ -DLLVM_ROOT_DIR=#{Formula["llvm"].opt_prefix} ] system "cmake", "..", *args system "make" end end mkdir "build" do args = std_cmake_args + %W[ -DLLVM_ROOT_DIR=#{Formula["llvm"].opt_prefix} -DINCLUDE_INSTALL_DIR=#{include}/dlang/ldc -DD_COMPILER=#{buildpath}/ldc-lts/build/bin/ldmd2 ] system "cmake", "..", *args system "make" system "make", "install" end end test do (testpath/"test.d").write <<-EOS.undent import std.stdio; void main() { writeln("Hello, world!"); } EOS system bin/"ldc2", "-flto=full", "test.d" assert_match "Hello, world!", shell_output("./test") system bin/"ldmd2", "test.d" assert_match "Hello, world!", shell_output("./test") end end