]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/tools/vcpkg/scripts/azure-pipelines/windows-unstable/rearrange-msvc-drop-layout.ps1
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / tools / vcpkg / scripts / azure-pipelines / windows-unstable / rearrange-msvc-drop-layout.ps1
1 # Copyright (c) Microsoft Corporation.
2 # SPDX-License-Identifier: MIT
3 #
4 <#
5 .SYNOPSIS
6 Moves files from an MSVC compiler drop to the locations where they are installed in a Visual Studio installation.
7
8 .PARAMETER DropRoot
9 The location where the MSVC compiler drop has been downloaded.
10
11 .PARAMETER BuildType
12 The MSVC drop build type set with /p:_BuildType when MSVC was built. Defaults to 'ret'.
13
14 #>
15 [CmdletBinding()]
16 param(
17 [Parameter(Mandatory = $true)][string]$DropRoot,
18 [Parameter(Mandatory = $false)][ValidateSet('ret', 'chk')][string]$BuildType = 'ret'
19 )
20
21 Set-StrictMode -Version Latest
22
23 $MSVCRoot = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC"
24
25 $ErrorActionPreference = "Stop"
26
27 $tempRoot = "$DropRoot\readytodeploy"
28
29 New-Item -ItemType Directory -Path $tempRoot | Out-Null
30
31 Write-Host "Rearranging x86$BuildType"
32 New-Item -ItemType Directory -Path "$tempRoot\bin\HostX86" | Out-Null
33 Move-Item "$DropRoot\binaries.x86$BuildType\bin\i386" "$tempRoot\bin\HostX86\x86"
34 Move-Item "$DropRoot\binaries.x86$BuildType\bin\x86_amd64" "$tempRoot\bin\HostX86\x64"
35 Move-Item "$DropRoot\binaries.x86$BuildType\bin\x86_arm" "$tempRoot\bin\HostX86\arm"
36
37 Write-Host "Rearranging amd64$BuildType"
38 New-Item -ItemType Directory -Path "$tempRoot\bin\HostX64" | Out-Null
39 Move-Item "$DropRoot\binaries.amd64$BuildType\bin\amd64" "$tempRoot\bin\HostX64\x64"
40 Move-Item "$DropRoot\binaries.amd64$BuildType\bin\amd64_x86" "$tempRoot\bin\HostX64\x86"
41 Move-Item "$DropRoot\binaries.amd64$BuildType\bin\amd64_arm" "$tempRoot\bin\HostX64\arm"
42
43 # Only copy files and directories that already exist in the VS installation.
44 Write-Host "Rearranging inc, lib"
45 New-Item -ItemType Directory -Path "$tempRoot\lib" | Out-Null
46 Move-Item "$DropRoot\binaries.x86$BuildType\inc" "$tempRoot\include"
47 Move-Item "$DropRoot\binaries.x86$BuildType\lib\i386" "$tempRoot\lib\x86"
48 Move-Item "$DropRoot\binaries.amd64$BuildType\lib\amd64" "$tempRoot\lib\x64"
49
50 Write-Host "Rearranging atlmfc"
51 New-Item -ItemType Directory -Path "$tempRoot\atlmfc" | Out-Null
52 New-Item -ItemType Directory -Path "$tempRoot\atlmfc\lib" | Out-Null
53 Move-Item "$DropRoot\binaries.x86$BuildType\atlmfc\include" "$tempRoot\atlmfc\include"
54 Move-Item "$DropRoot\binaries.x86$BuildType\atlmfc\lib\i386" "$tempRoot\atlmfc\lib\x86"
55 Move-Item "$DropRoot\binaries.amd64$BuildType\atlmfc\lib\amd64" "$tempRoot\atlmfc\lib\x64"
56
57 $toolsets = Get-ChildItem -Path $MSVCRoot -Directory | Sort-Object -Descending
58 if ($toolsets.Length -eq 0) {
59 throw "Could not find Visual Studio toolset!"
60 }
61
62 Write-Host "Found toolsets:`n$($toolsets -join `"`n`")`n"
63 $selectedToolset = $toolsets[0]
64 Write-Host "Using toolset: $selectedToolset"
65 for ($idx = 1; $idx -lt $toolsets.Length; $idx++) {
66 $badToolset = $toolsets[$idx]
67 Write-Host "Deleting toolset: $badToolset"
68 Remove-Item $badToolset -Recurse -Force
69 }
70
71 Write-Host "Deploying $tempRoot => $selectedToolset"
72 Copy-Item "$tempRoot\*" $selectedToolset -Recurse -Force
73 Write-Host "Deleting $DropRoot..."
74 Remove-Item $DropRoot -Recurse -Force
75 Write-Host "Done!"