homebrew-core/Formula/emscripten.rb
2018-10-30 11:06:51 +01: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.15.tar.gz"
sha256 "48ded851f0686717c129f0a8dd37eb6434399c9078beb99a4a60ea05c3aea31d"
resource "fastcomp" do
url "https://github.com/kripken/emscripten-fastcomp/archive/1.38.15.tar.gz"
sha256 "89d77e820c60f64b5b0cc5e9531a63aa0bd6e3af27d4b9ace82bc00d9c6902ae"
end
resource "fastcomp-clang" do
url "https://github.com/kripken/emscripten-fastcomp-clang/archive/1.38.15.tar.gz"
sha256 "b9f26967b21c93f76e7da387c82253073501ebcf16435002fc29767938509d85"
end
end
bottle do
cellar :any
sha256 "a86f91d139ad8cd4517cb115e10347dcccc24ee52315a9be9ea145c7e1153884" => :mojave
sha256 "d1bc434d3a3770a56b8051376c4a594b4ac6ea993129ebc38ce74953b8cb501e" => :high_sierra
sha256 "4d32b77d1b607de6b139a00dc9fbdd2fb640c9fb0fba2423d0934de0b4512ebe" => :sierra
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
depends_on "cmake" => :build
depends_on "node"
depends_on "python@2"
depends_on "yuicompressor"
depends_on "closure-compiler" => :optional
needs :cxx11
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