homebrew-core/Formula/emscripten.rb
2018-05-10 00:01:57 -07: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.38.0.tar.gz"
sha256 "74ef9107ff74ba5ff6fa9d6c054d2e237dd14e6c2a24d5664b46d56210a83764"
resource "fastcomp" do
url "https://github.com/kripken/emscripten-fastcomp/archive/1.38.0.tar.gz"
sha256 "e7d81790dab6201f3fb2db391a3e913d8904268e31e7ba1052942cdbbad147ca"
end
resource "fastcomp-clang" do
url "https://github.com/kripken/emscripten-fastcomp-clang/archive/1.38.0.tar.gz"
sha256 "31f1be3fc93533d2649adc60c186d4253c3e6bf4c33c0bf985a6386dd70e1886"
end
end
bottle do
cellar :any
sha256 "23fcde84c6c86ab3c412b0a865960b35ffbe57499d089d5f50e987ef65eed5eb" => :high_sierra
sha256 "6c5b6ac3caf1606672742a91e6412fd11d4a3178287ca2c41dabc64edbde0e43" => :sierra
sha256 "591ede08cc227b870f57b2729065e4e269dadca724993335b653a844c01cd91d" => :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
# rewrite hardcoded paths from system python to homebrew python
python2_shebangs = `grep --recursive --files-with-matches ^#!/usr/bin/python #{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/python2?$}, "#!#{Formula["python@2"].opt_bin}/python2"
# 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