-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buildDotnetModule: fix structured attributes support
This change refactors internal hooks used by buildDotnetModule to support derivations with structured attributes. Note that this changes variable names that the internal hooks expect.
- Loading branch information
Showing
19 changed files
with
440 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 46 additions & 30 deletions
76
pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,86 @@ | ||
# inherit arguments from derivation | ||
dotnetBuildFlags=( ${dotnetBuildFlags[@]-} ) | ||
|
||
dotnetBuildHook() { | ||
echo "Executing dotnetBuildHook" | ||
|
||
runHook preBuild | ||
|
||
if [ "${enableParallelBuilding-}" ]; then | ||
local -r hostRuntimeId=@runtimeId@ | ||
local -r dotnetBuildType="${dotnetBuildType-Release}" | ||
local -r dotnetRuntimeId="${dotnetRuntimeId-$hostRuntimeId}" | ||
|
||
if [[ -n $__structuredAttrs ]]; then | ||
local dotnetProjectFilesArray=( "${dotnetProjectFiles[@]}" ) | ||
local dotnetTestProjectFilesArray=( "${dotnetTestProjectFiles[@]}" ) | ||
local dotnetFlagsArray=( "${dotnetFlags[@]}" ) | ||
local dotnetBuildFlagsArray=( "${dotnetBuildFlags[@]}" ) | ||
else | ||
local dotnetProjectFilesArray=($dotnetProjectFiles) | ||
local dotnetTestProjectFilesArray=($dotnetTestProjectFiles) | ||
local dotnetFlagsArray=($dotnetFlags) | ||
local dotnetBuildFlagsArray=($dotnetBuildFlags) | ||
fi | ||
|
||
if [[ -n "${enableParallelBuilding-}" ]]; then | ||
local -r maxCpuFlag="$NIX_BUILD_CORES" | ||
local -r parallelBuildFlag="true" | ||
else | ||
local -r maxCpuFlag="1" | ||
local -r parallelBuildFlag="false" | ||
fi | ||
|
||
if [ "${selfContainedBuild-}" ]; then | ||
dotnetBuildFlags+=("-p:SelfContained=true") | ||
if [[ -n ${dotnetSelfContainedBuild-} ]]; then | ||
dotnetBuildFlagsArray+=("-p:SelfContained=true") | ||
else | ||
dotnetBuildFlags+=("-p:SelfContained=false") | ||
dotnetBuildFlagsArray+=("-p:SelfContained=false") | ||
fi | ||
|
||
if [ "${useAppHost-}" ]; then | ||
dotnetBuildFlags+=("-p:UseAppHost=true") | ||
if [[ -n ${dotnetUseAppHost-} ]]; then | ||
dotnetBuildFlagsArray+=("-p:UseAppHost=true") | ||
fi | ||
|
||
local versionFlags=() | ||
if [ "${version-}" ]; then | ||
versionFlags+=("-p:InformationalVersion=${version-}") | ||
local versionFlagsArray=() | ||
if [[ -n ${version-} ]]; then | ||
versionFlagsArray+=("-p:InformationalVersion=$version") | ||
fi | ||
|
||
if [ "${versionForDotnet-}" ]; then | ||
versionFlags+=("-p:Version=${versionForDotnet-}") | ||
if [[ -n ${versionForDotnet-} ]]; then | ||
versionFlagsArray+=("-p:Version=$versionForDotnet") | ||
fi | ||
|
||
dotnetBuild() { | ||
local -r project="${1-}" | ||
local -r projectFile="${1-}" | ||
|
||
runtimeIdFlags=() | ||
if [[ "$project" == *.csproj ]] || [ "${selfContainedBuild-}" ]; then | ||
runtimeIdFlags+=("--runtime @runtimeId@") | ||
local runtimeIdFlagsArray=() | ||
if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then | ||
runtimeIdFlagsArray+=("--runtime" "$dotnetRuntimeId") | ||
fi | ||
|
||
dotnet build ${project-} \ | ||
-maxcpucount:$maxCpuFlag \ | ||
-p:BuildInParallel=$parallelBuildFlag \ | ||
dotnet build ${1+"$projectFile"} \ | ||
-maxcpucount:"$maxCpuFlag" \ | ||
-p:BuildInParallel="$parallelBuildFlag" \ | ||
-p:ContinuousIntegrationBuild=true \ | ||
-p:Deterministic=true \ | ||
--configuration "@buildType@" \ | ||
--configuration "$dotnetBuildType" \ | ||
--no-restore \ | ||
${versionFlags[@]} \ | ||
${runtimeIdFlags[@]} \ | ||
${dotnetBuildFlags[@]} \ | ||
${dotnetFlags[@]} | ||
"${versionFlagsArray[@]}" \ | ||
"${runtimeIdFlagsArray[@]}" \ | ||
"${dotnetBuildFlagsArray[@]}" \ | ||
"${dotnetFlagsArray[@]}" | ||
} | ||
|
||
(( "${#projectFile[@]}" == 0 )) && dotnetBuild | ||
if (( ${#dotnetProjectFilesArray[@]} == 0 )); then | ||
dotnetBuild | ||
fi | ||
|
||
for project in ${projectFile[@]} ${testProjectFile[@]-}; do | ||
dotnetBuild "$project" | ||
local projectFile | ||
for projectFile in "${dotnetProjectFilesArray[@]}" "${dotnetTestProjectFilesArray[@]}"; do | ||
dotnetBuild "$projectFile" | ||
done | ||
|
||
runHook postBuild | ||
|
||
echo "Finished dotnetBuildHook" | ||
} | ||
|
||
if [[ -z "${dontDotnetBuild-}" && -z "${buildPhase-}" ]]; then | ||
if [[ -z ${dontDotnetBuild-} && -z ${buildPhase-} ]]; then | ||
buildPhase=dotnetBuildHook | ||
fi |
62 changes: 44 additions & 18 deletions
62
pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.