From 407767858336479eebe759404db689a9b1e16671 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 23 Feb 2018 16:34:31 -0800 Subject: Rename "depenencies" to tools. Rework xml file to reduce fields. --- scripts/bootstrap.ps1 | 6 +- scripts/fetchDependency.ps1 | 76 ----------------------- scripts/fetchTool.ps1 | 73 ++++++++++++++++++++++ scripts/findVisualStudioInstallationInstances.ps1 | 2 +- scripts/vcpkgDependencies.xml | 48 -------------- scripts/vcpkgTools.xml | 36 +++++++++++ 6 files changed, 113 insertions(+), 128 deletions(-) delete mode 100644 scripts/fetchDependency.ps1 create mode 100644 scripts/fetchTool.ps1 delete mode 100644 scripts/vcpkgDependencies.xml create mode 100644 scripts/vcpkgTools.xml (limited to 'scripts') diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index 9ee2d1643..bc94aecc8 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -14,9 +14,9 @@ $gitHash = "unknownhash" $oldpath = $env:path try { - [xml]$asXml = Get-Content "$scriptsDir\vcpkgDependencies.xml" - $dependencyData = $asXml.SelectSingleNode("//dependencies/dependency[@name=`"git`"]") - $postExtractionExecutableRelativePath = $dependencyData.postExtractionExecutableRelativePath + [xml]$asXml = Get-Content "$scriptsDir\vcpkgTools.xml" + $toolData = $asXml.SelectSingleNode("//tools/tool[@name=`"git`"]") + $postExtractionExecutableRelativePath = $toolData.postExtractionExecutableRelativePath $gitFromDownload = "$vcpkgRootDir\downloads\$postExtractionExecutableRelativePath" $gitDir = split-path -parent $gitFromDownload diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 deleted file mode 100644 index 5f7902881..000000000 --- a/scripts/fetchDependency.ps1 +++ /dev/null @@ -1,76 +0,0 @@ -[CmdletBinding()] -param( - [Parameter(Mandatory=$true)][string]$dependency -) - -$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition -. "$scriptsDir\VcpkgPowershellUtils.ps1" - -Write-Verbose "Fetching dependency: $dependency" -$vcpkgRootDir = vcpkgFindFileRecursivelyUp $scriptsDir .vcpkg-root - -$downloadsDir = "$vcpkgRootDir\downloads" - -function fetchDependencyInternal([Parameter(Mandatory=$true)][string]$dependency) -{ - $dependency = $dependency.toLower() - - [xml]$asXml = Get-Content "$scriptsDir\vcpkgDependencies.xml" - $dependencyData = $asXml.SelectSingleNode("//dependencies/dependency[@name=`"$dependency`"]") # Case-sensitive! - - if ($dependencyData -eq $null) - { - throw "Unkown dependency $dependency" - } - - $requiredVersion = $dependencyData.requiredVersion - $downloadVersion = $dependencyData.downloadVersion - $url = $dependencyData.x86url - $downloadRelativePath = $dependencyData.downloadRelativePath - $downloadPath = "$downloadsDir\$downloadRelativePath" - $expectedDownloadedFileHash = $dependencyData.sha256 - $extension = $dependencyData.extension - - if (!(Test-Path $downloadPath)) - { - Write-Host "Downloading $dependency..." - vcpkgDownloadFile $url $downloadPath - Write-Host "Downloading $dependency has completed successfully." - } - - $downloadedFileHash = vcpkgGetSHA256 $downloadPath - vcpkgCheckEqualFileHash -filePath $downloadPath -expectedHash $expectedDownloadedFileHash -actualHash $downloadedFileHash - - - if ($extension -eq "exe") - { - $executableFromDownload = $downloadPath - } - elseif ($extension -eq "zip") - { - $postExtractionExecutableRelativePath = $dependencyData.postExtractionExecutableRelativePath - $executableFromDownload = "$downloadsDir\$postExtractionExecutableRelativePath" - if (-not (Test-Path $executableFromDownload)) - { - $outFilename = (Get-ChildItem $downloadPath).BaseName - Write-Host "Extracting $dependency..." - vcpkgExtractFile -File $downloadPath -DestinationDir $downloadsDir -outFilename $outFilename - Write-Host "Extracting $dependency has completed successfully." - } - } - else - { - throw "Unexpected file type" - } - - if (-not (Test-Path $executableFromDownload)) - { - throw ("Could not detect or download " + $dependency) - } - - return $executableFromDownload -} - -$path = fetchDependencyInternal $dependency -Write-Verbose "Fetching dependency: $dependency. Done." -return "::$path::" diff --git a/scripts/fetchTool.ps1 b/scripts/fetchTool.ps1 new file mode 100644 index 000000000..1f72bb39e --- /dev/null +++ b/scripts/fetchTool.ps1 @@ -0,0 +1,73 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory=$true)][string]$tool +) + +$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)" + + if (Test-Path $exePath) + { + return $exePath + } + + if ($toolData.archiveRelativePath) + { + $downloadPath = "$downloadsDir\$($toolData.archiveRelativePath)" + } + else + { + $downloadPath = "$downloadsDir\$($toolData.exeRelativePath)" + } + + $url = $toolData.url + if (!(Test-Path $downloadPath)) + { + Write-Host "Downloading $tool..." + vcpkgDownloadFile $url $downloadPath + Write-Host "Downloading $tool has completed successfully." + } + + $expectedDownloadedFileHash = $toolData.sha256 + $downloadedFileHash = vcpkgGetSHA256 $downloadPath + vcpkgCheckEqualFileHash -filePath $downloadPath -expectedHash $expectedDownloadedFileHash -actualHash $downloadedFileHash + + if ($toolData.archiveRelativePath) + { + $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 "::$path::" diff --git a/scripts/findVisualStudioInstallationInstances.ps1 b/scripts/findVisualStudioInstallationInstances.ps1 index 359da9caa..fba5f447e 100644 --- a/scripts/findVisualStudioInstallationInstances.ps1 +++ b/scripts/findVisualStudioInstallationInstances.ps1 @@ -4,7 +4,7 @@ param( ) $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition -$vswhereExe = (& $scriptsDir\fetchDependency.ps1 "vswhere") -replace "::" -replace "::" +$vswhereExe = (& $scriptsDir\fetchTool.ps1 "vswhere") -replace "::" -replace "::" $output = & $vswhereExe -prerelease -legacy -products * -format xml [xml]$asXml = $output diff --git a/scripts/vcpkgDependencies.xml b/scripts/vcpkgDependencies.xml deleted file mode 100644 index 2007b3ca6..000000000 --- a/scripts/vcpkgDependencies.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - 3.10.2 - 3.10.2 - https://cmake.org/files/v3.10/cmake-3.10.2-win32-x86.zip - cmake-3.10.2-win32-x86.zip - f5f7e41a21d0e9b655aca58498b08e17ecd27796bf82837e2c84435359169dd6 - zip - cmake-3.10.2-win32-x86\bin\cmake.exe - - - 2.16.2 - 2.16.2 - https://github.com/git-for-windows/git/releases/download/v2.16.2.windows.1/MinGit-2.16.2-32-bit.zip - MinGit-2.16.2-32-bit.zip - 322c727e482aa97522c64a5ac68bdda3780111e8670bcfb532beac8e11ece5da - zip - - MinGit-2.16.2-32-bit\cmd\git.exe - - - 2.3.2 - 2.3.2 - https://github.com/Microsoft/vswhere/releases/download/2.3.2/vswhere.exe - vswhere-2.3.2\vswhere.exe - 103f2784c4b2c8e70c7c1c03687abbf22bce052aae30639406e4e13ffa29ee04 - exe - - - 4.4.0 - 4.4.0 - https://dist.nuget.org/win-x86-commandline/v4.4.0/nuget.exe - nuget-4.4.0\nuget.exe - 2cf9b118937eef825464e548f0c44f7f64090047746de295d75ac3dcffa3e1f6 - exe - - - 3.1.81 - 3.1.81 - https://github.com/podsvirov/installer-framework/releases/download/cr203958-9/QtInstallerFramework-win-x86.zip - QtInstallerFramework-win-x86.zip - f2ce23cf5cf9fc7ce409bdca49328e09a070c0026d3c8a04e4dfde7b05b83fe8 - zip - QtInstallerFramework-win-x86\bin\installerbase.exe - - \ No newline at end of file diff --git a/scripts/vcpkgTools.xml b/scripts/vcpkgTools.xml new file mode 100644 index 000000000..e54d16864 --- /dev/null +++ b/scripts/vcpkgTools.xml @@ -0,0 +1,36 @@ + + + + 3.10.2 + cmake-3.10.2-win32-x86\bin\cmake.exe + https://cmake.org/files/v3.10/cmake-3.10.2-win32-x86.zip + f5f7e41a21d0e9b655aca58498b08e17ecd27796bf82837e2c84435359169dd6 + cmake-3.10.2-win32-x86.zip + + + 2.16.2 + MinGit-2.16.2-32-bit\cmd\git.exe + https://github.com/git-for-windows/git/releases/download/v2.16.2.windows.1/MinGit-2.16.2-32-bit.zip + 322c727e482aa97522c64a5ac68bdda3780111e8670bcfb532beac8e11ece5da + MinGit-2.16.2-32-bit.zip + + + 2.3.2 + vswhere-2.3.2\vswhere.exe + https://github.com/Microsoft/vswhere/releases/download/2.3.2/vswhere.exe + 103f2784c4b2c8e70c7c1c03687abbf22bce052aae30639406e4e13ffa29ee04 + + + 4.4.0 + nuget-4.4.0\nuget.exe + https://dist.nuget.org/win-x86-commandline/v4.4.0/nuget.exe + 2cf9b118937eef825464e548f0c44f7f64090047746de295d75ac3dcffa3e1f6 + + + 3.1.81 + QtInstallerFramework-win-x86\bin\installerbase.exe + https://github.com/podsvirov/installer-framework/releases/download/cr203958-9/QtInstallerFramework-win-x86.zip + f2ce23cf5cf9fc7ce409bdca49328e09a070c0026d3c8a04e4dfde7b05b83fe8 + QtInstallerFramework-win-x86.zip + + -- cgit v1.2.3