mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-11 02:09:03 +08:00
3b0080e3b0
`files.h/files.cpp`: * Add end and else comments to all macros. * Add "remove_all_inside" function which empties a directory without actually deleting the directory. This is necessary to handle the case where the directory is actually a directory symlink. * Change remove_all to use std::remove when VCPKG_USE_STD_FILESYSTEM is set; this will engage POSIX delete support available on current Win10. `commands.ci.cpp`: empty "installed". `*/initialize_environment.*`: No longer clean the directories outside the tool. `ci-step.ps1`: Remove unused console output tee-ing.
92 lines
2.6 KiB
PowerShell
92 lines
2.6 KiB
PowerShell
# Copyright (c) Microsoft Corporation.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
<#
|
|
.SYNOPSIS
|
|
Sets up the environment to run other vcpkg CI steps in an Azure Pipelines job.
|
|
|
|
.DESCRIPTION
|
|
This script maps network drives from infrastructure and cleans out anything that
|
|
might have been leftover from a previous run.
|
|
|
|
.PARAMETER ForceAllPortsToRebuildKey
|
|
A subdirectory / key to use to force a build without any previous run caching,
|
|
if necessary.
|
|
#>
|
|
|
|
[CmdletBinding()]
|
|
Param(
|
|
[string]$ForceAllPortsToRebuildKey = ''
|
|
)
|
|
|
|
$StorageAccountName = $env:StorageAccountName
|
|
$StorageAccountKey = $env:StorageAccountKey
|
|
|
|
function Remove-DirectorySymlink {
|
|
Param([string]$Path)
|
|
if (Test-Path $Path) {
|
|
[System.IO.Directory]::Delete($Path)
|
|
}
|
|
}
|
|
|
|
Write-Host 'Setting up archives mount'
|
|
if (-Not (Test-Path W:)) {
|
|
net use W: "\\$StorageAccountName.file.core.windows.net\archives" /u:"AZURE\$StorageAccountName" $StorageAccountKey
|
|
}
|
|
|
|
Write-Host 'Creating downloads directory'
|
|
mkdir D:\downloads -ErrorAction SilentlyContinue
|
|
|
|
# Delete entries in the downloads folder, except:
|
|
# those in the 'tools' folder
|
|
# those last accessed in the last 30 days
|
|
Get-ChildItem -Path D:\downloads -Exclude "tools" `
|
|
| Where-Object{ $_.LastAccessTime -lt (get-Date).AddDays(-30) } `
|
|
| ForEach-Object{Remove-Item -Path $_ -Recurse -Force}
|
|
|
|
# Msys sometimes leaves a database lock file laying around, especially if there was a failed job
|
|
# which causes unrelated failures in jobs that run later on the machine.
|
|
# work around this by just removing the vcpkg installed msys2 if it exists
|
|
if( Test-Path D:\downloads\tools\msys2 )
|
|
{
|
|
Write-Host "removing previously installed msys2"
|
|
Remove-Item D:\downloads\tools\msys2 -Recurse -Force
|
|
}
|
|
|
|
Write-Host 'Setting up archives path...'
|
|
if ([string]::IsNullOrWhiteSpace($ForceAllPortsToRebuildKey))
|
|
{
|
|
$archivesPath = 'W:\'
|
|
}
|
|
else
|
|
{
|
|
$archivesPath = "W:\force\$ForceAllPortsToRebuildKey"
|
|
if (-Not (Test-Path $fullPath)) {
|
|
Write-Host 'Creating $archivesPath'
|
|
mkdir $archivesPath
|
|
}
|
|
}
|
|
|
|
Write-Host "Linking archives => $archivesPath"
|
|
if (-Not (Test-Path archives)) {
|
|
cmd /c "mklink /D archives $archivesPath"
|
|
}
|
|
|
|
Write-Host 'Linking installed => E:\installed'
|
|
if (-Not (Test-Path E:\installed)) {
|
|
mkdir E:\installed
|
|
}
|
|
|
|
if (-Not (Test-Path installed)) {
|
|
cmd /c "mklink /D installed E:\installed"
|
|
}
|
|
|
|
Write-Host 'Linking downloads => D:\downloads'
|
|
if (-Not (Test-Path D:\downloads)) {
|
|
mkdir D:\downloads
|
|
}
|
|
|
|
if (-Not (Test-Path downloads)) {
|
|
cmd /c "mklink /D downloads D:\downloads"
|
|
}
|