homebrew-core/Formula/haxe.rb

86 lines
2.6 KiB
Ruby

class Haxe < Formula
desc "Multi-platform programming language"
homepage "https://haxe.org/"
url "https://github.com/HaxeFoundation/haxe.git",
tag: "4.1.3",
revision: "c7d2c7aac5f8d280d694e46fc1c9de52e218b9c6"
head "https://github.com/HaxeFoundation/haxe.git", branch: "development"
livecheck do
url "https://github.com/HaxeFoundation/haxe/releases/latest"
regex(%r{href=.*?/tag/v?(\d+(?:\.\d+)+)["' >]}i)
end
bottle do
cellar :any
sha256 "53d69a9f8c0c0a757f7626260200a47c25bed78438fd675f7c1bd1c3da5276bc" => :catalina
sha256 "35acb01a0d40087fb8194c17ae1b38a422469bf2c1537a6412a24fa38a1f0217" => :mojave
sha256 "580bf94faade767c8078fe8c5622a37d7d6cd3e70531ab8eef7dff77c4844d67" => :high_sierra
end
depends_on "cmake" => :build
depends_on "ocaml" => :build
depends_on "opam" => :build
depends_on "pkg-config" => :build
depends_on "mbedtls"
depends_on "neko"
depends_on "pcre"
uses_from_macos "m4" => :build
uses_from_macos "unzip" => :build
def install
# Build requires targets to be built in specific order
ENV.deparallelize
Dir.mktmpdir("opamroot") do |opamroot|
ENV["OPAMROOT"] = opamroot
ENV["OPAMYES"] = "1"
ENV["ADD_REVISION"] = "1" if build.head?
system "opam", "init", "--no-setup", "--disable-sandboxing"
system "opam", "config", "exec", "--",
"opam", "pin", "add", "haxe", buildpath, "--no-action"
system "opam", "config", "exec", "--",
"opam", "install", "haxe", "--deps-only"
system "opam", "config", "exec", "--",
"make"
end
# Rebuild haxelib as a valid binary
cd "extra/haxelib_src" do
system "cmake", ".", *std_cmake_args
system "make"
end
rm "haxelib"
cp "extra/haxelib_src/haxelib", "haxelib"
bin.mkpath
system "make", "install", "INSTALL_BIN_DIR=#{bin}",
"INSTALL_LIB_DIR=#{lib}/haxe", "INSTALL_STD_DIR=#{lib}/haxe/std"
end
def caveats
<<~EOS
Add the following line to your .bashrc or equivalent:
export HAXE_STD_PATH="#{HOMEBREW_PREFIX}/lib/haxe/std"
EOS
end
test do
ENV["HAXE_STD_PATH"] = "#{HOMEBREW_PREFIX}/lib/haxe/std"
system "#{bin}/haxe", "-v", "Std"
system "#{bin}/haxelib", "version"
(testpath/"HelloWorld.hx").write <<~EOS
import js.html.Console;
class HelloWorld {
static function main() Console.log("Hello world!");
}
EOS
system "#{bin}/haxe", "-js", "out.js", "-main", "HelloWorld"
_, stderr, = Open3.capture3("osascript -so -lJavaScript out.js")
assert_match /^Hello world!$/, stderr
end
end