From 10981178a966f0d8bfc77a680921d85e5497e453 Mon Sep 17 00:00:00 2001 From: Boris Sukholitko Date: Sat, 12 Jul 2014 18:17:50 +0300 Subject: [PATCH] Add emscripten: LLVM to JavaScript compiler --- .../compilers/emscripten-fastcomp/default.nix | 42 +++++++++++++++++++ .../compilers/emscripten/default.nix | 40 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 ++ 3 files changed, 86 insertions(+) create mode 100644 pkgs/development/compilers/emscripten-fastcomp/default.nix create mode 100644 pkgs/development/compilers/emscripten/default.nix diff --git a/pkgs/development/compilers/emscripten-fastcomp/default.nix b/pkgs/development/compilers/emscripten-fastcomp/default.nix new file mode 100644 index 000000000000..3eb9aef528c0 --- /dev/null +++ b/pkgs/development/compilers/emscripten-fastcomp/default.nix @@ -0,0 +1,42 @@ +{ stdenv, fetchgit, python }: + +let + tag = "1.21.0"; +in + +stdenv.mkDerivation rec { + name = "emscripten-fastcomp-${tag}"; + + srcFC = fetchgit { + url = git://github.com/kripken/emscripten-fastcomp; + rev = "refs/tags/${tag}"; + sha256 = "0mcxzg2cfg0s1vfm3bh1ar4xsddb6xkv1dsdbgnpx38lbj1mvfs1"; + }; + + srcFL = fetchgit { + url = git://github.com/kripken/emscripten-fastcomp-clang; + rev = "refs/tags/${tag}"; + sha256 = "0s2jcn36d236cfpryjpgaazjp3cg83d0h78g6kk1j6vdppv3vgnp"; + }; + + buildInputs = [ python ]; + buildCommand = '' + cp -as ${srcFC} $TMPDIR/src + chmod +w $TMPDIR/src/tools + cp -as ${srcFL} $TMPDIR/src/tools/clang + + chmod +w $TMPDIR/src + mkdir $TMPDIR/src/build + cd $TMPDIR/src/build + + ../configure --enable-optimized --disable-assertions --enable-targets=host,js + make + cp -a Release/bin $out + ''; + meta = with stdenv.lib; { + homepage = https://github.com/kripken/emscripten-fastcomp; + description = "emscripten llvm"; + maintainers = with maintainers; [ bosu ]; + license = "University of Illinois/NCSA Open Source License"; + }; +} diff --git a/pkgs/development/compilers/emscripten/default.nix b/pkgs/development/compilers/emscripten/default.nix new file mode 100644 index 000000000000..dc81b90b4b90 --- /dev/null +++ b/pkgs/development/compilers/emscripten/default.nix @@ -0,0 +1,40 @@ +{ stdenv, fetchgit, emscriptenfastcomp, python, nodejs, closurecompiler, jre }: + +let + tag = "1.21.0"; +in + +stdenv.mkDerivation rec { + name = "emscripten-${tag}"; + + src = fetchgit { + url = git://github.com/kripken/emscripten; + rev = "refs/tags/${tag}"; + sha256 = "0y17ab4nhd3521b50sv2i2667w0rlcnmlkpkgw5j3fsh8awxgf32"; + }; + + buildCommand = '' + mkdir $out + cp -a $src $out/bin + chmod -R +w $out/bin + grep -rl '^#!/usr.*python' $out/bin | xargs sed -i -s 's@^#!/usr.*python.*@#!${python}/bin/python@' + sed -i -e "s,EM_CONFIG = '~/.emscripten',EM_CONFIG = '$out/config'," $out/bin/tools/shared.py + sed -i -e 's,^.*did not see a source tree above the LLVM.*$, return True,' $out/bin/tools/shared.py + sed -i -e 's,def check_sanity(force=False):,def check_sanity(force=False):\n return,' $out/bin/tools/shared.py + + echo "EMSCRIPTEN_ROOT = '$out/bin'" > $out/config + echo "LLVM_ROOT = '${emscriptenfastcomp}'" >> $out/config + echo "PYTHON = '${python}/bin/python'" >> $out/config + echo "NODE_JS = '${nodejs}/bin/node'" >> $out/config + echo "JS_ENGINES = [NODE_JS]" >> $out/config + echo "COMPILER_ENGINE = NODE_JS" >> $out/config + echo "CLOSURE_COMPILER = '${closurecompiler}/bin/closure-compiler'" >> $out/config + echo "JAVA = '${jre}/bin/java'" >> $out/config + ''; + meta = with stdenv.lib; { + homepage = https://github.com/kripken/emscripten; + description = "An LLVM-to-JavaScript Compiler"; + maintainers = with maintainers; [ bosu ]; + license = "MIT and University of Illinois/NCSA Open Source License"; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 450b28bd85e5..a8cf37220086 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -957,6 +957,10 @@ let edk2 = callPackage ../development/compilers/edk2 { }; + emscripten = callPackage ../development/compilers/emscripten { }; + + emscriptenfastcomp = callPackage ../development/compilers/emscripten-fastcomp { }; + efibootmgr = callPackage ../tools/system/efibootmgr { }; elasticsearch = callPackage ../servers/search/elasticsearch { };