-
Notifications
You must be signed in to change notification settings - Fork 0
/
ldc.rb
80 lines (70 loc) · 2.48 KB
/
ldc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
class Ldc < Formula
desc "Portable D programming language compiler"
homepage "https://wiki.dlang.org/LDC"
revision 2
stable do
url "https://github.com/ldc-developers/ldc/releases/download/v1.8.0/ldc-1.8.0-src.tar.gz"
sha256 "e421a1f4bbf97d173bd277125794862ca5b6a09409586b806cec23b922955c7f"
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 "99490b9435a79c78061962991d83d5be2ffd6cdc16512f479024e0035c4e96da" => :high_sierra
sha256 "c45b6622177a989f9b14f9722ce0cf8406a9b3af4c2a55aa87ca7dfad26eb899" => :sierra
sha256 "abd3dbef86edde7285bfbb7d66956341e5f2fca7445c876e1d8a525a8754650e" => :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
depends_on "cmake" => :build
depends_on "libconfig" => :build
depends_on "llvm@5"
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@5"].opt_prefix}
]
system "cmake", "..", *args
system "make"
end
end
mkdir "build" do
args = std_cmake_args + %W[
-DLLVM_ROOT_DIR=#{Formula["llvm@5"].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