buildDotnetModule: minor changes to hooks
Abide by `set -e` rules and use `local -r` where applicable.
This commit is contained in:
parent
e100b74627
commit
a7c598e458
4 changed files with 28 additions and 23 deletions
|
@ -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 \
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue