homebrew-core/Formula/emscripten.rb
2017-04-26 23:26:49 +02:00

100 lines
3.3 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.37.10.tar.gz"
sha256 "acd756abf7bb687d1fef733c49b3fb45305da6c777381f2699aa1a91b2ffbf9c"
emscripten_tag = version.to_s
resource "fastcomp" do
url "https://github.com/kripken/emscripten-fastcomp/archive/#{emscripten_tag}.tar.gz"
sha256 "68c2b3f7c3ba3c5fc65a1a2bbb4362c2633baf8410c23895c13fbf945b53e4a8"
end
resource "fastcomp-clang" do
url "https://github.com/kripken/emscripten-fastcomp-clang/archive/#{emscripten_tag}.tar.gz"
sha256 "b647336a964e252d1f13f94a191dbd58cc8b398cc6f83d66f49349f948283d3d"
end
end
bottle do
cellar :any
sha256 "f67a25acc1f4d71d1cf3e8c85da143f178cf78aa71e67a7765f58e9130f12bd2" => :sierra
sha256 "60a8ed033902c63ae70b56578d2cb86f8aafaabebb879d946acdf0f6e66b4f9d" => :el_capitan
sha256 "23cb3b65b6fb2ab34de60bf889741906a09e41f1b6ebac14af1d5856052ef3fb" => :yosemite
end
head do
url "https://github.com/kripken/emscripten.git", :branch => "master"
resource "fastcomp" do
url "https://github.com/kripken/emscripten-fastcomp.git", :branch => "master"
end
resource "fastcomp-clang" do
url "https://github.com/kripken/emscripten-fastcomp-clang.git", :branch => "master"
end
end
needs :cxx11
depends_on :python if MacOS.version <= :snow_leopard
depends_on "cmake" => :build
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")
cmake_args = std_cmake_args.reject { |s| s["CMAKE_INSTALL_PREFIX"] }
cmake_args = [
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_INSTALL_PREFIX=#{libexec}/llvm",
"-DLLVM_TARGETS_TO_BUILD='X86;JSBackend'",
"-DLLVM_INCLUDE_EXAMPLES=OFF",
"-DLLVM_INCLUDE_TESTS=OFF",
"-DCLANG_INCLUDE_TESTS=OFF",
"-DOCAMLFIND=/usr/bin/false",
"-DGO_EXECUTABLE=/usr/bin/false",
]
mkdir "fastcomp/build" do
system "cmake", "..", *cmake_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
and comment out BINARYEN_ROOT
in ~/.emscripten after running `emcc` for the first time.
EOS
end
test do
system "#{libexec}/llvm/bin/llvm-config", "--version"
end
end