2018-07-21 01:44:44 +01:00
|
|
|
{ emscriptenVersion, stdenv, fetchFromGitHub, emscriptenfastcomp, python, nodejs, closurecompiler
|
|
|
|
, jre, binaryen, enableWasm ? true , cmake
|
2017-06-04 04:50:51 +01:00
|
|
|
}:
|
2014-07-12 16:17:50 +01:00
|
|
|
|
|
|
|
let
|
2018-03-18 12:34:46 +00:00
|
|
|
rev = emscriptenVersion;
|
2015-10-31 06:27:15 +00:00
|
|
|
appdir = "share/emscripten";
|
2018-03-20 14:45:19 +00:00
|
|
|
binaryenVersioned = binaryen.override { emscriptenRev = rev; };
|
2014-07-12 16:17:50 +01:00
|
|
|
in
|
|
|
|
|
2016-05-27 01:05:07 +01:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "emscripten-${rev}";
|
2014-07-12 16:17:50 +01:00
|
|
|
|
2016-05-27 01:05:07 +01:00
|
|
|
src = fetchFromGitHub {
|
2019-02-25 12:13:55 +00:00
|
|
|
owner = "emscripten-core";
|
2016-05-27 01:05:07 +01:00
|
|
|
repo = "emscripten";
|
2019-02-25 12:13:55 +00:00
|
|
|
sha256 = "1j3f0hpy05qskaiyv75l7wv4n0nzxhrh9b296zchx3f6f9h2rghq";
|
2016-05-27 01:05:07 +01:00
|
|
|
inherit rev;
|
2014-07-12 16:17:50 +01:00
|
|
|
};
|
|
|
|
|
2018-03-18 12:34:46 +00:00
|
|
|
buildInputs = [ nodejs cmake python ];
|
|
|
|
|
2016-05-27 01:05:07 +01:00
|
|
|
buildCommand = ''
|
2015-10-31 06:27:15 +00:00
|
|
|
mkdir -p $out/${appdir}
|
|
|
|
cp -r $src/* $out/${appdir}
|
|
|
|
chmod -R +w $out/${appdir}
|
|
|
|
grep -rl '^#!/usr.*python' $out/${appdir} | xargs sed -i -s 's@^#!/usr.*python.*@#!${python}/bin/python@'
|
|
|
|
sed -i -e "s,EM_CONFIG = '~/.emscripten',EM_CONFIG = '$out/${appdir}/config'," $out/${appdir}/tools/shared.py
|
|
|
|
sed -i -e 's,^.*did not see a source tree above the LLVM.*$, return True,' $out/${appdir}/tools/shared.py
|
|
|
|
sed -i -e 's,def check_sanity(force=False):,def check_sanity(force=False):\n return,' $out/${appdir}/tools/shared.py
|
2017-01-02 13:26:20 +00:00
|
|
|
# fixes cmake support
|
|
|
|
sed -i -e "s/print \('emcc (Emscript.*\)/sys.stderr.write(\1); sys.stderr.flush()/g" $out/${appdir}/emcc.py
|
2015-10-31 06:27:15 +00:00
|
|
|
mkdir $out/bin
|
|
|
|
ln -s $out/${appdir}/{em++,em-config,emar,embuilder.py,emcc,emcmake,emconfigure,emlink.py,emmake,emranlib,emrun,emscons} $out/bin
|
2014-07-12 16:17:50 +01:00
|
|
|
|
2015-10-31 06:27:15 +00:00
|
|
|
echo "EMSCRIPTEN_ROOT = '$out/${appdir}'" > $out/${appdir}/config
|
2016-12-31 18:13:02 +00:00
|
|
|
echo "LLVM_ROOT = '${emscriptenfastcomp}/bin'" >> $out/${appdir}/config
|
2015-10-31 06:27:15 +00:00
|
|
|
echo "PYTHON = '${python}/bin/python'" >> $out/${appdir}/config
|
|
|
|
echo "NODE_JS = '${nodejs}/bin/node'" >> $out/${appdir}/config
|
|
|
|
echo "JS_ENGINES = [NODE_JS]" >> $out/${appdir}/config
|
|
|
|
echo "COMPILER_ENGINE = NODE_JS" >> $out/${appdir}/config
|
2017-04-28 17:54:34 +01:00
|
|
|
echo "CLOSURE_COMPILER = '${closurecompiler}/share/java/closure-compiler-v${closurecompiler.version}.jar'" >> $out/${appdir}/config
|
2015-10-31 06:27:15 +00:00
|
|
|
echo "JAVA = '${jre}/bin/java'" >> $out/${appdir}/config
|
2018-03-18 12:34:46 +00:00
|
|
|
# to make the test(s) below work
|
|
|
|
echo "SPIDERMONKEY_ENGINE = []" >> $out/${appdir}/config
|
2017-06-04 04:50:51 +01:00
|
|
|
''
|
|
|
|
+ stdenv.lib.optionalString enableWasm ''
|
2018-03-20 14:45:19 +00:00
|
|
|
echo "BINARYEN_ROOT = '${binaryenVersioned}'" >> $out/share/emscripten/config
|
2018-03-18 12:34:46 +00:00
|
|
|
''
|
|
|
|
+
|
|
|
|
''
|
|
|
|
echo "--------------- running test -----------------"
|
|
|
|
# quick hack to get the test working
|
|
|
|
HOME=$TMPDIR
|
|
|
|
cp $out/${appdir}/config $HOME/.emscripten
|
|
|
|
export PATH=$PATH:$out/bin
|
|
|
|
|
|
|
|
#export EMCC_DEBUG=2
|
|
|
|
${python}/bin/python $src/tests/runner.py test_hello_world
|
|
|
|
echo "--------------- /running test -----------------"
|
2014-07-12 16:17:50 +01:00
|
|
|
'';
|
2016-05-27 01:05:13 +01:00
|
|
|
|
2014-07-12 16:17:50 +01:00
|
|
|
meta = with stdenv.lib; {
|
2019-02-25 12:13:55 +00:00
|
|
|
homepage = https://github.com/emscripten-core/emscripten;
|
2014-07-12 16:17:50 +01:00
|
|
|
description = "An LLVM-to-JavaScript Compiler";
|
2015-11-21 12:33:22 +00:00
|
|
|
platforms = platforms.all;
|
2016-05-27 14:44:29 +01:00
|
|
|
maintainers = with maintainers; [ qknight matthewbauer ];
|
2015-05-28 18:20:29 +01:00
|
|
|
license = licenses.ncsa;
|
2014-07-12 16:17:50 +01:00
|
|
|
};
|
|
|
|
}
|