homebrew-core/Formula/emscripten.rb
2018-04-14 15:35:46 +10: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.37.tar.gz"
sha256 "54dd609a85014e7b2784a99984f29b0853c7a2fdbc80737445fac9dda45e4bfb"
resource "fastcomp" do
url "https://github.com/kripken/emscripten-fastcomp/archive/1.37.37.tar.gz"
sha256 "4f4903a598eb636f840441833b727d45fc2675d660962f40bd1512a5aaef6acc"
end
resource "fastcomp-clang" do
url "https://github.com/kripken/emscripten-fastcomp-clang/archive/1.37.37.tar.gz"
sha256 "a5fb2db0c8c8ffd25f5dc0f8bb0c8043609b7bdb54272d5d60ee4d89e791f13c"
end
end
bottle do
cellar :any
sha256 "19ff0a582db9cd1e0fff7d7f8bd4044b19bf28714377349789abd1df60a92f6f" => :high_sierra
sha256 "8d833a98e1a4808f070532e359eb30d3da52b20b452fdb6b4151d4381bab0f72" => :sierra
sha256 "665595f5cdf1d8f5015a0a1343cb987ce6ab806f0175e672ccabbf14dab6ff8e" => :el_capitan
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@2"
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
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 bin/"emcc"
assert_predicate testpath/".emscripten", :exist?, "Failed to create sample config"
end
end