homebrew-core/Formula/emscripten.rb
2018-06-13 23:27:42 -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.6.tar.gz"
sha256 "7e0d07beaa6177d7fca4446ed825cecf07ca4ced4a710f29411eea2082e763d5"
resource "fastcomp" do
url "https://github.com/kripken/emscripten-fastcomp/archive/1.38.6.tar.gz"
sha256 "1f313724c9353687c4c830f054bf7410706bedb62a718d37de3b5e9ea22bb9ab"
end
resource "fastcomp-clang" do
url "https://github.com/kripken/emscripten-fastcomp-clang/archive/1.38.6.tar.gz"
sha256 "d61baa557a9cbb5c787bb9823f6c1b99d9ff123953531e74b046577f81ebb275"
end
end
bottle do
cellar :any
sha256 "e771069dca3d80bb68ec71492f64a335ae467b53a4a2047aa573fe0702d3b180" => :high_sierra
sha256 "db21575f88767911c065d64ca2cb51706cb8fcbf9e0d1865d6fcf0e29bec0139" => :sierra
sha256 "d1c8bfe17f35d0b655ff015ecf4a9fe970bee9672e2d66f879b91299c5ae192d" => :el_capitan
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@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