homebrew-core/Formula/crystal.rb
2018-08-20 11:59:53 +02:00

84 lines
2.8 KiB
Ruby

class Crystal < Formula
desc "Fast and statically typed, compiled language with Ruby-like syntax"
homepage "https://crystal-lang.org/"
stable do
url "https://github.com/crystal-lang/crystal/archive/0.26.0.tar.gz"
sha256 "e98cf1403d5182fce888a120cda61918c329244765eaa265a17038bbfb217ba3"
resource "shards" do
url "https://github.com/crystal-lang/shards/archive/v0.8.1.tar.gz"
sha256 "75c74ab6acf2d5c59f61a7efd3bbc3c4b1d65217f910340cb818ebf5233207a5"
end
end
bottle do
sha256 "18af384d3dda852dfc86683c3696ac3d35986ab45a9562fb17f698d422a2c103" => :mojave
sha256 "42bbf810ed2f3bad9708b596409989265281c32ed801963d99e744c8c9743a34" => :high_sierra
sha256 "8fa840a8c937bc01eba1bb298255102ff960d9d945bd63b35798ed0b44f53841" => :sierra
sha256 "8b4bb9364d4d1a367e3e3037584621d525452e84eb46a715f9efa5a6167f2fb7" => :el_capitan
end
head do
url "https://github.com/crystal-lang/crystal.git"
resource "shards" do
url "https://github.com/crystal-lang/shards.git"
end
end
option "without-release", "Do not build the compiler in release mode"
option "without-shards", "Do not include `shards` dependency manager"
depends_on "pkg-config" => :build
depends_on "libatomic_ops" => :build # for building bdw-gc
depends_on "libevent"
depends_on "bdw-gc"
depends_on "llvm"
depends_on "pcre"
depends_on "gmp" # std uses it but it's not linked
depends_on "libyaml" if build.with? "shards"
resource "boot" do
url "https://github.com/crystal-lang/crystal/releases/download/0.25.1/crystal-0.25.1-2-darwin-x86_64.tar.gz"
version "0.25.1-2"
sha256 "6a72db4b4b9323186b6da3f72c7c4b1aaaa06a036707bd9fe4ffb60575edc6db"
end
def install
(buildpath/"boot").install resource("boot")
if build.head?
ENV["CRYSTAL_CONFIG_VERSION"] = Utils.popen_read("git rev-parse --short HEAD").strip
else
ENV["CRYSTAL_CONFIG_VERSION"] = version
end
ENV["CRYSTAL_CONFIG_PATH"] = prefix/"src:lib"
ENV.append_path "PATH", "boot/bin"
system "make", "deps"
(buildpath/".build").mkpath
command = ["bin/crystal", "build", "-D", "without_openssl", "-D", "without_zlib", "-o", ".build/crystal", "src/compiler/crystal.cr"]
command.concat ["--release", "--no-debug"] if build.with? "release"
system *command
if build.with? "shards"
resource("shards").stage do
system buildpath/"bin/crystal", "build", "-o", buildpath/".build/shards", "src/shards.cr"
end
bin.install ".build/shards"
end
bin.install ".build/crystal"
prefix.install "src"
bash_completion.install "etc/completion.bash" => "crystal"
zsh_completion.install "etc/completion.zsh" => "_crystal"
end
test do
assert_match "1", shell_output("#{bin}/crystal eval puts 1")
end
end