blob: ff9b5d9bf60a8058a7e5dbfaddd02fc9bfe12350 (
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
67
68
69
70
71
72
73
74
75
|
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)][string]$tool
)
Set-StrictMode -Version Latest
$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
. "$scriptsDir\VcpkgPowershellUtils.ps1"
Write-Verbose "Fetching tool: $tool"
$vcpkgRootDir = vcpkgFindFileRecursivelyUp $scriptsDir .vcpkg-root
$downloadsDir = "$vcpkgRootDir\downloads"
vcpkgCreateDirectoryIfNotExists $downloadsDir
function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool)
{
$tool = $tool.toLower()
[xml]$asXml = Get-Content "$scriptsDir\vcpkgTools.xml"
$toolData = $asXml.SelectSingleNode("//tools/tool[@name=`"$tool`"]") # Case-sensitive!
if ($toolData -eq $null)
{
throw "Unkown tool $tool"
}
$exePath = "$downloadsDir\$(@($toolData.exeRelativePath)[0])"
if (Test-Path $exePath)
{
return $exePath
}
$isArchive = vcpkgHasProperty -object $toolData -propertyName "archiveRelativePath"
if ($isArchive)
{
$downloadPath = "$downloadsDir\$(@($toolData.archiveRelativePath)[0])"
}
else
{
$downloadPath = "$downloadsDir\$(@($toolData.exeRelativePath)[0])"
}
[String]$url = @($toolData.url)[0]
if (!(Test-Path $downloadPath))
{
Write-Host "Downloading $tool..."
vcpkgDownloadFile $url $downloadPath
Write-Host "Downloading $tool has completed successfully."
}
$expectedDownloadedFileHash = @($toolData.sha256)[0]
$downloadedFileHash = vcpkgGetSHA256 $downloadPath
vcpkgCheckEqualFileHash -filePath $downloadPath -expectedHash $expectedDownloadedFileHash -actualHash $downloadedFileHash
if ($isArchive)
{
$outFilename = (Get-ChildItem $downloadPath).BaseName
Write-Host "Extracting $tool..."
vcpkgExtractFile -File $downloadPath -DestinationDir $downloadsDir -outFilename $outFilename
Write-Host "Extracting $tool has completed successfully."
}
if (-not (Test-Path $exePath))
{
throw ("Could not detect or download " + $tool)
}
return $exePath
}
$path = fetchToolInternal $tool
Write-Verbose "Fetching tool: $tool. Done."
return "<sol>::$path::<eol>"
|