diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2018-02-23 16:34:31 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2018-02-23 18:19:04 -0800 |
| commit | 407767858336479eebe759404db689a9b1e16671 (patch) | |
| tree | 7f3014c271062212caa4d3e4c8aa3ca11b96f9fc | |
| parent | f0cee21f7a11c9c2073616e199b412d6fb2a364d (diff) | |
| download | vcpkg-407767858336479eebe759404db689a9b1e16671.tar.gz vcpkg-407767858336479eebe759404db689a9b1e16671.zip | |
Rename "depenencies" to tools. Rework xml file to reduce fields.
| -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 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/vcpkgpaths.cpp | 31 |
7 files changed, 128 insertions, 144 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> diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp index d574b7c4d..8ec7ba4cc 100644 --- a/toolsrc/src/vcpkg/vcpkgpaths.cpp +++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp @@ -80,10 +80,10 @@ namespace vcpkg return data_lines; } - static fs::path fetch_dependency(const fs::path& scripts_folder, - const std::string& tool_name, - const fs::path& expected_downloaded_path, - const std::array<int, 3>& version) + static fs::path fetch_tool(const fs::path& scripts_folder, + const std::string& tool_name, + const fs::path& expected_downloaded_path, + const std::array<int, 3>& version) { const std::string version_as_string = Strings::format("%d.%d.%d", version[0], version[1], version[2]); System::println("A suitable version of %s was not found (required v%s). Downloading portable %s v%s...", @@ -91,22 +91,21 @@ namespace vcpkg version_as_string, tool_name, version_as_string); - const fs::path script = scripts_folder / "fetchDependency.ps1"; + const fs::path script = scripts_folder / "fetchtool.ps1"; const std::string title = Strings::format( "Fetching %s version %s (No sufficient installed version was found)", tool_name, version_as_string); - const System::PowershellParameter dependency_param("Dependency", tool_name); - const std::string output = System::powershell_execute_and_capture_output(title, script, {dependency_param}); + const System::PowershellParameter tool_param("tool", tool_name); + const std::string output = System::powershell_execute_and_capture_output(title, script, {tool_param}); - const std::vector<std::string> dependency_path = keep_data_lines(output); - Checks::check_exit( - VCPKG_LINE_INFO, dependency_path.size() == 1, "Expected dependency path, but got %s", output); + const std::vector<std::string> tool_path = keep_data_lines(output); + Checks::check_exit(VCPKG_LINE_INFO, tool_path.size() == 1, "Expected tool path, but got %s", output); - const fs::path actual_downloaded_path = Strings::trim(std::string{dependency_path.at(0)}); + const fs::path actual_downloaded_path = Strings::trim(std::string{tool_path.at(0)}); std::error_code ec; const auto eq = fs::stdfs::equivalent(expected_downloaded_path, actual_downloaded_path, ec); Checks::check_exit(VCPKG_LINE_INFO, eq && !ec, - "Expected dependency downloaded path to be %s, but was %s", + "Expected tool downloaded path to be %s, but was %s", expected_downloaded_path.u8string(), actual_downloaded_path.u8string()); return actual_downloaded_path; @@ -141,7 +140,7 @@ namespace vcpkg return *p; } - return fetch_dependency(scripts_folder, "cmake", downloaded_copy, EXPECTED_VERSION); + return fetch_tool(scripts_folder, "cmake", downloaded_copy, EXPECTED_VERSION); } fs::path get_nuget_path(const fs::path& downloads_folder, const fs::path& scripts_folder) @@ -161,7 +160,7 @@ namespace vcpkg return *p; } - return fetch_dependency(scripts_folder, "nuget", downloaded_copy, EXPECTED_VERSION); + return fetch_tool(scripts_folder, "nuget", downloaded_copy, EXPECTED_VERSION); } fs::path get_git_path(const fs::path& downloads_folder, const fs::path& scripts_folder) @@ -193,7 +192,7 @@ namespace vcpkg return *p; } - return fetch_dependency(scripts_folder, "git", downloaded_copy, EXPECTED_VERSION); + return fetch_tool(scripts_folder, "git", downloaded_copy, EXPECTED_VERSION); } static fs::path get_ifw_installerbase_path(const fs::path& downloads_folder, const fs::path& scripts_folder) @@ -221,7 +220,7 @@ namespace vcpkg return *p; } - return fetch_dependency(scripts_folder, "installerbase", downloaded_copy, EXPECTED_VERSION); + return fetch_tool(scripts_folder, "installerbase", downloaded_copy, EXPECTED_VERSION); } Expected<VcpkgPaths> VcpkgPaths::create(const fs::path& vcpkg_root_dir) |
