at 23.05-pre 74 lines 2.0 kB view raw
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 # removes archive indices 22 dontStrip = args.dontStrip or true; 23 24 configurePhase = args.configurePhase or '' 25 # FIXME: Some tests require writing at $HOME 26 HOME=$TMPDIR 27 runHook preConfigure 28 29 emconfigure ./configure --prefix=$out 30 31 mkdir -p .emscriptencache 32 export EM_CACHE=$(pwd)/.emscriptencache 33 34 runHook postConfigure 35 ''; 36 37 buildPhase = args.buildPhase or '' 38 runHook preBuild 39 40 HOME=$TMPDIR 41 42 emmake make 43 44 runHook postBuild 45 ''; 46 47 doCheck = true; 48 49 checkPhase = args.checkPhase or '' 50 runHook preCheck 51 52 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" 53 echo "" 54 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." 55 echo " -> https://github.com/kripken/emscripten/wiki/Linking" 56 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!" 57 exit 1 58 59 runHook postCheck 60 ''; 61 62 enableParallelBuilding = args.enableParallelBuilding or true; 63 64 meta = { 65 # Add default meta information 66 platforms = lib.platforms.all; 67 # Do not build this automatically 68 hydraPlatforms = []; 69 } // meta // { 70 # add an extra maintainer to every package 71 maintainers = (meta.maintainers or []) ++ 72 [ lib.maintainers.qknight ]; 73 }; 74})