This commit is contained in:
Robin Appelman 2023-07-09 17:13:58 +02:00
commit f1707cebd8
9 changed files with 314 additions and 174 deletions

View file

@ -1,30 +1,43 @@
{ lib, stdenv, sourcemod-includes, sourcepawn, which }:
{
lib,
stdenv,
sourcemod-includes,
sourcepawn,
which,
}: {
defaultIncludes ? true,
includes ? [],
src,
outPath ? "",
...
}@args: let
} @ args: let
inherit (lib) optionals;
inherit (builtins) removeAttrs;
allIncludes = includes ++ optionals defaultIncludes [sourcemod-includes];
forwardAttrs = removeAttrs args ["defaultIncludes" "includes" "entrypoint"];
spEnv = sourcepawn.buildEnv allIncludes;
outPathRelative = if outPath == "" then "" else "/${outPath}";
mkdirOut = if outPath == "" then "" else "mkdir -p $out";
in stdenv.mkDerivation (rec {
nativeBuildInputs = [spEnv which];
dontUnpack = true;
buildPhase = ''
# absolute path is needed for spcomp to find the includes
${spEnv}/bin/spcomp ${src} -o out.smx
'';
installPhase = ''
${mkdirOut}
cp out.smx $out${outPathRelative}
'';
testPhase = ''
verifier out.smx
'';
} // args)
outPathRelative =
if outPath == ""
then ""
else "/${outPath}";
mkdirOut =
if outPath == ""
then ""
else "mkdir -p $out";
in
stdenv.mkDerivation (rec {
nativeBuildInputs = [spEnv which];
dontUnpack = true;
buildPhase = ''
# absolute path is needed for spcomp to find the includes
spcomp ${src} -o out.smx
'';
installPhase = ''
${mkdirOut}
cp out.smx $out${outPathRelative}
'';
testPhase = ''
verifier out.smx
'';
}
// args)