86 lines
2.6 KiB
Ruby
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.4",
|
|
revision: "7d0faa039ffe5e618587e2417323b59044282177"
|
|
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 "4d198b6fe5ad9addbaadd2aba3a43e4f0a356cfd632e389af76c83a8eb1246a6" => :catalina
|
|
sha256 "077d47ef86c0c3ccdc5f4c7c92b5485e76727afc3096d19bf149125e60ad5ce3" => :mojave
|
|
sha256 "3c8e7a07d745f290ef54154a05b730440cb319ec84319e6117e59936510b3234" => :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
|