@@ -0,0 +1,71 @@
1+{ emscriptenVersion, stdenv, fetchFromGitHub, emscriptenfastcomp, python, nodejs, closurecompiler
2+, jre, binaryen, enableWasm ? true , cmake, emscriptenBackend ? emscriptenfastcomp
6+ rev = emscriptenVersion;
7+ appdir = "share/emscripten";
8+ binaryenVersioned = binaryen;
12+ name = "emscripten-${rev}";
14+ src = fetchFromGitHub {
15+ owner = "emscripten-core";
17+ sha256 = "10f2mlwh4s6v3rqghb7zdmv4ry0a4si915x4v17vp4nv7swkkwhn";
18+ rev = "fc6a4bb97b421b6dcf5806d0dc42ab8ddd4da026";
21+ buildInputs = [ nodejs cmake python ];
24+ mkdir -p $out/${appdir}
25+ cp -r $src/* $out/${appdir}
26+ chmod -R +w $out/${appdir}
27+ grep -rl '^#!/usr.*python' $out/${appdir} | xargs sed -i -s 's@^#!/usr.*python.*@#!${python}/bin/python@'
28+ sed -i -e "s,EM_CONFIG = '~/.emscripten',EM_CONFIG = '$out/${appdir}/config'," $out/${appdir}/tools/shared.py
29+ sed -i -e 's,^.*did not see a source tree above the LLVM.*$, return True,' $out/${appdir}/tools/shared.py
30+ sed -i -e 's,def check_sanity(force=False):,def check_sanity(force=False):\n return,' $out/${appdir}/tools/shared.py
31+ # fixes cmake support
32+ sed -i -e "s/print \('emcc (Emscript.*\)/sys.stderr.write(\1); sys.stderr.flush()/g" $out/${appdir}/emcc.py
34+ ln -s $out/${appdir}/{em++,em-config,emar,emar.py,embuilder.py,emcc,emcc.py,emcmake,emconfigure,emlink.py,emmake,emranlib,emranlib.py,emrun,emscons} $out/bin
36+ echo "EMSCRIPTEN_ROOT = '$out/${appdir}'" > $out/${appdir}/config
37+ echo "LLVM_ROOT = '${emscriptenBackend}/bin'" >> $out/${appdir}/config
38+ echo "PYTHON = '${python}/bin/python'" >> $out/${appdir}/config
39+ echo "NODE_JS = '${nodejs}/bin/node'" >> $out/${appdir}/config
40+ echo "JS_ENGINES = [NODE_JS]" >> $out/${appdir}/config
41+ echo "COMPILER_ENGINE = NODE_JS" >> $out/${appdir}/config
42+ echo "CLOSURE_COMPILER = '${closurecompiler}/share/java/closure-compiler-v${closurecompiler.version}.jar'" >> $out/${appdir}/config
43+ echo "JAVA = '${jre}/bin/java'" >> $out/${appdir}/config
44+ # to make the test(s) below work
45+ echo "SPIDERMONKEY_ENGINE = []" >> $out/${appdir}/config
46+ echo "EMCC_FAST_COMPILER = 0" >> $out/${appdir}/config
48+ + stdenv.lib.optionalString enableWasm ''
49+ echo "BINARYEN_ROOT = '${binaryenVersioned}'" >> $out/share/emscripten/config
53+ echo "--------------- running test -----------------"
54+ # quick hack to get the test working
56+ cp $out/${appdir}/config $HOME/.emscripten
57+ export PATH=$PATH:$out/bin
60+ ${python}/bin/python $src/tests/runner.py test_hello_world
61+ echo "--------------- /running test -----------------"
64+ meta = with stdenv.lib; {
65+ homepage = "https://github.com/emscripten-core/emscripten";
66+ description = "An LLVM-to-JavaScript Compiler";
67+ platforms = platforms.all;
68+ maintainers = with maintainers; [ qknight matthewbauer ];
69+ license = licenses.ncsa;