diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/bootstrap.ps1 | 6 | ||||
| -rw-r--r-- | scripts/fetchDependency.ps1 | 76 | ||||
| -rw-r--r-- | scripts/fetchTool.ps1 | 73 | ||||
| -rw-r--r-- | scripts/findVisualStudioInstallationInstances.ps1 | 2 | ||||
| -rw-r--r-- | scripts/vcpkgDependencies.xml | 48 | ||||
| -rw-r--r-- | scripts/vcpkgTools.xml | 36 |
6 files changed, 113 insertions, 128 deletions
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 "<sol>::$path::<eol>" 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 "<sol>::$path::<eol>" 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 "<sol>::" -replace "::<eol>" +$vswhereExe = (& $scriptsDir\fetchTool.ps1 "vswhere") -replace "<sol>::" -replace "::<eol>" $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 @@ -<?xml version="1.0"?> -<dependencies> - <dependency name="cmake"> - <requiredVersion>3.10.2</requiredVersion> - <downloadVersion>3.10.2</downloadVersion> - <x86url>https://cmake.org/files/v3.10/cmake-3.10.2-win32-x86.zip</x86url> - <downloadRelativePath>cmake-3.10.2-win32-x86.zip</downloadRelativePath> - <sha256>f5f7e41a21d0e9b655aca58498b08e17ecd27796bf82837e2c84435359169dd6</sha256> - <extension>zip</extension> - <postExtractionExecutableRelativePath>cmake-3.10.2-win32-x86\bin\cmake.exe</postExtractionExecutableRelativePath> - </dependency> - <dependency name="git"> - <requiredVersion>2.16.2</requiredVersion> - <downloadVersion>2.16.2</downloadVersion> - <x86url>https://github.com/git-for-windows/git/releases/download/v2.16.2.windows.1/MinGit-2.16.2-32-bit.zip</x86url> - <downloadRelativePath>MinGit-2.16.2-32-bit.zip</downloadRelativePath> - <sha256>322c727e482aa97522c64a5ac68bdda3780111e8670bcfb532beac8e11ece5da</sha256> - <extension>zip</extension> - <!--There is another copy of git.exe in MinGit\bin. However, an installed version of git add the cmd dir to the PATH. - Therefore, choosing the cmd dir here as well.--> - <postExtractionExecutableRelativePath>MinGit-2.16.2-32-bit\cmd\git.exe</postExtractionExecutableRelativePath> - </dependency> - <dependency name="vswhere"> - <requiredVersion>2.3.2</requiredVersion> - <downloadVersion>2.3.2</downloadVersion> - <x86url>https://github.com/Microsoft/vswhere/releases/download/2.3.2/vswhere.exe</x86url> - <downloadRelativePath>vswhere-2.3.2\vswhere.exe</downloadRelativePath> - <sha256>103f2784c4b2c8e70c7c1c03687abbf22bce052aae30639406e4e13ffa29ee04</sha256> - <extension>exe</extension> - </dependency> - <dependency name="nuget"> - <requiredVersion>4.4.0</requiredVersion> - <downloadVersion>4.4.0</downloadVersion> - <x86url>https://dist.nuget.org/win-x86-commandline/v4.4.0/nuget.exe</x86url> - <downloadRelativePath>nuget-4.4.0\nuget.exe</downloadRelativePath> - <sha256>2cf9b118937eef825464e548f0c44f7f64090047746de295d75ac3dcffa3e1f6</sha256> - <extension>exe</extension> - </dependency> - <dependency name="installerbase"> - <requiredVersion>3.1.81</requiredVersion> - <downloadVersion>3.1.81</downloadVersion> - <x86url>https://github.com/podsvirov/installer-framework/releases/download/cr203958-9/QtInstallerFramework-win-x86.zip</x86url> - <downloadRelativePath>QtInstallerFramework-win-x86.zip</downloadRelativePath> - <sha256>f2ce23cf5cf9fc7ce409bdca49328e09a070c0026d3c8a04e4dfde7b05b83fe8</sha256> - <extension>zip</extension> - <postExtractionExecutableRelativePath>QtInstallerFramework-win-x86\bin\installerbase.exe</postExtractionExecutableRelativePath> - </dependency> -</dependencies>
\ 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 @@ +<?xml version="1.0"?> +<tools version="1"> + <tool name="cmake"> + <requiredVersion>3.10.2</requiredVersion> + <exeRelativePath>cmake-3.10.2-win32-x86\bin\cmake.exe</exeRelativePath> + <url>https://cmake.org/files/v3.10/cmake-3.10.2-win32-x86.zip</url> + <sha256>f5f7e41a21d0e9b655aca58498b08e17ecd27796bf82837e2c84435359169dd6</sha256> + <archiveRelativePath>cmake-3.10.2-win32-x86.zip</archiveRelativePath> + </tool> + <tool name="git"> + <requiredVersion>2.16.2</requiredVersion> + <exeRelativePath>MinGit-2.16.2-32-bit\cmd\git.exe</exeRelativePath> + <url>https://github.com/git-for-windows/git/releases/download/v2.16.2.windows.1/MinGit-2.16.2-32-bit.zip</url> + <sha256>322c727e482aa97522c64a5ac68bdda3780111e8670bcfb532beac8e11ece5da</sha256> + <archiveRelativePath>MinGit-2.16.2-32-bit.zip</archiveRelativePath> + </tool> + <tool name="vswhere"> + <requiredVersion>2.3.2</requiredVersion> + <exeRelativePath>vswhere-2.3.2\vswhere.exe</exeRelativePath> + <url>https://github.com/Microsoft/vswhere/releases/download/2.3.2/vswhere.exe</url> + <sha256>103f2784c4b2c8e70c7c1c03687abbf22bce052aae30639406e4e13ffa29ee04</sha256> + </tool> + <tool name="nuget"> + <requiredVersion>4.4.0</requiredVersion> + <exeRelativePath>nuget-4.4.0\nuget.exe</exeRelativePath> + <url>https://dist.nuget.org/win-x86-commandline/v4.4.0/nuget.exe</url> + <sha256>2cf9b118937eef825464e548f0c44f7f64090047746de295d75ac3dcffa3e1f6</sha256> + </tool> + <tool name="installerbase"> + <requiredVersion>3.1.81</requiredVersion> + <exeRelativePath>QtInstallerFramework-win-x86\bin\installerbase.exe</exeRelativePath> + <url>https://github.com/podsvirov/installer-framework/releases/download/cr203958-9/QtInstallerFramework-win-x86.zip</url> + <sha256>f2ce23cf5cf9fc7ce409bdca49328e09a070c0026d3c8a04e4dfde7b05b83fe8</sha256> + <archiveRelativePath>QtInstallerFramework-win-x86.zip</archiveRelativePath> + </tool> +</tools> |
