117 lines
3.5 KiB
Ruby
117 lines
3.5 KiB
Ruby
class Dmd < Formula
|
|
desc "D programming language compiler for macOS"
|
|
homepage "https://dlang.org/"
|
|
license "BSL-1.0"
|
|
|
|
stable do
|
|
# make sure resources also use the same version
|
|
url "https://github.com/dlang/dmd/archive/v2.101.1.tar.gz"
|
|
sha256 "e369396dbbe4eec9311122fa24c975688b209a000bf2062a9f86b49ab2e4a7b0"
|
|
|
|
resource "phobos" do
|
|
url "https://github.com/dlang/phobos/archive/v2.101.1.tar.gz"
|
|
sha256 "8a275b3f46d921be87744ec80d3094421a979d6f607dbd43e88e251bbb3f503a"
|
|
end
|
|
|
|
resource "tools" do
|
|
url "https://github.com/dlang/tools/archive/v2.101.1.tar.gz"
|
|
sha256 "0e6892084f95f87fa330579a1f6131dec8cfa8e254aabb3cb73a5bf2a673d2ac"
|
|
end
|
|
end
|
|
|
|
bottle do
|
|
rebuild 1
|
|
sha256 ventura: "45e3f8bda3d8240f046d5294979e0c6acb90afe90d18c69fb92ab01d377062f0"
|
|
sha256 monterey: "17444c8de4bdce7347166ce845b90dd6bd9c0d0eabe2a8d845a98047b48797ad"
|
|
sha256 big_sur: "6cfb87d1ddcac123caeb24570d7bbc076cfb60822215c93520f89daed1f001dc"
|
|
sha256 x86_64_linux: "9ed704196c4b617fc824573fb55eaeeba97fc1dc97a67ecd09bac2dfc37b5d41"
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/dlang/dmd.git", branch: "master"
|
|
|
|
resource "phobos" do
|
|
url "https://github.com/dlang/phobos.git", branch: "master"
|
|
end
|
|
|
|
resource "tools" do
|
|
url "https://github.com/dlang/tools.git", branch: "master"
|
|
end
|
|
end
|
|
|
|
depends_on "ldc" => :build
|
|
depends_on arch: :x86_64
|
|
|
|
def install
|
|
dmd_make_args = %W[
|
|
INSTALL_DIR=#{prefix}
|
|
SYSCONFDIR=#{etc}
|
|
HOST_DMD=#{Formula["ldc"].opt_bin/"ldmd2"}
|
|
ENABLE_RELEASE=1
|
|
VERBOSE=1
|
|
]
|
|
|
|
system "ldc2", "compiler/src/build.d", "-of=compiler/src/build"
|
|
system "./compiler/src/build", *dmd_make_args
|
|
|
|
make_args = %W[
|
|
INSTALL_DIR=#{prefix}
|
|
MODEL=64
|
|
BUILD=release
|
|
DMD_DIR=#{buildpath}
|
|
DRUNTIME_PATH=#{buildpath}/druntime
|
|
PHOBOS_PATH=#{buildpath}/phobos
|
|
-f posix.mak
|
|
]
|
|
|
|
(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
|
|
|
|
kernel_name = OS.mac? ? "osx" : OS.kernel_name.downcase
|
|
bin.install "generated/#{kernel_name}/release/64/dmd"
|
|
pkgshare.install "compiler/samples"
|
|
man.install Dir["compiler/docs/man/*"]
|
|
|
|
(include/"dlang/dmd").install Dir["druntime/import/*"]
|
|
cp_r ["phobos/std", "phobos/etc"], include/"dlang/dmd"
|
|
lib.install Dir["druntime/**/libdruntime.*", "phobos/**/libphobos2.*"]
|
|
|
|
(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", "-fPIC", pkgshare/"samples/hello.d"
|
|
system "./hello"
|
|
end
|
|
end
|