100 lines
3.3 KiB
Ruby
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.21.tar.gz"
|
|
sha256 "f3e6f1e6039256968131bc491ea8c2e1bfc31c41c1ec1370e2f1fae9a8e56faa"
|
|
|
|
resource "fastcomp" do
|
|
url "https://github.com/kripken/emscripten-fastcomp/archive/1.38.21.tar.gz"
|
|
sha256 "d77aa245747df5d807ab36f91cd27495e5c8d08b0addf6becdc618d80025ba0b"
|
|
end
|
|
|
|
resource "fastcomp-clang" do
|
|
url "https://github.com/kripken/emscripten-fastcomp-clang/archive/1.38.21.tar.gz"
|
|
sha256 "a14e445d295c31e998b171eb81f15fab389936b11a548ddb33fc9fb6c425d045"
|
|
end
|
|
end
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "40bf5a54f1dc06fefe06ce0d36b1883524a5bb65a37ca271f905e1000cb22377" => :mojave
|
|
sha256 "a6e5be8a3e734f36470f3a09738c383cc36f20d4e26b7d88a2e10f2ef2cf603e" => :high_sierra
|
|
sha256 "6bc9550a1b785e5524e4b87344276fb37624b88fc04b96dda039c7d4455826ce" => :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
|