aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2018-03-27 18:06:02 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2018-03-27 18:08:05 -0700
commit12d862ab2b6e387b596e680d334daa212b77fb32 (patch)
tree4a6d852311282112fdac79f48fe0a597cabf815e /scripts
parentc814c9b8ac883aa42930e1f48660145fd4234fe6 (diff)
downloadvcpkg-12d862ab2b6e387b596e680d334daa212b77fb32.tar.gz
vcpkg-12d862ab2b6e387b596e680d334daa212b77fb32.zip
[ps1] Revert function removal
Diffstat (limited to 'scripts')
-rw-r--r--scripts/fetchTool.ps193
1 files changed, 50 insertions, 43 deletions
diff --git a/scripts/fetchTool.ps1 b/scripts/fetchTool.ps1
index 8cf8002bc..26eedac3b 100644
--- a/scripts/fetchTool.ps1
+++ b/scripts/fetchTool.ps1
@@ -13,57 +13,64 @@ $vcpkgRootDir = vcpkgFindFileRecursivelyUp $scriptsDir .vcpkg-root
$downloadsDir = "$vcpkgRootDir\downloads"
vcpkgCreateDirectoryIfNotExists $downloadsDir
-$tool = $tool.toLower()
+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!
+ [xml]$asXml = Get-Content "$scriptsDir\vcpkgTools.xml"
+ $toolData = $asXml.SelectSingleNode("//tools/tool[@name=`"$tool`"]") # Case-sensitive!
-if ($toolData -eq $null)
-{
- throw "Unkown tool $tool"
-}
+ if ($toolData -eq $null)
+ {
+ throw "Unkown tool $tool"
+ }
-$exePath = "$downloadsDir\$($toolData.exeRelativePath)"
+ $exePath = "$downloadsDir\$($toolData.exeRelativePath)"
-if (Test-Path $exePath)
-{
- return $exePath
-}
+ if (Test-Path $exePath)
+ {
+ return $exePath
+ }
-$isArchive = vcpkgHasProperty -object $toolData -propertyName "archiveRelativePath"
-if ($isArchive)
-{
- $downloadPath = "$downloadsDir\$($toolData.archiveRelativePath)"
-}
-else
-{
- $downloadPath = "$downloadsDir\$($toolData.exeRelativePath)"
-}
+ $isArchive = vcpkgHasProperty -object $toolData -propertyName "archiveRelativePath"
+ if ($isArchive)
+ {
+ $downloadPath = "$downloadsDir\$($toolData.archiveRelativePath)"
+ }
+ else
+ {
+ $downloadPath = "$downloadsDir\$($toolData.exeRelativePath)"
+ }
-[String]$url = $toolData.url
-if (!(Test-Path $downloadPath))
-{
- Write-Host "Downloading $tool..."
- vcpkgDownloadFile $url $downloadPath
- Write-Host "Downloading $tool... done."
-}
+ [String]$url = $toolData.url
+ if (!(Test-Path $downloadPath))
+ {
+ Write-Host "Downloading $tool..."
+ vcpkgDownloadFile $url $downloadPath
+ Write-Host "Downloading $tool... done."
+ }
-$expectedDownloadedFileHash = $toolData.sha256
-$downloadedFileHash = vcpkgGetSHA256 $downloadPath
-vcpkgCheckEqualFileHash -filePath $downloadPath -expectedHash $expectedDownloadedFileHash -actualHash $downloadedFileHash
+ $expectedDownloadedFileHash = $toolData.sha256
+ $downloadedFileHash = vcpkgGetSHA256 $downloadPath
+ vcpkgCheckEqualFileHash -filePath $downloadPath -expectedHash $expectedDownloadedFileHash -actualHash $downloadedFileHash
-if ($isArchive)
-{
- $outFilename = (Get-ChildItem $downloadPath).BaseName
- Write-Host "Extracting $tool..."
- vcpkgExtractFile -ArchivePath $downloadPath -DestinationDir $downloadsDir -outFilename $outFilename
- Write-Host "Extracting $tool... done."
-}
+ if ($isArchive)
+ {
+ $outFilename = (Get-ChildItem $downloadPath).BaseName
+ Write-Host "Extracting $tool..."
+ vcpkgExtractFile -ArchivePath $downloadPath -DestinationDir $downloadsDir -outFilename $outFilename
+ Write-Host "Extracting $tool... done."
+ }
-if (-not (Test-Path $exePath))
-{
- Write-Error "Could not detect or download $tool"
- throw
+ if (-not (Test-Path $exePath))
+ {
+ Write-Error "Could not detect or download $tool"
+ throw
+ }
+
+ return $exePath
}
-return "<sol>::$exePath::<eol>"
+$path = fetchToolInternal $tool
+Write-Verbose "Fetching tool: $tool. Done."
+return "<sol>::$path::<eol>"