nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ pkgs, lib, emscripten, python3 }:
2
3{ buildInputs ? [], nativeBuildInputs ? []
4
5, enableParallelBuilding ? true
6
7, meta ? {}, ... } @ args:
8
9pkgs.stdenv.mkDerivation (
10 args //
11 {
12
13 pname = "emscripten-${lib.getName args}";
14 version = lib.getVersion args;
15 buildInputs = [ emscripten python3 ] ++ buildInputs;
16 nativeBuildInputs = [ emscripten python3 ] ++ nativeBuildInputs;
17
18 # fake conftest results with emscripten's python magic
19 EMCONFIGURE_JS=2;
20
21 configurePhase = args.configurePhase or ''
22 # FIXME: Some tests require writing at $HOME
23 HOME=$TMPDIR
24 runHook preConfigure
25
26 emconfigure ./configure --prefix=$out
27
28 mkdir -p .emscriptencache
29 export EM_CACHE=$(pwd)/.emscriptencache
30
31 runHook postConfigure
32 '';
33
34 buildPhase = args.buildPhase or ''
35 runHook preBuild
36
37 HOME=$TMPDIR
38
39 emmake make
40
41 runHook postBuild
42 '';
43
44 doCheck = true;
45
46 checkPhase = args.checkPhase or ''
47 runHook preCheck
48
49 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"
50 echo ""
51 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."
52 echo " -> https://github.com/kripken/emscripten/wiki/Linking"
53 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!"
54 exit 1
55
56 runHook postCheck
57 '';
58
59 enableParallelBuilding = args.enableParallelBuilding or true;
60
61 meta = {
62 # Add default meta information
63 platforms = lib.platforms.all;
64 # Do not build this automatically
65 hydraPlatforms = [];
66 } // meta // {
67 # add an extra maintainer to every package
68 maintainers = (meta.maintainers or []) ++
69 [ lib.maintainers.qknight ];
70 };
71})