66 lines
2.1 KiB
Ruby
66 lines
2.1 KiB
Ruby
class Nim < Formula
|
|
desc "Statically typed, imperative programming language"
|
|
homepage "https://nim-lang.org/"
|
|
url "https://nim-lang.org/download/nim-0.18.0.tar.xz"
|
|
sha256 "2ebe164eb4638a7a65aa02da7bdc4d7559026105655fdf3f620b9525406a46c1"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "249cd3f7f4cf8647528e4938bff0ea54bbb266bfd2b908ab9e2f7825a776e70f" => :high_sierra
|
|
sha256 "0144771b6b89b7a03403c7924fa7d770f836cbd2dee0edc5a0687b0ada6adb1b" => :sierra
|
|
sha256 "f89bf02352fd3580fef36b7e7626cc0e99ccabed9513b5b2dba62b906bc5a93e" => :el_capitan
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/nim-lang/Nim.git", :branch => "devel"
|
|
resource "csources" do
|
|
url "https://github.com/nim-lang/csources.git"
|
|
end
|
|
end
|
|
|
|
def install
|
|
if build.head?
|
|
resource("csources").stage do
|
|
system "/bin/sh", "build.sh"
|
|
build_bin = buildpath/"bin"
|
|
build_bin.install "bin/nim"
|
|
end
|
|
else
|
|
system "/bin/sh", "build.sh"
|
|
end
|
|
# Compile the koch management tool
|
|
system "bin/nim", "c", "-d:release", "koch"
|
|
# Build a new version of the compiler with readline bindings
|
|
system "./koch", "boot", "-d:release", "-d:useLinenoise"
|
|
# Build nimsuggest/nimble/nimgrep
|
|
system "./koch", "tools"
|
|
system "./koch", "geninstall"
|
|
system "/bin/sh", "install.sh", prefix
|
|
bin.install_symlink prefix/"nim/bin/nim"
|
|
bin.install_symlink prefix/"nim/bin/nim" => "nimrod"
|
|
|
|
target = prefix/"nim/bin"
|
|
target.install "bin/nimsuggest"
|
|
target.install "bin/nimble"
|
|
target.install "bin/nimgrep"
|
|
bin.install_symlink prefix/"nim/bin/nimsuggest"
|
|
bin.install_symlink target/"nimble"
|
|
bin.install_symlink target/"nimgrep"
|
|
end
|
|
|
|
test do
|
|
(testpath/"hello.nim").write <<~EOS
|
|
echo("hello")
|
|
EOS
|
|
assert_equal "hello", shell_output("#{bin}/nim compile --verbosity:0 --run #{testpath}/hello.nim").chomp
|
|
|
|
(testpath/"hello.nimble").write <<~EOS
|
|
version = "0.1.0"
|
|
author = "Author Name"
|
|
description = "A test nimble package"
|
|
license = "MIT"
|
|
requires "nim >= 0.15.0"
|
|
EOS
|
|
assert_equal "name: \"hello\"\n", shell_output("#{bin}/nimble dump").lines.first
|
|
end
|
|
end
|