2016-09-19 11:50:08 +08:00
|
|
|
[CmdletBinding()]
|
|
|
|
param(
|
2017-11-26 17:32:09 +08:00
|
|
|
[Parameter(Mandatory=$true)][string]$Dependency
|
2016-09-19 11:50:08 +08:00
|
|
|
)
|
|
|
|
|
2017-11-16 10:07:50 +08:00
|
|
|
$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition
|
|
|
|
. "$scriptsDir\VcpkgPowershellUtils.ps1"
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-05-07 12:37:04 +08:00
|
|
|
Write-Verbose "Fetching dependency: $Dependency"
|
2016-09-20 09:46:02 +08:00
|
|
|
$vcpkgRootDir = & $scriptsDir\findFileRecursivelyUp.ps1 $scriptsDir .vcpkg-root
|
|
|
|
|
|
|
|
$downloadsDir = "$vcpkgRootDir\downloads"
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
|
|
|
|
{
|
|
|
|
# Enums (without resorting to C#) are only available on powershell 5+.
|
|
|
|
$ExtractionType_NO_EXTRACTION_REQUIRED = 0
|
|
|
|
$ExtractionType_ZIP = 1
|
|
|
|
$ExtractionType_SELF_EXTRACTING_7Z = 2
|
2017-01-24 09:02:43 +08:00
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
if($Dependency -eq "cmake")
|
|
|
|
{
|
2018-01-20 07:12:21 +08:00
|
|
|
$requiredVersion = "3.10.2"
|
|
|
|
$downloadVersion = "3.10.2"
|
|
|
|
$url = "https://cmake.org/files/v3.10/cmake-3.10.2-win32-x86.zip"
|
|
|
|
$downloadPath = "$downloadsDir\cmake-3.10.2-win32-x86.zip"
|
|
|
|
$expectedDownloadedFileHash = "f5f7e41a21d0e9b655aca58498b08e17ecd27796bf82837e2c84435359169dd6"
|
|
|
|
$executableFromDownload = "$downloadsDir\cmake-3.10.2-win32-x86\bin\cmake.exe"
|
2016-09-19 11:50:08 +08:00
|
|
|
$extractionType = $ExtractionType_ZIP
|
|
|
|
}
|
|
|
|
elseif($Dependency -eq "nuget")
|
|
|
|
{
|
2017-10-18 05:19:48 +08:00
|
|
|
$requiredVersion = "4.4.0"
|
|
|
|
$downloadVersion = "4.4.0"
|
|
|
|
$url = "https://dist.nuget.org/win-x86-commandline/v4.4.0/nuget.exe"
|
2017-10-06 05:27:36 +08:00
|
|
|
$downloadPath = "$downloadsDir\nuget-$downloadVersion\nuget.exe"
|
2017-10-18 05:19:48 +08:00
|
|
|
$expectedDownloadedFileHash = "2cf9b118937eef825464e548f0c44f7f64090047746de295d75ac3dcffa3e1f6"
|
2017-01-25 04:30:14 +08:00
|
|
|
$executableFromDownload = $downloadPath
|
2016-09-19 11:50:08 +08:00
|
|
|
$extractionType = $ExtractionType_NO_EXTRACTION_REQUIRED
|
|
|
|
}
|
2017-10-06 05:27:36 +08:00
|
|
|
elseif($Dependency -eq "vswhere")
|
|
|
|
{
|
2017-11-04 07:40:28 +08:00
|
|
|
$requiredVersion = "2.2.11"
|
|
|
|
$downloadVersion = "2.2.11"
|
|
|
|
$url = "https://github.com/Microsoft/vswhere/releases/download/2.2.11/vswhere.exe"
|
2017-10-06 05:27:36 +08:00
|
|
|
$downloadPath = "$downloadsDir\vswhere-$downloadVersion\vswhere.exe"
|
2017-11-04 07:40:28 +08:00
|
|
|
$expectedDownloadedFileHash = "0235c2cb6341978abdf32e27fcf1d7af5cb5514c035e529c4cd9283e6f1a261f"
|
2017-10-06 05:27:36 +08:00
|
|
|
$executableFromDownload = $downloadPath
|
|
|
|
$extractionType = $ExtractionType_NO_EXTRACTION_REQUIRED
|
|
|
|
}
|
2016-09-19 11:50:08 +08:00
|
|
|
elseif($Dependency -eq "git")
|
|
|
|
{
|
2017-11-01 08:30:29 +08:00
|
|
|
$requiredVersion = "2.15.0"
|
|
|
|
$downloadVersion = "2.15.0"
|
|
|
|
$url = "https://github.com/git-for-windows/git/releases/download/v2.15.0.windows.1/MinGit-2.15.0-32-bit.zip"
|
|
|
|
$downloadPath = "$downloadsDir\MinGit-2.15.0-32-bit.zip"
|
|
|
|
$expectedDownloadedFileHash = "69c035ab7b75c42ce5dd99e8927d2624ab618fab73c5ad84c9412bd74c343537"
|
2017-02-16 08:35:51 +08:00
|
|
|
# There is another copy of git.exe in MinGit\bin. However, an installed version of git add the cmd dir to the PATH.
|
2017-01-24 09:02:43 +08:00
|
|
|
# Therefore, choosing the cmd dir here as well.
|
2017-11-01 08:30:29 +08:00
|
|
|
$executableFromDownload = "$downloadsDir\MinGit-2.15.0-32-bit\cmd\git.exe"
|
2017-02-16 08:35:51 +08:00
|
|
|
$extractionType = $ExtractionType_ZIP
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
2017-09-27 07:57:51 +08:00
|
|
|
elseif($Dependency -eq "installerbase")
|
|
|
|
{
|
|
|
|
$requiredVersion = "3.1.81"
|
|
|
|
$downloadVersion = "3.1.81"
|
|
|
|
$url = "https://github.com/podsvirov/installer-framework/releases/download/cr203958-9/QtInstallerFramework-win-x86.zip"
|
|
|
|
$downloadPath = "$downloadsDir\QtInstallerFramework-win-x86.zip"
|
|
|
|
$expectedDownloadedFileHash = "f2ce23cf5cf9fc7ce409bdca49328e09a070c0026d3c8a04e4dfde7b05b83fe8"
|
|
|
|
$executableFromDownload = "$downloadsDir\QtInstallerFramework-win-x86\bin\installerbase.exe"
|
|
|
|
$extractionType = $ExtractionType_ZIP
|
|
|
|
}
|
2016-09-19 11:50:08 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
throw "Unknown program requested"
|
|
|
|
}
|
|
|
|
|
2018-01-19 10:12:14 +08:00
|
|
|
if (!(Test-Path $downloadPath))
|
|
|
|
{
|
|
|
|
Write-Host "Downloading $Dependency..."
|
|
|
|
vcpkgDownloadFile $url $downloadPath
|
|
|
|
Write-Host "Downloading $Dependency has completed successfully."
|
|
|
|
}
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-11-16 10:07:50 +08:00
|
|
|
$downloadedFileHash = vcpkgGetSHA256 $downloadPath
|
|
|
|
vcpkgCheckEqualFileHash -filePath $downloadPath -expectedHash $expectedDownloadedFileHash -actualHash $downloadedFileHash
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
if ($extractionType -eq $ExtractionType_NO_EXTRACTION_REQUIRED)
|
|
|
|
{
|
|
|
|
# do nothing
|
|
|
|
}
|
|
|
|
elseif($extractionType -eq $ExtractionType_ZIP)
|
|
|
|
{
|
2017-11-16 18:01:50 +08:00
|
|
|
if (-not (Test-Path $executableFromDownload))
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-12-09 07:16:35 +08:00
|
|
|
$outFilename = (Get-ChildItem $downloadPath).BaseName
|
2018-01-18 09:34:09 +08:00
|
|
|
Write-Host "Extracting $Dependency..."
|
2017-12-09 07:16:35 +08:00
|
|
|
vcpkgExtractFile -File $downloadPath -DestinationDir $downloadsDir -outFilename $outFilename
|
2018-01-18 09:34:09 +08:00
|
|
|
Write-Host "Extracting $Dependency has completed successfully."
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif($extractionType -eq $ExtractionType_SELF_EXTRACTING_7Z)
|
|
|
|
{
|
|
|
|
if (-not (Test-Path $executableFromDownload))
|
|
|
|
{
|
2017-11-16 10:07:50 +08:00
|
|
|
vcpkgInvokeCommand $downloadPath "-y" -wait:$true
|
2017-01-24 09:02:43 +08:00
|
|
|
}
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw "Invalid extraction type"
|
|
|
|
}
|
|
|
|
|
|
|
|
if (-not (Test-Path $executableFromDownload))
|
|
|
|
{
|
2017-11-04 07:39:43 +08:00
|
|
|
throw ("Could not detect or download " + $Dependency)
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
2017-01-25 04:36:46 +08:00
|
|
|
|
2017-03-12 11:08:16 +08:00
|
|
|
return $executableFromDownload
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
|
2017-11-01 08:23:09 +08:00
|
|
|
$path = SelectProgram $Dependency
|
2017-05-07 12:37:04 +08:00
|
|
|
Write-Verbose "Fetching dependency: $Dependency. Done."
|
2017-11-01 08:23:09 +08:00
|
|
|
return "<sol>::$path::<eol>"
|