homebrew-core/Formula/emscripten.rb
2015-10-21 00:22:25 +01:00

92 lines
2.9 KiB
Ruby

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.0.tar.gz"
sha256 "d9e84330ad97be018e5015e9cc6ecf3423d438f6a1a73f7ad359d4d1e8afa4b3"
resource "fastcomp" do
url "https://github.com/kripken/emscripten-fastcomp/archive/1.35.0.tar.gz"
sha256 "e70aec0e821f2c0a00cb59219f48e279d85f38b1f749ba479d0d2edd6bb066c5"
end
resource "fastcomp-clang" do
url "https://github.com/kripken/emscripten-fastcomp-clang/archive/1.35.0.tar.gz"
sha256 "dc9b33f88124806b95648dec8b0b60b1520c7b52779471559e06e12630c8eb32"
end
end
bottle do
sha256 "979016f3e884da501400132f924bfc39b35b19a84be3efe57ff2fdd896bd74fa" => :el_capitan
sha256 "0731e03a5c1d4b77fe2e41703cfc5a363fd6baa1f494c8118a5db0a6ff4ee662" => :yosemite
sha256 "a6ccaaa8a885dd97d395091a3a6b9258b2d61a6a975fc42a7c195282b01f3b76" => :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",
]
cd "fastcomp" 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