119 lines
4.2 KiB
Ruby
119 lines
4.2 KiB
Ruby
class Crystal < Formula
|
|
desc "Fast and statically typed, compiled language with Ruby-like syntax"
|
|
homepage "https://crystal-lang.org/"
|
|
license "Apache-2.0"
|
|
|
|
stable do
|
|
url "https://github.com/crystal-lang/crystal/archive/1.1.1.tar.gz"
|
|
sha256 "add4b07f23de6e493a17d951e4cff38e1cbf2356cc4a3f642687c769f9ba7d12"
|
|
|
|
resource "shards" do
|
|
url "https://github.com/crystal-lang/shards/archive/v0.15.0.tar.gz"
|
|
sha256 "89ad7f7550a6036b376008c9e376a3b9fbf4aca9f7d2eae5086282122e92711a"
|
|
end
|
|
end
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 big_sur: "b7abbccaeb24c6f7c49bfa4036690462e271475ac6d9190e9946ef7a887c4098"
|
|
sha256 catalina: "5d21445288240651ccf2bed421b2127884c12191a6ca514f609fe886337d46ef"
|
|
sha256 mojave: "a2e65148242942f13794248d54063f652336e34e8de98aa776e266b5cd8daaa2"
|
|
sha256 x86_64_linux: "635aa215f78244e1a6d4df02d909a436f5a150af2fd261615bbe3e6843aebf3f"
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/crystal-lang/crystal.git"
|
|
|
|
resource "shards" do
|
|
url "https://github.com/crystal-lang/shards.git"
|
|
end
|
|
end
|
|
|
|
depends_on "bdw-gc"
|
|
depends_on "gmp" # std uses it but it's not linked
|
|
depends_on "libevent"
|
|
depends_on "libyaml"
|
|
depends_on "llvm@11"
|
|
depends_on "openssl@1.1" # std uses it but it's not linked
|
|
depends_on "pcre"
|
|
depends_on "pkg-config" # @[Link] will use pkg-config if available
|
|
|
|
resource "boot" do
|
|
on_macos do
|
|
url "https://github.com/crystal-lang/crystal/releases/download/1.0.0/crystal-1.0.0-1-darwin-x86_64.tar.gz"
|
|
version "1.0.0-1"
|
|
sha256 "29019828d32df9807a3f08fb7354fa0e44a5ad8b000eccd1dea114f891cbc006"
|
|
end
|
|
on_linux do
|
|
url "https://github.com/crystal-lang/crystal/releases/download/1.0.0/crystal-1.0.0-1-linux-x86_64.tar.gz"
|
|
version "1.0.0-1"
|
|
sha256 "00211ca77758e99210ec40b8c5517b086d2ff9909e089400f6d847a95e5689a4"
|
|
end
|
|
end
|
|
|
|
def install
|
|
(buildpath/"boot").install resource("boot")
|
|
ENV.append_path "PATH", "boot/bin"
|
|
ENV.append_path "CRYSTAL_LIBRARY_PATH", Formula["bdw-gc"].opt_lib
|
|
ENV.append_path "CRYSTAL_LIBRARY_PATH", ENV["HOMEBREW_LIBRARY_PATHS"]
|
|
ENV.append_path "LLVM_CONFIG", Formula["llvm@11"].opt_bin/"llvm-config"
|
|
|
|
# Build crystal
|
|
crystal_build_opts = []
|
|
crystal_build_opts << "release=true"
|
|
crystal_build_opts << "FLAGS=--no-debug"
|
|
crystal_build_opts << "CRYSTAL_CONFIG_LIBRARY_PATH="
|
|
crystal_build_opts << "CRYSTAL_CONFIG_BUILD_COMMIT=#{Utils.git_short_head}" if build.head?
|
|
(buildpath/".build").mkpath
|
|
system "make", "deps"
|
|
system "make", "crystal", *crystal_build_opts
|
|
|
|
# Build shards (with recently built crystal)
|
|
#
|
|
# Setup the same path the wrapper script would, but just for building shards.
|
|
# NOTE: it seems that the installed crystal in bin/"crystal" can be used while
|
|
# building the formula. Otherwise this ad-hoc setup could be avoided.
|
|
embedded_crystal_path=`"#{buildpath/".build/crystal"}" env CRYSTAL_PATH`.strip
|
|
ENV["CRYSTAL_PATH"] = "#{embedded_crystal_path}:#{buildpath/"src"}"
|
|
|
|
# Install shards
|
|
resource("shards").stage do
|
|
system "make", "bin/shards", "CRYSTAL=#{buildpath/"bin/crystal"}",
|
|
"SHARDS=false",
|
|
"release=true",
|
|
"FLAGS=--no-debug"
|
|
|
|
# Install shards
|
|
bin.install "bin/shards"
|
|
man1.install "man/shards.1"
|
|
man5.install "man/shard.yml.5"
|
|
end
|
|
|
|
# Install crystal
|
|
libexec.install ".build/crystal"
|
|
(bin/"crystal").write <<~SH
|
|
#!/bin/bash
|
|
EMBEDDED_CRYSTAL_PATH=$("#{libexec/"crystal"}" env CRYSTAL_PATH)
|
|
export CRYSTAL_PATH="${CRYSTAL_PATH:-"$EMBEDDED_CRYSTAL_PATH:#{prefix/"src"}"}"
|
|
export CRYSTAL_LIBRARY_PATH="${CRYSTAL_LIBRARY_PATH:+$CRYSTAL_LIBRARY_PATH:}#{HOMEBREW_PREFIX}/lib"
|
|
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH:+$PKG_CONFIG_PATH:}#{Formula["openssl@1.1"].opt_lib/"pkgconfig"}"
|
|
exec "#{libexec/"crystal"}" "${@}"
|
|
SH
|
|
|
|
prefix.install "src"
|
|
|
|
bash_completion.install "etc/completion.bash" => "crystal"
|
|
zsh_completion.install "etc/completion.zsh" => "_crystal"
|
|
|
|
man1.install "man/crystal.1"
|
|
end
|
|
|
|
test do
|
|
assert_match "1", shell_output("#{bin}/crystal eval puts 1")
|
|
end
|
|
end
|