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.7.0/ldc-1.7.0-src.tar.gz" sha256 "7cd46140ca3e4ca0d52c352e5b694d4d5336898ed4f02c3e18e0eafd69dd18bd" resource "ldc-lts" do url "https://github.com/ldc-developers/ldc/releases/download/v0.17.5/ldc-0.17.5-src.tar.gz" sha256 "7aa540a135f9fa1ee9722cad73100a8f3600a07f9a11d199d8be68887cc90008" end end bottle do sha256 "b94a78eb56c888d137870b5674510e899e40fd153829e560debc3f99ed49547f" => :high_sierra sha256 "aa3aedaea3ca30fea1c8aeb0158bd2ed91c796dec52a96f992c9b988e11aed38" => :sierra sha256 "50d0676d3b51c574923d110004f2efea2b5dfc8ea2b4f3458141bccd94c272d0" => :el_capitan 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 "libconfig" => :build depends_on "llvm" 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 -DLDC_WITH_LLD=OFF -DRT_ARCHIVE_WITH_LDC=OFF ] # LDC_WITH_LLD see https://github.com/ldc-developers/ldc/releases/tag/v1.4.0 Known issues # RT_ARCHIVE_WITH_LDC see https://github.com/ldc-developers/ldc/issues/2350 system "cmake", "..", *args system "make" system "make", "install" end end test do (testpath/"test.d").write <<~EOS import std.stdio; void main() { writeln("Hello, world!"); } EOS system bin/"ldc2", "test.d" assert_match "Hello, world!", shell_output("./test") system bin/"ldc2", "-flto=thin", "test.d" assert_match "Hello, world!", shell_output("./test") 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