2022-05-09 14:56:23 +00:00
|
|
|
{ pkgs, lib, emscripten, python3 }:
|
2016-06-12 22:34:50 +00:00
|
|
|
|
|
|
|
{ buildInputs ? [], nativeBuildInputs ? []
|
|
|
|
|
|
|
|
, enableParallelBuilding ? true
|
|
|
|
|
|
|
|
, meta ? {}, ... } @ args:
|
|
|
|
|
|
|
|
pkgs.stdenv.mkDerivation (
|
2019-08-15 12:41:18 +00:00
|
|
|
args //
|
2016-06-12 22:34:50 +00:00
|
|
|
{
|
|
|
|
|
2019-11-24 17:22:28 +00:00
|
|
|
pname = "emscripten-${lib.getName args}";
|
|
|
|
version = lib.getVersion args;
|
2022-05-09 14:56:23 +00:00
|
|
|
buildInputs = [ emscripten python3 ] ++ buildInputs;
|
|
|
|
nativeBuildInputs = [ emscripten python3 ] ++ nativeBuildInputs;
|
2016-06-12 22:34:50 +00:00
|
|
|
|
|
|
|
# fake conftest results with emscripten's python magic
|
|
|
|
EMCONFIGURE_JS=2;
|
|
|
|
|
2022-05-29 20:39:45 +00:00
|
|
|
# removes archive indices
|
|
|
|
dontStrip = args.dontStrip or true;
|
|
|
|
|
2016-06-12 22:34:50 +00:00
|
|
|
configurePhase = args.configurePhase or ''
|
|
|
|
# FIXME: Some tests require writing at $HOME
|
|
|
|
HOME=$TMPDIR
|
|
|
|
runHook preConfigure
|
|
|
|
|
|
|
|
emconfigure ./configure --prefix=$out
|
|
|
|
|
2022-05-09 14:56:23 +00:00
|
|
|
mkdir -p .emscriptencache
|
|
|
|
export EM_CACHE=$(pwd)/.emscriptencache
|
|
|
|
|
2016-06-12 22:34:50 +00:00
|
|
|
runHook postConfigure
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = args.buildPhase or ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
HOME=$TMPDIR
|
2022-05-09 14:56:23 +00:00
|
|
|
|
2016-06-12 22:34:50 +00:00
|
|
|
emmake make
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
2018-03-18 12:34:46 +00:00
|
|
|
doCheck = true;
|
|
|
|
|
2016-06-12 22:34:50 +00:00
|
|
|
checkPhase = args.checkPhase or ''
|
|
|
|
runHook preCheck
|
|
|
|
|
2018-03-18 12:34:46 +00:00
|
|
|
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"
|
|
|
|
echo ""
|
|
|
|
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."
|
|
|
|
echo " -> https://github.com/kripken/emscripten/wiki/Linking"
|
|
|
|
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!"
|
|
|
|
exit 1
|
|
|
|
|
2016-06-12 22:34:50 +00:00
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
})
|