[ps1] Remove extraneous function

This commit is contained in:
Alexander Karatarakis 2018-03-27 17:48:33 -07:00
parent 26187d1bed
commit 45d31162c2

View File

@ -13,64 +13,57 @@ $vcpkgRootDir = vcpkgFindFileRecursivelyUp $scriptsDir .vcpkg-root
$downloadsDir = "$vcpkgRootDir\downloads" $downloadsDir = "$vcpkgRootDir\downloads"
vcpkgCreateDirectoryIfNotExists $downloadsDir 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)
{ {
$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" throw "Unkown tool $tool"
} }
$exePath = "$downloadsDir\$(@($toolData.exeRelativePath)[0])" $exePath = "$downloadsDir\$($toolData.exeRelativePath)"
if (Test-Path $exePath) if (Test-Path $exePath)
{ {
return $exePath return $exePath
} }
$isArchive = vcpkgHasProperty -object $toolData -propertyName "archiveRelativePath" $isArchive = vcpkgHasProperty -object $toolData -propertyName "archiveRelativePath"
if ($isArchive) if ($isArchive)
{ {
$downloadPath = "$downloadsDir\$(@($toolData.archiveRelativePath)[0])" $downloadPath = "$downloadsDir\$($toolData.archiveRelativePath)"
} }
else else
{ {
$downloadPath = "$downloadsDir\$(@($toolData.exeRelativePath)[0])" $downloadPath = "$downloadsDir\$($toolData.exeRelativePath)"
} }
[String]$url = @($toolData.url)[0] [String]$url = $toolData.url
if (!(Test-Path $downloadPath)) if (!(Test-Path $downloadPath))
{ {
Write-Host "Downloading $tool..." Write-Host "Downloading $tool..."
vcpkgDownloadFile $url $downloadPath vcpkgDownloadFile $url $downloadPath
Write-Host "Downloading $tool... done." Write-Host "Downloading $tool... done."
} }
$expectedDownloadedFileHash = @($toolData.sha256)[0] $expectedDownloadedFileHash = $toolData.sha256
$downloadedFileHash = vcpkgGetSHA256 $downloadPath $downloadedFileHash = vcpkgGetSHA256 $downloadPath
vcpkgCheckEqualFileHash -filePath $downloadPath -expectedHash $expectedDownloadedFileHash -actualHash $downloadedFileHash vcpkgCheckEqualFileHash -filePath $downloadPath -expectedHash $expectedDownloadedFileHash -actualHash $downloadedFileHash
if ($isArchive) if ($isArchive)
{ {
$outFilename = (Get-ChildItem $downloadPath).BaseName $outFilename = (Get-ChildItem $downloadPath).BaseName
Write-Host "Extracting $tool..." Write-Host "Extracting $tool..."
vcpkgExtractFile -ArchivePath $downloadPath -DestinationDir $downloadsDir -outFilename $outFilename vcpkgExtractFile -ArchivePath $downloadPath -DestinationDir $downloadsDir -outFilename $outFilename
Write-Host "Extracting $tool... done." Write-Host "Extracting $tool... done."
}
if (-not (Test-Path $exePath))
{
Write-Error "Could not detect or download $tool"
throw
}
return $exePath
} }
$path = fetchToolInternal $tool if (-not (Test-Path $exePath))
Write-Verbose "Fetching tool: $tool. Done." {
return "<sol>::$path::<eol>" Write-Error "Could not detect or download $tool"
throw
}
return "<sol>::$exePath::<eol>"