64 lines
2.0 KiB
Ruby
64 lines
2.0 KiB
Ruby
class Nim < Formula
|
|
desc "Statically typed compiled systems programming language"
|
|
homepage "https://nim-lang.org/"
|
|
url "https://nim-lang.org/download/nim-1.0.6.tar.xz"
|
|
sha256 "134e5751cf62fa189f76616a698ce0df4b4a0c1419ec0b582924087e585f66b3"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "8dfeb3aeb5cb403e0c9f2b30a0c161ef2fce6c9696e39d78dbc05ec962ae15d0" => :catalina
|
|
sha256 "2c50f99da7e1841c56d4273bd3671b019aaf9e5c635d912696b5d858f2282b74" => :mojave
|
|
sha256 "a4ae43af2717855750783e00dfde826a31b20ebfffbbb51cea49dc910efce8d5" => :high_sierra
|
|
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"
|
|
(buildpath/"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 nimble/nimgrep/nimpretty/nimsuggest
|
|
system "./koch", "tools"
|
|
system "./koch", "geninstall"
|
|
system "/bin/sh", "install.sh", prefix
|
|
|
|
target = prefix/"nim/bin"
|
|
bin.install_symlink target/"nim"
|
|
tools = %w[nimble nimgrep nimpretty nimsuggest]
|
|
tools.each do |t|
|
|
target.install buildpath/"bin"/t
|
|
bin.install_symlink target/t
|
|
end
|
|
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
|