3
0
Fork 0
forked from mirrors/nixpkgs

emscripten: 1.39.1 -> 2.0.0

This commit is contained in:
Gabriel Ebner 2020-08-28 20:19:50 +02:00
parent 40fafd53b1
commit 2d39da2084
4 changed files with 53 additions and 137 deletions

View file

@ -1,63 +1,66 @@
{ emscriptenVersion, stdenv, fetchFromGitHub, emscriptenfastcomp, python, nodejs, closurecompiler
, jre, binaryen, enableWasm ? true , cmake
{ stdenv, fetchFromGitHub, python3, nodejs, closurecompiler
, jre, binaryen
, llvmPackages_11
, symlinkJoin, makeWrapper
}:
let
rev = emscriptenVersion;
appdir = "share/emscripten";
binaryenVersioned = binaryen.override { emscriptenRev = rev; };
in
stdenv.mkDerivation rec {
pname = "emscripten";
# 2.0.1 requires unreleased binaryen version (as of 2020-08-28)
version = "2.0.0";
stdenv.mkDerivation {
name = "emscripten-${rev}";
llvmEnv = symlinkJoin {
name = "emscripten-llvm-${version}";
paths = with llvmPackages_11; [ clang-unwrapped lld llvm ];
};
src = fetchFromGitHub {
owner = "emscripten-core";
repo = "emscripten";
sha256 = "1j3f0hpy05qskaiyv75l7wv4n0nzxhrh9b296zchx3f6f9h2rghq";
inherit rev;
sha256 = "1ihr1v8dlq5xq97i59n7s1hhz5pkafi6556ppgzjmmhiiraz2mkh";
rev = version;
};
buildInputs = [ nodejs cmake python ];
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ nodejs python3 ];
buildCommand = ''
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
outputs = [ "out" "appdir" ];
buildPhase = ''
patchShebangs .
# fixes cmake support
sed -i -e "s/print \('emcc (Emscript.*\)/sys.stderr.write(\1); sys.stderr.flush()/g" $out/${appdir}/emcc.py
mkdir $out/bin
ln -s $out/${appdir}/{em++,em-config,emar,embuilder.py,emcc,emcmake,emconfigure,emlink.py,emmake,emranlib,emrun,emscons} $out/bin
sed -i -e "s/print \('emcc (Emscript.*\)/sys.stderr.write(\1); sys.stderr.flush()/g" emcc.py
echo "EMSCRIPTEN_ROOT = '$out/${appdir}'" > $out/${appdir}/config
echo "LLVM_ROOT = '${emscriptenfastcomp}/bin'" >> $out/${appdir}/config
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
echo "CLOSURE_COMPILER = '${closurecompiler}/share/java/closure-compiler-v${closurecompiler.version}.jar'" >> $out/${appdir}/config
echo "JAVA = '${jre}/bin/java'" >> $out/${appdir}/config
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
# to make the test(s) below work
echo "SPIDERMONKEY_ENGINE = []" >> $out/${appdir}/config
''
+ stdenv.lib.optionalString enableWasm ''
echo "BINARYEN_ROOT = '${binaryenVersioned}'" >> $out/share/emscripten/config
''
+
''
echo "--------------- running test -----------------"
# quick hack to get the test working
HOME=$TMPDIR
cp $out/${appdir}/config $HOME/.emscripten
export PATH=$PATH:$out/bin
echo "SPIDERMONKEY_ENGINE = []" >> .emscripten
echo "BINARYEN_ROOT = '${binaryen}'" >> .emscripten
'';
#export EMCC_DEBUG=2
${python}/bin/python $src/tests/runner.py test_hello_world
echo "--------------- /running test -----------------"
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 \
--set PYTHON ${python3}/bin/python
done
'';
doCheck = true;
checkPhase = ''
#export EMCC_DEBUG=2
export PYTHON=${python3}/bin/python
export HOME=$TMPDIR
python tests/runner.py test_hello_world
'';
meta = with stdenv.lib; {

View file

@ -1,28 +0,0 @@
{ newScope, stdenv, binutils, wrapCCWith, symlinkJoin }:
let
callPackage = newScope (self // {inherit stdenv;});
self = {
emscriptenfastcomp-unwrapped = callPackage ./emscripten-fastcomp.nix {};
emscriptenfastcomp-wrapped = wrapCCWith {
cc = self.emscriptenfastcomp-unwrapped;
# Never want Apple's cctools for WASM target
bintools = binutils;
libc = stdenv.cc.libc;
extraBuildCommands = ''
# hardening flags break WASM support
cat > $out/nix-support/add-hardening.sh
'';
};
emscriptenfastcomp = symlinkJoin {
name = "emscriptenfastcomp-${stdenv.lib.getVersion self.emscriptenfastcomp-unwrapped}";
paths = [ self.emscriptenfastcomp-wrapped self.emscriptenfastcomp-unwrapped ];
preferLocalBuild = false;
allowSubstitutes = true;
postBuild = ''
# replace unwrapped clang-3.9 binary by wrapper
ln -sf $out/bin/clang $out/bin/clang-[0-9]*
'';
};
};
in self

View file

@ -1,53 +0,0 @@
{ emscriptenVersion, stdenv, fetchFromGitHub, cmake, python, gtest, gccForLibs, ... }:
let
rev = emscriptenVersion;
in
stdenv.mkDerivation rec {
name = "emscripten-fastcomp-${rev}";
src = fetchFromGitHub {
owner = "emscripten-core";
repo = "emscripten-fastcomp";
sha256 = "0bd0l5k2fa4k0nax2cpxi003pqffqivx4z4m2j5xdha1a12sid8i";
inherit rev;
};
srcFL = fetchFromGitHub {
owner = "emscripten-core";
repo = "emscripten-fastcomp-clang";
sha256 = "1iw2qplhp489qzw0rma73sab7asnm27g4m95sr36c6kq9cq6agri";
inherit rev;
};
nativeBuildInputs = [ cmake python gtest ];
preConfigure = ''
cp -Lr ${srcFL} tools/clang
chmod +w -R tools/clang
'';
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DLLVM_TARGETS_TO_BUILD='X86;JSBackend'"
"-DLLVM_INCLUDE_EXAMPLES=OFF"
"-DLLVM_INCLUDE_TESTS=ON"
#"-DLLVM_CONFIG=${llvm}/bin/llvm-config"
"-DLLVM_BUILD_TESTS=ON"
"-DCLANG_INCLUDE_TESTS=ON"
] ++ (stdenv.lib.optional stdenv.isLinux
# necessary for clang to find crtend.o
"-DGCC_INSTALL_PREFIX=${gccForLibs}"
);
enableParallelBuilding = true;
passthru = {
isClang = true;
};
meta = with stdenv.lib; {
homepage = "https://github.com/emscripten-core/emscripten-fastcomp";
description = "Emscripten LLVM";
platforms = platforms.all;
maintainers = with maintainers; [ qknight matthewbauer ];
license = stdenv.lib.licenses.ncsa;
};
}

View file

@ -3369,14 +3369,8 @@ in
cholmod-extra = callPackage ../development/libraries/science/math/cholmod-extra { };
emscriptenVersion = "1.39.1";
emscripten = callPackage ../development/compilers/emscripten { };
emscriptenfastcompPackages = dontRecurseIntoAttrs (callPackage ../development/compilers/emscripten/fastcomp { });
emscriptenfastcomp = emscriptenfastcompPackages.emscriptenfastcomp;
emscriptenPackages = recurseIntoAttrs (callPackage ./emscripten-packages.nix { });
emscriptenStdenv = stdenv // { mkDerivation = buildEmscriptenPackage; };
@ -4583,7 +4577,7 @@ in
isync = callPackage ../tools/networking/isync { };
itm-tools = callPackage ../development/tools/misc/itm-tools { };
itm-tools = callPackage ../development/tools/misc/itm-tools { };
ix = callPackage ../tools/misc/ix { };
@ -4888,7 +4882,7 @@ in
asciidoc = asciidoc-full;
imagemagick = imagemagick7Big;
};
kristall = libsForQt5.callPackage ../applications/networking/browsers/kristall { };
kzipmix = pkgsi686Linux.callPackage ../tools/compression/kzipmix { };
@ -20980,7 +20974,7 @@ in
i3-wk-switch = callPackage ../applications/window-managers/i3/wk-switch.nix { };
windowchef = callPackage ../applications/window-managers/windowchef/default.nix { };
wmfocus = callPackage ../applications/window-managers/i3/wmfocus.nix { };
wmfs = callPackage ../applications/window-managers/wmfs/default.nix { };
@ -27533,7 +27527,7 @@ in
sequeler = callPackage ../applications/misc/sequeler { };
sequelpro = callPackage ../applications/misc/sequelpro {};
snowsql = callPackage ../applications/misc/snowsql {};
sidequest = callPackage ../applications/misc/sidequest {};