diff --git a/utils/build.ps1 b/utils/build.ps1 index d6de3c8a92010..bf4a014edeab4 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -1963,10 +1963,6 @@ function Build-SPMProject { $Stopwatch = [Diagnostics.Stopwatch]::StartNew() Invoke-IsolatingEnvVars { - $RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", $ProductVersion) - - $env:Path = "$RuntimeInstallRoot\usr\bin;$($BuildPlatform.ToolchainInstallRoot)\usr\bin;${env:Path}" - $env:SDKROOT = (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) $env:SWIFTCI_USE_LOCAL_DEPS = "1" $Arguments = @( @@ -1997,6 +1993,18 @@ function Build-SPMProject { } } + if ($ActionName -eq "build") { + # For building, we are cross-compiling content using the pinned to ship as part of the toolchain + $env:Path = "$(Get-PinnedToolchainRuntime);$(Get-PinnedToolchainToolsDir);${env:Path}" + $env:SDKROOT = (Get-PinnedToolchainSDK -OS $BuildPlatform.OS) + $Arguments += @("--triple", "$($Platform.Triple)") + } else { + # For testing, we are doing this using the just-built toolchain and only when NOT cross-compiling + $RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", $ProductVersion) + $env:Path = "$RuntimeInstallRoot\usr\bin;$($BuildPlatform.ToolchainInstallRoot)\usr\bin;${env:Path}" + $env:SDKROOT = (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) + } + Invoke-Program swift $ActionName @Arguments @AdditionalArguments } @@ -4322,7 +4330,7 @@ if (-not $SkipBuild -and $IncludeNoAsserts) { Build-NoAssertsToolchain } -if (-not $SkipBuild -and -not $IsCrossCompiling) { +if (-not $SkipBuild) { Invoke-BuildStep Build-DocC $HostPlatform }