summary refs log tree commit diff
path: root/pkgs/build-support/dotnet
diff options
context:
space:
mode:
authorIvar Scholten <ivar.scholten@protonmail.com>2022-09-09 00:00:49 +0200
committerIvar Scholten <ivar.scholten@protonmail.com>2022-09-18 18:00:37 +0200
commita7c598e458183b30a7218f3b1301a689b39a6542 (patch)
tree9b26ca8aa611ff21897335bd886a25fff5e612ec /pkgs/build-support/dotnet
parente100b7462775b418ccf8c4dc3aa427d9acb56f82 (diff)
downloadnixpkgs-a7c598e458183b30a7218f3b1301a689b39a6542.tar
nixpkgs-a7c598e458183b30a7218f3b1301a689b39a6542.tar.gz
nixpkgs-a7c598e458183b30a7218f3b1301a689b39a6542.tar.bz2
nixpkgs-a7c598e458183b30a7218f3b1301a689b39a6542.tar.lz
nixpkgs-a7c598e458183b30a7218f3b1301a689b39a6542.tar.xz
nixpkgs-a7c598e458183b30a7218f3b1301a689b39a6542.tar.zst
nixpkgs-a7c598e458183b30a7218f3b1301a689b39a6542.zip
buildDotnetModule: minor changes to hooks
Abide by `set -e` rules and use `local -r` where applicable.
Diffstat (limited to 'pkgs/build-support/dotnet')
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh12
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh10
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh4
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh25
4 files changed, 28 insertions, 23 deletions
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh
index c7a6d8c17ab..3e6f2bd8465 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh
+++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh
@@ -7,11 +7,11 @@ dotnetBuildHook() {
     runHook preBuild
 
     if [ "${enableParallelBuilding-}" ]; then
-        maxCpuFlag="$NIX_BUILD_CORES"
-        parallelBuildFlag="true"
+        local -r maxCpuFlag="$NIX_BUILD_CORES"
+        local -r parallelBuildFlag="true"
     else
-        maxCpuFlag="1"
-        parallelBuildFlag="false"
+        local -r maxCpuFlag="1"
+        local -r parallelBuildFlag="false"
     fi
 
     if [ "${selfContainedBuild-}" ]; then
@@ -21,10 +21,10 @@ dotnetBuildHook() {
     fi
 
     if [ "${version-}" ]; then
-        versionFlag="-p:Version=${version-}"
+        local -r versionFlag="-p:Version=${version-}"
     fi
 
-    for project in ${projectFile[@]} ${testProjectFile[@]}; do
+    for project in ${projectFile[@]} ${testProjectFile[@]-}; do
         env \
             dotnet build "$project" \
                 -maxcpucount:$maxCpuFlag \
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
index bc7b1b5c3d8..0c0e5d310ea 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
+++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
@@ -7,10 +7,16 @@ dotnetCheckHook() {
     runHook preCheck
 
     if [ "${disabledTests-}" ]; then
-        disabledTestsFlag="--filter FullyQualifiedName!=@disabledTests@"
+        local -r disabledTestsFlag="--filter FullyQualifiedName!=@disabledTests@"
     fi
 
-    for project in ${testProjectFile[@]}; do
+    if [ "${enableParallelBuilding-}" ]; then
+        local -r maxCpuFlag="$NIX_BUILD_CORES"
+    else
+        local -r maxCpuFlag="1"
+    fi
+
+    for project in ${testProjectFile[@]-}; do
         env "LD_LIBRARY_PATH=@libraryPath@" \
             dotnet test "$project" \
               -maxcpucount:$maxCpuFlag \
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh
index 3e8c1418950..5528f0e07a3 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh
+++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh
@@ -10,10 +10,10 @@ dotnetConfigureHook() {
     runHook preConfigure
 
     if [ -z "${enableParallelBuilding-}" ]; then
-        parallelFlag="--disable-parallel"
+        local -r parallelFlag="--disable-parallel"
     fi
 
-    for project in ${projectFile[@]} ${testProjectFile[@]}; do
+    for project in ${projectFile[@]} ${testProjectFile[@]-}; do
         env \
             dotnet restore "$project" \
                 -p:ContinuousIntegrationBuild=true \
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
index 0a881fae9cf..59df9b319af 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
+++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
@@ -5,38 +5,37 @@ makeWrapperArgs=( ${makeWrapperArgs-} )
 # the second is the destination for the wrapper.
 wrapDotnetProgram() {
     if [ ! "${selfContainedBuild-}" ]; then
-        dotnetRootFlag=("--set" "DOTNET_ROOT" "@dotnetRuntime@")
+        local -r dotnetRootFlag=("--set" "DOTNET_ROOT" "@dotnetRuntime@")
     fi
 
     makeWrapper "$1" "$2" \
-        "${dotnetRootFlag[@]}" \
         --suffix "LD_LIBRARY_PATH" : "@runtimeDeps@" \
+        "${dotnetRootFlag[@]}" \
         "${gappsWrapperArgs[@]}" \
         "${makeWrapperArgs[@]}"
 
-    echo "Installed wrapper to: "$2""
+    echo "installed wrapper to "$2""
 }
 
 dotnetFixupHook() {
     echo "Executing dotnetFixupPhase"
 
-    if [ "${executables}" ]; then
+    if [ "${executables-}" ]; then
         for executable in ${executables[@]}; do
-            execPath="$out/lib/${pname}/$executable"
+            path="$out/lib/$pname/$executable"
 
-            if [[ -f "$execPath" && -x "$execPath" ]]; then
-                wrapDotnetProgram "$execPath" "$out/bin/$(basename "$executable")"
+            if test -x "$path"; then
+                wrapDotnetProgram "$path" "$out/bin/$(basename "$executable")"
             else
-                echo "Specified binary \"$executable\" is either not an executable, or does not exist!"
+                echo "Specified binary \"$executable\" is either not an executable or does not exist!"
+                echo "Looked in $path"
                 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
+        while IFS= read -d '' executable; do
+            wrapDotnetProgram "$executable" "$out/bin/$(basename "$executable")" \;
+        done < <(find "$out/lib/$pname" ! -name "*.dll" -executable -type f -print0)
     fi
 
     echo "Finished dotnetFixupPhase"