class Emscripten < Formula desc "LLVM bytecode to JavaScript compiler" homepage "https://kripken.github.io/emscripten-site/" stable do url "https://github.com/kripken/emscripten/archive/1.35.9.tar.gz" sha256 "bc6966366d1d7720d362bf00f4c98de49ad0b7078909123a06cb02f764d4db3c" resource "fastcomp" do url "https://github.com/kripken/emscripten-fastcomp/archive/1.35.9.tar.gz" sha256 "87e1ea01868e775227a57f23ea21be9d47d1fe0e73682bd4a9ef4ae73cf3a2e4" end resource "fastcomp-clang" do url "https://github.com/kripken/emscripten-fastcomp-clang/archive/1.35.9.tar.gz" sha256 "df55066375dd778186c7647a465bab5b09c5506a1c4cb90727fb1798a016b1bb" end end bottle do sha256 "96e322f558865c833396f5ca909fb4ddf52a57f50679f9b36bfa38666c5b28c7" => :el_capitan sha256 "46091d97d09b351fc85e3265930e6c6734585cb6ff01fd570bb6c5dbc750d460" => :yosemite sha256 "d8e41f09998f42c014cf636eeb99bbbc91bf9193745181f72ab818391f43be03" => :mavericks end head do url "https://github.com/kripken/emscripten.git", :branch => "incoming" resource "fastcomp" do url "https://github.com/kripken/emscripten-fastcomp.git", :branch => "incoming" end resource "fastcomp-clang" do url "https://github.com/kripken/emscripten-fastcomp-clang.git", :branch => "incoming" end end needs :cxx11 depends_on :python if MacOS.version <= :snow_leopard depends_on "node" depends_on "closure-compiler" => :optional depends_on "yuicompressor" def install ENV.cxx11 # OSX doesn't provide a "python2" binary so use "python" instead. python2_shebangs = `grep --recursive --files-with-matches ^#!/usr/bin/.*python2$ #{buildpath}` python2_shebang_files = python2_shebangs.lines.sort.uniq python2_shebang_files.map! { |f| Pathname(f.chomp) } python2_shebang_files.reject! &:symlink? inreplace python2_shebang_files, %r{^(#!/usr/bin/.*python)2$}, "\\1" # All files from the repository are required as emscripten is a collection # of scripts which need to be installed in the same layout as in the Git # repository. libexec.install Dir["*"] (buildpath/"fastcomp").install resource("fastcomp") (buildpath/"fastcomp/tools/clang").install resource("fastcomp-clang") args = [ "--prefix=#{libexec}/llvm", "--enable-optimized", "--enable-targets=host,js", "--disable-assertions", "--disable-bindings", ] mkdir "fastcomp/build" do system "../configure", *args system "make" system "make", "install" end %w[em++ em-config emar emcc emcmake emconfigure emlink.py emmake emranlib emrun emscons].each do |emscript| bin.install_symlink libexec/emscript end end def caveats; <<-EOS.undent Manually set LLVM_ROOT to #{opt_libexec}/llvm/bin in ~/.emscripten after running `emcc` for the first time. EOS end test do system "#{libexec}/llvm/bin/llvm-config", "--version" end end