1{ pkgs, lib, emscripten, python }:
2
3{ buildInputs ? [], nativeBuildInputs ? []
4
5, enableParallelBuilding ? true
6
7, meta ? {}, ... } @ args:
8
9pkgs.stdenv.mkDerivation (
10 args //
11 {
12
13 name = "emscripten-${args.name}";
14 buildInputs = [ emscripten python ] ++ buildInputs;
15 nativeBuildInputs = [ emscripten python ] ++ nativeBuildInputs;
16
17 # fake conftest results with emscripten's python magic
18 EMCONFIGURE_JS=2;
19
20 configurePhase = args.configurePhase or ''
21 # FIXME: Some tests require writing at $HOME
22 HOME=$TMPDIR
23 runHook preConfigure
24
25 emconfigure ./configure --prefix=$out
26
27 runHook postConfigure
28 '';
29
30 buildPhase = args.buildPhase or ''
31 runHook preBuild
32
33 HOME=$TMPDIR
34 emmake make
35
36 runHook postBuild
37 '';
38
39 doCheck = true;
40
41 checkPhase = args.checkPhase or ''
42 runHook preCheck
43
44 echo "Please provide a test for your emscripten based library/tool, see libxml2 as an exmple on how to use emcc/node to verify your build"
45 echo ""
46 echo "In normal C 'unresolved symbols' would yield an error and a breake of execution. In contrast, in emscripten they are only a warning which is ok given that emscripten assumptions about shared libraries."
47 echo " -> https://github.com/kripken/emscripten/wiki/Linking"
48 echo "So just assume the dependencies were built using hydra, then YOU WILL NEVER see the warning and your code depending on a library will always fail!"
49 exit 1
50
51 runHook postCheck
52 '';
53
54 enableParallelBuilding = args.enableParallelBuilding or true;
55
56 meta = {
57 # Add default meta information
58 platforms = lib.platforms.all;
59 # Do not build this automatically
60 hydraPlatforms = [];
61 } // meta // {
62 # add an extra maintainer to every package
63 maintainers = (meta.maintainers or []) ++
64 [ lib.maintainers.qknight ];
65 };
66})