dotnetenv.{buildSolution,buildWrapper}: follow editorconfig & follow common bash style

There seems to be duplication and also improvements to one between these, so someone
should rework these.

Add missing `pre` and `post` hook runs.
This commit is contained in:
Artturin 2024-09-12 20:18:12 +03:00
parent 280db3deca
commit a4e4fc5d35
2 changed files with 39 additions and 46 deletions

View File

@ -31,41 +31,37 @@ stdenv.mkDerivation {
'';
installPhase = ''
addDeps()
{
if [ -f $1/nix-support/dotnet-assemblies ]
then
for i in $(cat $1/nix-support/dotnet-assemblies)
do
windowsPath=$(cygpath --windows $i)
assemblySearchPaths="$assemblySearchPaths;$windowsPath"
runHook preInstall
addDeps $i
done
fi
addDeps() {
if [ -f $1/nix-support/dotnet-assemblies ]; then
for i in $(cat $1/nix-support/dotnet-assemblies); do
windowsPath=$(cygpath --windows $i)
assemblySearchPaths="$assemblySearchPaths;$windowsPath"
addDeps $i
done
fi
}
for i in ${toString assemblyInputs}
do
windowsPath=$(cygpath --windows $i)
echo "Using assembly path: $windowsPath"
for i in ${toString assemblyInputs}; do
windowsPath=$(cygpath --windows $i)
echo "Using assembly path: $windowsPath"
if [ "$assemblySearchPaths" = "" ]
then
assemblySearchPaths="$windowsPath"
else
assemblySearchPaths="$assemblySearchPaths;$windowsPath"
fi
if [ "$assemblySearchPaths" = "" ]; then
assemblySearchPaths="$windowsPath"
else
assemblySearchPaths="$assemblySearchPaths;$windowsPath"
fi
addDeps $i
addDeps $i
done
echo "Assembly search paths are: $assemblySearchPaths"
if [ "$assemblySearchPaths" != "" ]
then
echo "Using assembly search paths args: $assemblySearchPathsArg"
export AssemblySearchPaths=$assemblySearchPaths
if [ "$assemblySearchPaths" != "" ]; then
echo "Using assembly search paths args: $assemblySearchPathsArg"
export AssemblySearchPaths=$assemblySearchPaths
fi
mkdir -p $out
@ -77,9 +73,10 @@ stdenv.mkDerivation {
mkdir -p $out/nix-support
for i in ${toString assemblyInputs}
do
echo $i >> $out/nix-support/dotnet-assemblies
for i in ${toString assemblyInputs}; do
echo $i >> $out/nix-support/dotnet-assemblies
done
runHook postInstall
'';
}

View File

@ -28,27 +28,23 @@ dotnetenv.buildSolution {
slnFile = "Wrapper.sln";
assemblyInputs = [ application ];
preBuild = ''
addRuntimeDeps()
{
if [ -f $1/nix-support/dotnet-assemblies ]
then
for i in $(cat $1/nix-support/dotnet-assemblies)
do
windowsPath=$(cygpath --windows $i | sed 's|\\|\\\\|g')
assemblySearchArray="$assemblySearchArray @\"$windowsPath\""
addRuntimeDeps() {
if [ -f $1/nix-support/dotnet-assemblies ]; then
for i in $(cat $1/nix-support/dotnet-assemblies); do
windowsPath=$(cygpath --windows $i | sed 's|\\|\\\\|g')
assemblySearchArray="$assemblySearchArray @\"$windowsPath\""
addRuntimeDeps $i
done
fi
addRuntimeDeps $i
done
fi
}
export exePath=$(cygpath --windows $(find ${application} -name \*.exe) | sed 's|\\|\\\\|g')
# Generate assemblySearchPaths string array contents
for path in ${toString assemblyInputs}
do
assemblySearchArray="$assemblySearchArray @\"$(cygpath --windows $path | sed 's|\\|\\\\|g')\", "
addRuntimeDeps $path
for path in ${toString assemblyInputs}; do
assemblySearchArray="$assemblySearchArray @\"$(cygpath --windows $path | sed 's|\\|\\\\|g')\", "
addRuntimeDeps $path
done
sed -e "s|@ROOTNAMESPACE@|${namespace}Wrapper|" \
@ -57,8 +53,8 @@ dotnetenv.buildSolution {
sed -e "s|@NAMESPACE@|${namespace}|g" \
-e "s|@MAINCLASSNAME@|${mainClassName}|g" \
-e "s|@EXEPATH@|$exePath|g" \
-e "s|@ASSEMBLYSEARCHPATH@|$assemblySearchArray|" \
-e "s|@EXEPATH@|$exePath|g" \
-e "s|@ASSEMBLYSEARCHPATH@|$assemblySearchArray|" \
Wrapper/Wrapper.cs.in > Wrapper/Wrapper.cs
'';
}