on e94de40 help sign in
71 lines 3.0 kB history raw
1{ emscriptenVersion, stdenv, fetchFromGitHub, emscriptenfastcomp, python, nodejs, closurecompiler
2, jre, binaryen, enableWasm ? true , cmake, emscriptenBackend ? emscriptenfastcomp
3}:
5let
6 rev = emscriptenVersion;
7 appdir = "share/emscripten";
8 binaryenVersioned = binaryen;
9in
11stdenv.mkDerivation {
12 name = "emscripten-${rev}";
14 src = fetchFromGitHub {
15 owner = "emscripten-core";
16 repo = "emscripten";
17 sha256 = "10f2mlwh4s6v3rqghb7zdmv4ry0a4si915x4v17vp4nv7swkkwhn";
18 rev = "fc6a4bb97b421b6dcf5806d0dc42ab8ddd4da026";
19 };
21 buildInputs = [ nodejs cmake python ];
23 buildCommand = ''
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
33 mkdir $out/bin
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
47 ''
48 + stdenv.lib.optionalString enableWasm ''
49 echo "BINARYEN_ROOT = '${binaryenVersioned}'" >> $out/share/emscripten/config
50 ''
51 +
52 ''
53 echo "--------------- running test -----------------"
54 # quick hack to get the test working
55 HOME=$TMPDIR
56 cp $out/${appdir}/config $HOME/.emscripten
57 export PATH=$PATH:$out/bin
59 #export EMCC_DEBUG=2
60 ${python}/bin/python $src/tests/runner.py test_hello_world
61 echo "--------------- /running test -----------------"
62 '';
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;
70 };