125 lines
3.6 KiB
Ruby
125 lines
3.6 KiB
Ruby
class Dmd < Formula
|
|
desc "D programming language compiler for macOS"
|
|
homepage "https://dlang.org/"
|
|
license "BSL-1.0"
|
|
|
|
stable do
|
|
url "https://github.com/dlang/dmd/archive/v2.093.1.tar.gz"
|
|
sha256 "4fd9fe3bdca776a0bf5edab651fe39429948735ed79d55e34ebe6ad2044a13f9"
|
|
|
|
resource "druntime" do
|
|
url "https://github.com/dlang/druntime/archive/v2.093.1.tar.gz"
|
|
sha256 "f4b78f26322186c9332d5150a91ba75dca29db2db99f7cae57150f6614113cc0"
|
|
end
|
|
|
|
resource "phobos" do
|
|
url "https://github.com/dlang/phobos/archive/v2.093.1.tar.gz"
|
|
sha256 "66b3a75c5b313e823d252b87e4e1d02a39d24079ccb956c806f960a1617288c0"
|
|
end
|
|
|
|
resource "tools" do
|
|
url "https://github.com/dlang/tools/archive/v2.093.1.tar.gz"
|
|
sha256 "deceea44f176b31703a11a71e827416bfc4172a368e7fa0eceece8f397cb1553"
|
|
end
|
|
end
|
|
|
|
bottle do
|
|
sha256 "15c6aa24b2594155f9f88471af1fa7697cdbe1fcbaec088caf62b8efb843db81" => :catalina
|
|
sha256 "fc03172f4d36276ef0f3620a74a3074055ae44d2638913a1af49df070ce383ac" => :mojave
|
|
sha256 "e2f443a408dbbd334c3ba809598aa0c7deff364f20d1cae831ca39c8217b9829" => :high_sierra
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/dlang/dmd.git"
|
|
|
|
resource "druntime" do
|
|
url "https://github.com/dlang/druntime.git"
|
|
end
|
|
|
|
resource "phobos" do
|
|
url "https://github.com/dlang/phobos.git"
|
|
end
|
|
|
|
resource "tools" do
|
|
url "https://github.com/dlang/tools.git"
|
|
end
|
|
end
|
|
|
|
uses_from_macos "unzip" => :build
|
|
uses_from_macos "xz" => :build
|
|
|
|
def install
|
|
# DMD defaults to v2.088.0 to bootstrap as of DMD 2.090.0
|
|
# On MacOS Catalina, a version < 2.087.1 would not work due to TLS related symbols missing
|
|
|
|
make_args = %W[
|
|
INSTALL_DIR=#{prefix}
|
|
MODEL=64
|
|
BUILD=release
|
|
-f posix.mak
|
|
]
|
|
|
|
dmd_make_args = %W[
|
|
SYSCONFDIR=#{etc}
|
|
TARGET_CPU=X86
|
|
AUTO_BOOTSTRAP=1
|
|
ENABLE_RELEASE=1
|
|
]
|
|
|
|
system "make", *dmd_make_args, *make_args
|
|
|
|
make_args.unshift "DMD_DIR=#{buildpath}", "DRUNTIME_PATH=#{buildpath}/druntime", "PHOBOS_PATH=#{buildpath}/phobos"
|
|
|
|
(buildpath/"druntime").install resource("druntime")
|
|
system "make", "-C", "druntime", *make_args
|
|
|
|
(buildpath/"phobos").install resource("phobos")
|
|
system "make", "-C", "phobos", "VERSION=#{buildpath}/VERSION", *make_args
|
|
|
|
resource("tools").stage do
|
|
inreplace "posix.mak", "install: $(TOOLS) $(CURL_TOOLS)", "install: $(TOOLS) $(ROOT)/dustmite"
|
|
system "make", "install", *make_args
|
|
end
|
|
|
|
bin.install "generated/osx/release/64/dmd"
|
|
pkgshare.install "samples"
|
|
man.install Dir["docs/man/*"]
|
|
|
|
(include/"dlang/dmd").install Dir["druntime/import/*"]
|
|
cp_r ["phobos/std", "phobos/etc"], include/"dlang/dmd"
|
|
lib.install Dir["druntime/lib/*", "phobos/**/libphobos2.a"]
|
|
|
|
(buildpath/"dmd.conf").write <<~EOS
|
|
[Environment]
|
|
DFLAGS=-I#{opt_include}/dlang/dmd -L-L#{opt_lib}
|
|
EOS
|
|
etc.install "dmd.conf"
|
|
end
|
|
|
|
# Previous versions of this formula may have left in place an incorrect
|
|
# dmd.conf. If it differs from the newly generated one, move it out of place
|
|
# and warn the user.
|
|
def install_new_dmd_conf
|
|
conf = etc/"dmd.conf"
|
|
|
|
# If the new file differs from conf, etc.install drops it here:
|
|
new_conf = etc/"dmd.conf.default"
|
|
# Else, we're already using the latest version:
|
|
return unless new_conf.exist?
|
|
|
|
backup = etc/"dmd.conf.old"
|
|
opoo "An old dmd.conf was found and will be moved to #{backup}."
|
|
mv conf, backup
|
|
mv new_conf, conf
|
|
end
|
|
|
|
def post_install
|
|
install_new_dmd_conf
|
|
end
|
|
|
|
test do
|
|
system bin/"dmd", pkgshare/"samples/hello.d"
|
|
system "./hello"
|
|
end
|
|
end
|