aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/scripts/azure-pipelines/windows/deploy-inteloneapi.ps1
blob: 6b99d9f9dad4e6e1a219ac7da333c4c128be998f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT

param([string]$SasToken)

if (Test-Path "$PSScriptRoot/utility-prefix.ps1") {
  . "$PSScriptRoot/utility-prefix.ps1"
}


[string]$oneAPIBaseUrl
if ([string]::IsNullOrEmpty($SasToken)) {
  Write-Host 'Downloading from the Internet'
  $oneAPIBaseUrl = 'https://registrationcenter-download.intel.com/akdlm/IRC_NAS/3bbdaf75-6728-492e-a18c-be654dae9ee2/intel-oneapi-hpc-toolkit-2025.2.0.576_offline.exe'
} else {
  Write-Host 'Downloading from vcpkgimageminting using SAS token'
  $SasToken = $SasToken.Replace('"', '')
  $oneAPIBaseUrl = "https://vcpkgimageminting.blob.core.windows.net/assets/intel-oneapi-hpc-toolkit-2025.2.0.576_offline.exe?$SasToken"
}

$oneAPIHPCComponents = 'intel.oneapi.win.ifort-compiler'

$LocalName = 'intel-oneapi-hpc-toolkit-2025.2.0.576_offline.exe'

try {
  [bool]$doRemove = $false
  [string]$LocalPath = Join-Path $PSScriptRoot $LocalName
  if (Test-Path $LocalPath) {
    Write-Host "Using local Intel oneAPI..."
  } else {
    Write-Host "Downloading Intel oneAPI..."
    $tempPath = Get-TempFilePath
    New-Item -ItemType Directory -Path $tempPath -Force
    $LocalPath = Join-Path $tempPath $LocalName
    curl.exe -L -o $LocalPath $oneAPIBaseUrl
    $doRemove = $true
  }

  [string]$extractionPath = Get-TempFilePath
  Write-Host 'Extracting Intel oneAPI...to folder: ' $extractionPath
  $proc = Start-Process -FilePath $LocalPath -ArgumentList @('-s ', '-x', '-f', $extractionPath) -Wait -PassThru
  $exitCode = $proc.ExitCode
  if ($exitCode -eq 0) {
    Write-Host 'Extraction successful!'
  } else {
    Write-Error "Extraction failed! Exited with $exitCode."
    throw
  }

  Write-Host 'Install Intel oneAPI...from folder: ' $extractionPath
  $proc = Start-Process -FilePath "$extractionPath/bootstrapper.exe" -ArgumentList @('-s ', '--action install', "--components=$oneAPIHPCComponents" , '--eula=accept', '-p=NEED_VS2017_INTEGRATION=0', '-p=NEED_VS2019_INTEGRATION=0', '-p=NEED_VS2022_INTEGRATION=0', '--log-dir=.') -Wait -PassThru
  $exitCode = $proc.ExitCode
  if ($exitCode -eq 0) {
    Write-Host 'Installation successful!'
  } elseif ($exitCode -eq 3010) {
    Write-Host 'Installation successful! Exited with 3010 (ERROR_SUCCESS_REBOOT_REQUIRED).'
  } else {
    Write-Error "Installation failed! Exited with $exitCode."
  }

  if ($doRemove) {
    Remove-Item -Path $LocalPath -Force
  }
} catch {
  Write-Error "Installation failed! Exception: $($_.Exception.Message)"
}