class Nim < Formula desc "Statically typed compiled systems programming language" homepage "https://nim-lang.org/" url "https://nim-lang.org/download/nim-1.0.2.tar.xz" sha256 "73a0ae099e1da39cc913c4a4054b5bf3d843ab93df95ffb98988a51074b651e6" bottle do cellar :any_skip_relocation sha256 "6ee3bd404cc5b2b3f1cb7f1470b052879b34401028c74489a4c73308414f7360" => :catalina sha256 "8cb24b7174375f9fe696d7961cf3b703b27c1279c7fb026440ac86178803ecca" => :mojave sha256 "7379299b370756d952848a1c7ce4f583149dde80420e37eff10bc374e468ea7f" => :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