blob: d55338d06fbb02c7bf65a761baf25242146b8d32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/* there is a lot of hideous directory-shuffling bureaucracy here. it
* encompasses all that has been found necessary out in the wild. sourcemod
* plugins following a sane standard project structure is a fairly recent
* development.
*/
{ lib, stdenvNoCC, sourcemod }:
{ scriptingPath ? "scripting"
, includePath ? "scripting/include"
, pluginsPath ? "plugins"
, translationsPath ? "translations"
, gamedataPath ? "gamedata"
, removePrebuilt ? true
, nativeBuildInputs ? []
, ...
}@args:
let
inherit (lib) hasSuffix;
in
assert !hasSuffix "/" scriptingPath;
assert !hasSuffix "/" includePath;
assert !hasSuffix "/" pluginsPath;
assert !hasSuffix "/" translationsPath;
assert !hasSuffix "/" gamedataPath;
stdenvNoCC.mkDerivation ({
inherit
scriptingPath includePath pluginsPath translationsPath gamedataPath
removePrebuilt;
configurePhase = ''
runHook preConfigure
source <(for d in scripting include plugins translations gamedata; do
echo "''${d}Path=$PWD/"\$"''${d}Path"
done)
cd /build
for p in scripting plugins translations gamedata; do
path="$(eval echo \$"''${p}Path")"
[ -d "$path" ] && cp -rT "$path" ./"$p"
done
case "$includePath" in
"$scriptingPath/include") :;;
"$scriptingPath"/*) echo TODO; exit 1;;
*) cp -r "$includePath" ./scripting/include;;
esac
[ -n "''${removePrebuilt:-}" ] && rm -f plugins/*.smx;
mkdir -p scripting/include plugins/disabled translations gamedata
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
cd /build/scripting
[ -d ./include ] && SPCOMPFLAGS="$SPCOMPFLAGS -i ./include"
for plug in *.sp; do
spcomp -o "../plugins/disabled/''${plug%.sp}.smx" "$plug"
done
runHook postBuild
'';
installPhase = ''
runHook preInstall
cd /build
find . -type d -empty -delete
odir=$out/share/addons/sourcemod
mkdir -p $odir
for d in scripting plugins translation gamedata; do
[ -d $d ] && cp -r $d $odir/$d
done
runHook postInstall
'';
} // args // {
nativeBuildInputs = nativeBuildInputs ++ [ sourcemod ];
})
|