Skip to content

Commit

Permalink
Fix handling of toolchain-specific Windows ARM32 compiler. (#2255)
Browse files Browse the repository at this point in the history
- Ensure that compiler zip and expanded directory are resolved relative to
  the repo root, not current directory.

  This is needed because the azureiotedge-diagnostics build script changes
  the current directory when it switches from building amd64 to arm32.

- Ensure that compiler zip and expanded directory contain the toolchain name.

  Previously the existing expanded directory would be used regardless of
  which toolchain zip was expanded to create it.

  This is also needed because the build agent is shared for older branches that
  do not use the toolchain file, so their zip and expanded directories
  must not conflict.
  • Loading branch information
arsing authored Jan 7, 2020
1 parent 463a663 commit 8a02d35
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions edgelet/build/windows/util.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ function Test-RustUp

function GetPrivateRustPath
{
Join-Path -Path (Get-IotEdgeFolder) -ChildPath 'rust-windows-arm/rust-windows-arm/bin/'
$toolchain = Get-Content -Encoding UTF8 (Join-Path -Path (Get-EdgeletFolder) -ChildPath 'rust-toolchain')
$targetPath = Join-Path -Path (Get-IotEdgeFolder) -ChildPath "rust-windows-arm-$toolchain"
Join-Path -Path $targetPath -ChildPath 'rust-windows-arm/bin/'
}

function Get-CargoCommand
Expand Down Expand Up @@ -54,9 +56,10 @@ function Assert-Rust

$ErrorActionPreference = 'Continue'

$toolchain = Get-Content -Encoding UTF8 (Join-Path -Path (Get-EdgeletFolder) -ChildPath 'rust-toolchain')

if ($Arm) {
if (-not (Test-Path 'rust-windows-arm')) {
# if the folder rust-windows-arm exists, we assume the private rust compiler for arm is installed
if (-not (Test-Path (GetPrivateRustPath))) {
InstallWinArmPrivateRustCompiler
}
}
Expand All @@ -77,7 +80,6 @@ function Assert-Rust
}
}

$toolchain = Get-Content -Encoding UTF8 (Join-Path -Path (Get-EdgeletFolder) -ChildPath 'rust-toolchain')
Write-Host "Installing / updating $toolchain toolchain"
rustup update $toolchain
if ($LastExitCode)
Expand All @@ -90,15 +92,25 @@ function Assert-Rust
}

function InstallWinArmPrivateRustCompiler {
$ProgressPreference = 'SilentlyContinue'

$toolchain = Get-Content -Encoding UTF8 (Join-Path -Path (Get-EdgeletFolder) -ChildPath 'rust-toolchain')
$link = "https://edgebuild.blob.core.windows.net/iotedge-win-arm32v7-tools/rust-windows-arm-$toolchain.zip"

Write-Host "Downloading $link"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest $link -OutFile 'rust-windows-arm.zip' -UseBasicParsing
$downloadPath = (Join-Path -Path (Get-IotEdgeFolder) -ChildPath "rust-windows-arm-$toolchain.zip")
if (-not (Test-Path $downloadPath)) {
$link = "https://edgebuild.blob.core.windows.net/iotedge-win-arm32v7-tools/rust-windows-arm-$toolchain.zip"

Write-Host "Downloading $link to $downloadPath"
Invoke-WebRequest $link -OutFile $downloadPath -UseBasicParsing
}

$targetPath = Join-Path -Path (Get-IotEdgeFolder) -ChildPath "rust-windows-arm-$toolchain"
Write-Host "Extracting $downloadPath to $targetPath"
if (Test-Path $targetPath) {
Remove-Item -Recurse -Force $targetPath
}
Expand-Archive -Path $downloadPath -DestinationPath $targetPath

Write-Host "Extracting $link"
Expand-Archive -Path 'rust-windows-arm.zip' -DestinationPath 'rust-windows-arm'
$ProgressPreference = 'Stop'
}

Expand Down

0 comments on commit 8a02d35

Please sign in to comment.