2021-01-19 07:50:56 +01:00
|
|
|
{ stdenv, lib, makeWrapper, pkg-config, mono, dotnetbuildhelpers }:
|
2015-05-22 15:25:02 +02:00
|
|
|
|
|
|
|
attrsOrig @
|
2021-11-08 17:12:26 +01:00
|
|
|
{ pname
|
2015-05-22 15:25:02 +02:00
|
|
|
, version
|
2021-11-11 20:35:43 +01:00
|
|
|
, nativeBuildInputs ? []
|
2015-05-22 15:25:02 +02:00
|
|
|
, xBuildFiles ? [ ]
|
|
|
|
, xBuildFlags ? [ "/p:Configuration=Release" ]
|
|
|
|
, outputFiles ? [ "bin/Release/*" ]
|
|
|
|
, dllFiles ? [ "*.dll" ]
|
|
|
|
, exeFiles ? [ "*.exe" ]
|
2015-10-29 03:54:31 +01:00
|
|
|
# Additional arguments to pass to the makeWrapper function, which wraps
|
|
|
|
# generated binaries.
|
|
|
|
, makeWrapperArgs ? [ ]
|
2015-05-22 15:25:02 +02:00
|
|
|
, ... }:
|
|
|
|
let
|
|
|
|
arrayToShell = (a: toString (map (lib.escape (lib.stringToCharacters "\\ ';$`()|<>\t") ) a));
|
|
|
|
|
|
|
|
attrs = {
|
2021-11-08 17:12:26 +01:00
|
|
|
inherit pname version;
|
2015-05-22 15:25:02 +02:00
|
|
|
|
2021-11-11 20:35:43 +01:00
|
|
|
nativeBuildInputs = [
|
|
|
|
pkg-config
|
2015-05-22 15:25:02 +02:00
|
|
|
makeWrapper
|
2021-11-11 21:23:40 +01:00
|
|
|
dotnetbuildhelpers
|
|
|
|
mono
|
|
|
|
] ++ nativeBuildInputs;
|
2015-05-22 15:25:02 +02:00
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
|
|
|
|
2019-10-31 17:50:15 +01:00
|
|
|
[ -z "''${dontPlacateNuget-}" ] && placate-nuget.sh
|
|
|
|
[ -z "''${dontPlacatePaket-}" ] && placate-paket.sh
|
|
|
|
[ -z "''${dontPatchFSharpTargets-}" ] && patch-fsharp-targets.sh
|
2015-05-22 15:25:02 +02:00
|
|
|
|
|
|
|
runHook postConfigure
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
echo Building dotNET packages...
|
|
|
|
|
|
|
|
# Probably needs to be moved to fsharp
|
|
|
|
if pkg-config FSharp.Core
|
|
|
|
then
|
|
|
|
export FSharpTargetsPath="$(dirname $(pkg-config FSharp.Core --variable=Libraries))/Microsoft.FSharp.Targets"
|
|
|
|
fi
|
|
|
|
|
|
|
|
ran=""
|
|
|
|
for xBuildFile in ${arrayToShell xBuildFiles} ''${xBuildFilesExtra}
|
|
|
|
do
|
|
|
|
ran="yes"
|
|
|
|
xbuild ${arrayToShell xBuildFlags} ''${xBuildFlagsArray} $xBuildFile
|
|
|
|
done
|
|
|
|
|
|
|
|
[ -z "$ran" ] && xbuild ${arrayToShell xBuildFlags} ''${xBuildFlagsArray}
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2021-11-08 17:12:26 +01:00
|
|
|
target="$out/lib/dotnet/${pname}"
|
2015-05-22 15:25:02 +02:00
|
|
|
mkdir -p "$target"
|
|
|
|
|
|
|
|
cp -rv ${arrayToShell outputFiles} "''${outputFilesArray[@]}" "$target"
|
|
|
|
|
2019-10-31 17:50:15 +01:00
|
|
|
if [ -z "''${dontRemoveDuplicatedDlls-}" ]
|
2015-05-22 15:25:02 +02:00
|
|
|
then
|
|
|
|
pushd "$out"
|
|
|
|
remove-duplicated-dlls.sh
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -f
|
|
|
|
for dllPattern in ${arrayToShell dllFiles} ''${dllFilesArray[@]}
|
|
|
|
do
|
|
|
|
set +f
|
|
|
|
for dll in "$target"/$dllPattern
|
|
|
|
do
|
|
|
|
[ -f "$dll" ] || continue
|
|
|
|
if pkg-config $(basename -s .dll "$dll")
|
|
|
|
then
|
|
|
|
echo "$dll already exported by a buildInputs, not re-exporting"
|
|
|
|
else
|
2021-11-11 21:23:40 +01:00
|
|
|
create-pkg-config-for-dll.sh "$out/lib/pkgconfig" "$dll"
|
2015-05-22 15:25:02 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
set -f
|
|
|
|
for exePattern in ${arrayToShell exeFiles} ''${exeFilesArray[@]}
|
|
|
|
do
|
|
|
|
set +f
|
|
|
|
for exe in "$target"/$exePattern
|
|
|
|
do
|
|
|
|
[ -f "$exe" ] || continue
|
|
|
|
mkdir -p "$out"/bin
|
|
|
|
commandName="$(basename -s .exe "$(echo "$exe" | tr "[A-Z]" "[a-z]")")"
|
2015-10-29 03:54:31 +01:00
|
|
|
makeWrapper \
|
2017-03-27 17:23:49 +02:00
|
|
|
"${mono}/bin/mono" \
|
2015-10-29 03:54:31 +01:00
|
|
|
"$out"/bin/"$commandName" \
|
2017-03-27 17:23:49 +02:00
|
|
|
--add-flags "\"$exe\"" \
|
2015-10-29 03:54:31 +01:00
|
|
|
''${makeWrapperArgs}
|
2015-05-22 15:25:02 +02:00
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
2021-11-11 21:23:40 +01:00
|
|
|
stdenv.mkDerivation (attrs // (builtins.removeAttrs attrsOrig [ "nativeBuildInputs" ] ))
|