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