Merge pull request #16208 from qknight/emscripten_toolchain

emscripten toolchain *katsching*
This commit is contained in:
Joachim Schiele 2016-07-04 12:04:03 +02:00 committed by GitHub
commit 4c4a63f55d
3 changed files with 171 additions and 0 deletions

View File

@ -0,0 +1,59 @@
{ pkgs, lib, emscripten }:
{ buildInputs ? [], nativeBuildInputs ? []
, enableParallelBuilding ? true
, meta ? {}, ... } @ args:
pkgs.stdenv.mkDerivation (
args //
{
name = "emscripten-${args.name}";
buildInputs = [ emscripten ] ++ buildInputs;
nativeBuildInputs = [ emscripten ] ++ nativeBuildInputs;
# fake conftest results with emscripten's python magic
EMCONFIGURE_JS=2;
configurePhase = args.configurePhase or ''
# FIXME: Some tests require writing at $HOME
HOME=$TMPDIR
runHook preConfigure
# probably requires autotools as dependency
./autogen.sh
emconfigure ./configure --prefix=$out
runHook postConfigure
'';
buildPhase = args.buildPhase or ''
runHook preBuild
HOME=$TMPDIR
emmake make
runHook postBuild
'';
checkPhase = args.checkPhase or ''
runHook preCheck
runHook postCheck
'';
enableParallelBuilding = args.enableParallelBuilding or true;
meta = {
# Add default meta information
platforms = lib.platforms.all;
# Do not build this automatically
hydraPlatforms = [];
} // meta // {
# add an extra maintainer to every package
maintainers = (meta.maintainers or []) ++
[ lib.maintainers.qknight ];
};
})

View File

@ -1402,10 +1402,19 @@ in
eid-viewer = callPackage ../tools/security/eid-viewer { };
### DEVELOPMENT / EMSCRIPTEN
buildEmscriptenPackage = callPackage ../development/em-modules/generic { };
emscripten = callPackage ../development/compilers/emscripten { };
emscriptenfastcomp = callPackage ../development/compilers/emscripten-fastcomp { };
emscriptenPackages = recurseIntoAttrs (callPackage ./emscripten-packages.nix { });
emscriptenStdenv = stdenv // { mkDerivation = buildEmscriptenPackage; };
efibootmgr = callPackage ../tools/system/efibootmgr { };
efivar = callPackage ../tools/system/efivar { };

View File

@ -0,0 +1,103 @@
{ pkgs }:
# emscripten toolchain abstraction for nix
# https://github.com/NixOS/nixpkgs/pull/16208
with pkgs; rec {
json_c = pkgs.json_c.override {
stdenv = emscriptenStdenv;
};
libxml2 = (pkgs.libxml2.override {
stdenv = emscriptenStdenv;
supportPython = false;
}).overrideDerivation
(old: {
buildInputs = old.buildInputs ++ [ autoreconfHook pkgconfig zlib nodejs ];
nativeBuildInputs = old.nativeBuildInputs ++ [ zlib pkgconfig ];
# just override it with nothing so it does not fail
autoreconfPhase = "echo autoreconfPhase not used...";
checkPhase = ''
echo "================= testing xmllint using node ================="
emcc -O2 -s EMULATE_FUNCTION_POINTER_CASTS=1 xmllint.o \
./.libs/libxml2.a `pkg-config zlib --cflags` `pkg-config zlib --libs` -o ./xmllint.test.js \
--embed-file ./test/xmlid/id_err1.xml
# test/xmlid/id_err2.xml:3: validity error : xml:id : attribute type should be ID
# <!ATTLIST foo xml:id CDATA #IMPLIED>
# ^
node ./xmllint.test.js --noout test/xmlid/id_err1.xml 2>&1 | grep 0bar
if [ $? -ne 0 ]; then
echo "xmllint unit test failed, please fix this package"
exit 1;
else
echo "since there is no stupid text containing 'foo xml:id' it seems to work! very good."
fi
echo "================= /testing xmllint using node ================="
'';
});
xmlmirror = buildEmscriptenPackage rec {
name = "xmlmirror";
buildInputs = [ autoconf automake libtool pkgconfig gnumake libxml2 nodejs
python openjdk json_c zlib ];
src = fetchgit {
url = "https://gitlab.com/odfplugfest/xmlmirror.git";
rev = "4fd7e86f7c9526b8f4c1733e5c8b45175860a8fd";
sha256 = "1jasdqnbdnb83wbcnyrp32f36w3xwhwp0wq8lwwmhqagxrij1r4b";
};
configurePhase = ''
rm -f fastXmlLint.js*
'';
buildPhase = ''
HOME=$TMPDIR
make -f Makefile.emEnv
'';
outputs = [ "out" "doc" ];
installPhase = ''
mkdir -p $out/share
mkdir -p $doc
cp Demo* $out/share
cp -R codemirror-5.12 $out/share
cp fastXmlLint.js* $out/share
cp *.xsd $out/share
cp *.js $out/share
cp *.xhtml $out/share
cp *.html $out/share
cp *.json $out/share
cp *.rng $out/share
cp README.md $doc/
'';
postInstall = ''
'';
};
zlib = (pkgs.zlib.override {
stdenv = emscriptenStdenv;
}).overrideDerivation
(old: {
configurePhase = ''
# FIXME: Some tests require writing at $HOME
HOME=$TMPDIR
runHook preConfigure
emconfigure ./configure --prefix=$out
runHook postConfigure
'';
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace configure \
--replace '/usr/bin/libtool' 'ar' \
--replace 'AR="libtool"' 'AR="ar"' \
--replace 'ARFLAGS="-o"' 'ARFLAGS="-r"'
'';
});
}