nixpkgs/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
= f0af1ef49c buildDotnetModule: properly inherit arguments from drv
Previously buildDotnetModule did not properly inherit some arguments from
derivations, take for example this expression:

dotnetFlags = [
    "--runtime linux-x64"
];

It would error out as follows: "MSBUILD : error MSB1001: Unknown switch.".
Setting the same flag from bash would work fine. This fixes that, all
arguments should now be properly interpreted :)
2022-04-30 18:24:48 -07:00

43 lines
1.3 KiB
Bash

# Inherit arguments from the derivation
makeWrapperArgs=( ${makeWrapperArgs-} )
# First argument is the executable you want to wrap,
# the second is the destination for the wrapper.
wrapDotnetProgram() {
makeWrapper "$1" "$2" \
--set "DOTNET_ROOT" "@dotnetRuntime@" \
--suffix "LD_LIBRARY_PATH" : "@runtimeDeps@" \
"${gappsWrapperArgs[@]}" \
"${makeWrapperArgs[@]}"
echo "Installed wrapper to: "$2""
}
dotnetFixupHook() {
echo "Executing dotnetFixupPhase"
if [ "${executables}" ]; then
for executable in ${executables[@]}; do
execPath="$out/lib/${pname}/$executable"
if [[ -f "$execPath" && -x "$execPath" ]]; then
wrapDotnetProgram "$execPath" "$out/bin/$(basename "$executable")"
else
echo "Specified binary \"$executable\" is either not an executable, or does not exist!"
exit 1
fi
done
else
for executable in $out/lib/${pname}/*; do
if [[ -f "$executable" && -x "$executable" && "$executable" != *"dll"* ]]; then
wrapDotnetProgram "$executable" "$out/bin/$(basename "$executable")"
fi
done
fi
echo "Finished dotnetFixupPhase"
}
if [[ -z "${dontDotnetFixup-}" ]]; then
preFixupPhases+=" dotnetFixupHook"
fi