2020-08-28 19:19:50 +01:00
|
|
|
{ stdenv, fetchFromGitHub, python3, nodejs, closurecompiler
|
|
|
|
, jre, binaryen
|
|
|
|
, llvmPackages_11
|
|
|
|
, symlinkJoin, makeWrapper
|
2020-08-29 10:04:30 +01:00
|
|
|
, mkYarnModules
|
2017-06-04 04:50:51 +01:00
|
|
|
}:
|
2014-07-12 16:17:50 +01:00
|
|
|
|
2020-08-28 19:19:50 +01:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "emscripten";
|
2020-08-29 10:27:42 +01:00
|
|
|
version = "2.0.1";
|
2014-07-12 16:17:50 +01:00
|
|
|
|
2020-08-28 19:19:50 +01:00
|
|
|
llvmEnv = symlinkJoin {
|
|
|
|
name = "emscripten-llvm-${version}";
|
|
|
|
paths = with llvmPackages_11; [ clang-unwrapped lld llvm ];
|
|
|
|
};
|
2014-07-12 16:17:50 +01:00
|
|
|
|
2020-08-29 10:04:30 +01:00
|
|
|
nodeModules = mkYarnModules {
|
|
|
|
name = "emscripten-node-modules-${version}";
|
|
|
|
inherit pname version;
|
2020-08-29 10:35:11 +01:00
|
|
|
# it is vitally important the the package.json has name and version fields
|
2020-08-29 10:04:30 +01:00
|
|
|
packageJSON = ./package.json;
|
|
|
|
yarnLock = ./yarn.lock;
|
|
|
|
yarnNix = ./yarn.nix;
|
|
|
|
};
|
|
|
|
|
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";
|
2020-08-29 10:27:42 +01:00
|
|
|
sha256 = "06dsd819qjv4n2ihrz1mpn5aigmbv0gpkm7iw06wrqx30nzphnpk";
|
2020-08-28 19:19:50 +01:00
|
|
|
rev = version;
|
2014-07-12 16:17:50 +01:00
|
|
|
};
|
|
|
|
|
2020-08-28 19:19:50 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = [ nodejs python3 ];
|
|
|
|
|
|
|
|
outputs = [ "out" "appdir" ];
|
2018-03-18 12:34:46 +00:00
|
|
|
|
2020-08-28 19:19:50 +01:00
|
|
|
buildPhase = ''
|
|
|
|
patchShebangs .
|
2017-01-02 13:26:20 +00:00
|
|
|
# fixes cmake support
|
2020-08-28 19:19:50 +01:00
|
|
|
sed -i -e "s/print \('emcc (Emscript.*\)/sys.stderr.write(\1); sys.stderr.flush()/g" emcc.py
|
2014-07-12 16:17:50 +01:00
|
|
|
|
2020-08-28 19:19:50 +01:00
|
|
|
echo "EMSCRIPTEN_ROOT = '$appdir'" > .emscripten
|
|
|
|
echo "LLVM_ROOT = '${llvmEnv}/bin'" >> .emscripten
|
|
|
|
echo "NODE_JS = '${nodejs}/bin/node'" >> .emscripten
|
|
|
|
echo "JS_ENGINES = [NODE_JS]" >> .emscripten
|
|
|
|
echo "COMPILER_ENGINE = NODE_JS" >> .emscripten
|
|
|
|
echo "CLOSURE_COMPILER = '${closurecompiler}/share/java/closure-compiler-v${closurecompiler.version}.jar'" >> .emscripten
|
|
|
|
echo "JAVA = '${jre}/bin/java'" >> .emscripten
|
2018-03-18 12:34:46 +00:00
|
|
|
# to make the test(s) below work
|
2020-08-28 19:19:50 +01:00
|
|
|
echo "SPIDERMONKEY_ENGINE = []" >> .emscripten
|
|
|
|
echo "BINARYEN_ROOT = '${binaryen}'" >> .emscripten
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
rm -rf cache
|
|
|
|
cp -r . $appdir
|
|
|
|
chmod -R +w $appdir
|
|
|
|
|
|
|
|
mkdir -p $out/bin
|
|
|
|
for b in em++ em-config emar embuilder.py emcc emcmake emconfigure emlink.py emmake emranlib emrun emscons; do
|
|
|
|
makeWrapper $appdir/$b $out/bin/$b \
|
2020-08-29 10:04:30 +01:00
|
|
|
--set NODE_PATH ${nodeModules}/node_modules \
|
2020-08-28 19:19:50 +01:00
|
|
|
--set PYTHON ${python3}/bin/python
|
|
|
|
done
|
|
|
|
'';
|
2018-03-18 12:34:46 +00:00
|
|
|
|
2020-08-28 19:19:50 +01:00
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
#export EMCC_DEBUG=2
|
|
|
|
export PYTHON=${python3}/bin/python
|
|
|
|
export HOME=$TMPDIR
|
|
|
|
python tests/runner.py test_hello_world
|
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; {
|
2020-04-01 02:11:51 +01: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
|
|
|
};
|
|
|
|
}
|