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