-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[vcpkg] Implementation of --x-binarysource=nuget (and friends) #12058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ras0219-msft
merged 22 commits into
microsoft:master
from
ras0219:dev/roschuma/nuget-binarycaching
Jun 26, 2020
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
2b1b0e8
[vcpkg] Initial implementation of --x-binarysource=nuget
ras0219-msft 9c45e7b
Merge branch 'master' into dev/roschuma/nuget-binarycaching
ras0219-msft 8c690a7
[vcpkg] Remove double-double quoting of CMake arguments
ras0219-msft 862d73c
[vcpkg] Update nuget.exe to 5.5.1 to support Azure DevOps Artifacts
ras0219-msft ec56388
[vcpkg] Enable batching of NuGet server calls with prefetch(). Add `i…
ras0219-msft fbcc5de
[vcpkg] Add `nugetconfig` binary source
ras0219-msft fb4db0c
Merge remote-tracking branch 'origin/master' into dev/roschuma/nuget-…
ras0219-msft c512b02
[vcpkg] Short circuit querying remote NuGet servers once all refs are…
ras0219-msft b23aa70
[vcpkg] Add experimental help for binary caching
ras0219-msft 17a7963
[vcpkg] Improved NuGet cache package descriptions and version formatting
ras0219-msft 1e140ad
Merge remote-tracking branch 'origin/master' into dev/roschuma/nuget-…
ras0219-msft c41125d
[vcpkg] Rename `CmdLineBuilder::build()` to extract()
ras0219-msft 78edd0d
[vcpkg-help] Ascii-betize help topics
ras0219-msft b0574f4
[vcpkg] Add tests for cmdlinebuilder. Improve handling of quotes and …
ras0219-msft 54caa05
[vcpkg] Addressing code review comments
ras0219-msft add3ae9
[vcpkg] Add tests for vcpkg::reformat_version()
ras0219-msft 0903807
[vcpkg] Added test for vcpkg::generate_nuspec()
ras0219-msft db1c64f
[vcpkg] Add tests for vcpkg::XmlSerializer
ras0219-msft 45b2376
[vcpkg] Addressed code review comment
ras0219-msft c887b2b
[vcpkg] Add test for vcpkg::Strings::find_first_of
ras0219-msft 1d238b5
[vcpkg] Fix machine-specific paths in test for vcpkg::generate_nuspec()
ras0219-msft 0a39c1c
Merge remote-tracking branch 'origin/master' into dev/roschuma/nuget-…
ras0219-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <vcpkg/dependencies.h> | ||
| #include <vcpkg/packagespec.h> | ||
| #include <vcpkg/vcpkgpaths.h> | ||
|
|
||
| namespace vcpkg | ||
| { | ||
| std::string reformat_version(const std::string& version, const std::string& abi_tag); | ||
|
|
||
| struct NugetReference | ||
| { | ||
| explicit NugetReference(const Dependencies::InstallPlanAction& action) | ||
| : NugetReference(action.spec, | ||
| action.source_control_file_location.value_or_exit(VCPKG_LINE_INFO) | ||
| .source_control_file->core_paragraph->version, | ||
| action.abi_info.value_or_exit(VCPKG_LINE_INFO).package_abi) | ||
| { | ||
| } | ||
|
|
||
| NugetReference(const PackageSpec& spec, const std::string& raw_version, const std::string& abi_tag) | ||
| : id(spec.dir()), version(reformat_version(raw_version, abi_tag)) | ||
| { | ||
| } | ||
|
|
||
| std::string id; | ||
| std::string version; | ||
|
|
||
| std::string nupkg_filename() const { return Strings::concat(id, '.', version, ".nupkg"); } | ||
| }; | ||
|
|
||
| std::string generate_nuspec(const VcpkgPaths& paths, | ||
| const Dependencies::InstallPlanAction& action, | ||
| const NugetReference& ref); | ||
|
|
||
| struct XmlSerializer | ||
| { | ||
| std::string buf; | ||
| int indent = 0; | ||
|
|
||
| XmlSerializer& emit_declaration(); | ||
| XmlSerializer& open_tag(StringLiteral sl); | ||
| XmlSerializer& start_complex_open_tag(StringLiteral sl); | ||
| XmlSerializer& text_attr(StringLiteral name, StringView content); | ||
| XmlSerializer& finish_complex_open_tag(); | ||
| XmlSerializer& finish_self_closing_complex_tag(); | ||
| XmlSerializer& close_tag(StringLiteral sl); | ||
| XmlSerializer& text(StringView sv); | ||
| XmlSerializer& simple_tag(StringLiteral tag, StringView content); | ||
| XmlSerializer& line_break(); | ||
| }; | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| #include <catch2/catch.hpp> | ||
| #include <vcpkg/binarycaching.private.h> | ||
| #include <vcpkg/base/files.h> | ||
| #include <vcpkg/vcpkgcmdarguments.h> | ||
| #include <vcpkg/sourceparagraph.h> | ||
| #include <vcpkg/paragraphs.h> | ||
| #include <vcpkg/dependencies.h> | ||
| #include <string> | ||
|
|
||
| using namespace vcpkg; | ||
|
|
||
| TEST_CASE ("reformat_version semver-ish", "[reformat_version]") | ||
| { | ||
| REQUIRE(reformat_version("0.0.0", "abitag") == "0.0.0-abitag"); | ||
| REQUIRE(reformat_version("1.0.1", "abitag") == "1.0.1-abitag"); | ||
| REQUIRE(reformat_version("1.01.000", "abitag") == "1.1.0-abitag"); | ||
| REQUIRE(reformat_version("1.2", "abitag") == "1.2.0-abitag"); | ||
| REQUIRE(reformat_version("v52", "abitag") == "52.0.0-abitag"); | ||
| REQUIRE(reformat_version("v09.01.02", "abitag") == "9.1.2-abitag"); | ||
| REQUIRE(reformat_version("1.1.1q", "abitag") == "1.1.1-abitag"); | ||
| REQUIRE(reformat_version("1", "abitag") == "1.0.0-abitag"); | ||
| } | ||
|
|
||
| TEST_CASE ("reformat_version date", "[reformat_version]") | ||
| { | ||
| REQUIRE(reformat_version("2020-06-26", "abitag") == "2020.6.26-abitag"); | ||
| REQUIRE(reformat_version("20-06-26", "abitag") == "0.0.0-abitag"); | ||
| REQUIRE(reformat_version("2020-06-26-release", "abitag") == "2020.6.26-abitag"); | ||
| REQUIRE(reformat_version("2020-06-26000", "abitag") == "2020.6.26-abitag"); | ||
| } | ||
|
|
||
| TEST_CASE ("reformat_version generic", "[reformat_version]") | ||
| { | ||
| REQUIRE(reformat_version("apr", "abitag") == "0.0.0-abitag"); | ||
| REQUIRE(reformat_version("", "abitag") == "0.0.0-abitag"); | ||
| } | ||
|
|
||
| TEST_CASE ("generate_nuspec", "[generate_nuspec]") | ||
| { | ||
| auto& fsWrapper = Files::get_real_filesystem(); | ||
| VcpkgCmdArguments args = VcpkgCmdArguments::create_from_arg_sequence(nullptr, nullptr); | ||
| args.packages_root_dir = std::make_unique<std::string>("/"); | ||
| VcpkgPaths paths(fsWrapper, args); | ||
|
|
||
| auto pghs = Paragraphs::parse_paragraphs(R"( | ||
| Source: zlib2 | ||
| Version: 1.5 | ||
| Build-Depends: zlib | ||
| Description: a spiffy compression library wrapper | ||
|
|
||
| Feature: a | ||
| Description: a feature | ||
|
|
||
| Feature: b | ||
| Description: enable bzip capabilities | ||
| Build-Depends: bzip | ||
| )", | ||
| "<testdata>"); | ||
| REQUIRE(pghs.has_value()); | ||
| auto maybe_scf = SourceControlFile::parse_control_file(fs::path(), std::move(*pghs.get())); | ||
| REQUIRE(maybe_scf.has_value()); | ||
| SourceControlFileLocation scfl{std::move(*maybe_scf.get()), fs::path()}; | ||
|
|
||
| Dependencies::InstallPlanAction ipa(PackageSpec{"zlib2", Triplet::X64_WINDOWS}, | ||
| scfl, | ||
| Dependencies::RequestType::USER_REQUESTED, | ||
| {{"a", {}}, {"b", {}}}); | ||
|
|
||
| ipa.abi_info = Build::AbiInfo{}; | ||
| ipa.abi_info.get()->package_abi = "packageabi"; | ||
| std::string tripletabi("tripletabi"); | ||
| ipa.abi_info.get()->triplet_abi = tripletabi; | ||
|
|
||
| NugetReference ref(ipa); | ||
|
|
||
| REQUIRE(ref.nupkg_filename() == "zlib2_x64-windows.1.5.0-packageabi.nupkg"); | ||
|
|
||
| auto nuspec = generate_nuspec(paths, ipa, ref); | ||
| #ifdef _WIN32 | ||
| #define PKGPATH "C:\\zlib2_x64-windows\\**" | ||
| #else | ||
| #define PKGPATH "/zlib2_x64-windows/**" | ||
| #endif | ||
| std::string expected = R"(<package> | ||
| <metadata> | ||
| <id>zlib2_x64-windows</id> | ||
| <version>1.5.0-packageabi</version> | ||
| <authors>vcpkg</authors> | ||
| <description>NOT FOR DIRECT USE. Automatically generated cache package. | ||
|
|
||
| a spiffy compression library wrapper | ||
|
|
||
| Version: 1.5 | ||
| Triplet/Compiler hash: tripletabi | ||
| Features: a, b | ||
| Dependencies: | ||
| </description> | ||
| <packageTypes><packageType name="vcpkg"/></packageTypes> | ||
| </metadata> | ||
| <files><file src=")" PKGPATH R"(" target=""/></files> | ||
| </package> | ||
| )"; | ||
| auto expected_lines = Strings::split(expected, '\n'); | ||
| auto nuspec_lines = Strings::split(nuspec, '\n'); | ||
| for (size_t i = 0; i < expected_lines.size() && i < nuspec_lines.size(); ++i) | ||
| { | ||
| INFO("on line: " << i); | ||
| REQUIRE(nuspec_lines[i] == expected_lines[i]); | ||
| } | ||
| REQUIRE(nuspec_lines.size() == expected_lines.size()); | ||
| } | ||
|
|
||
| TEST_CASE ("XmlSerializer", "[XmlSerializer]") | ||
| { | ||
| XmlSerializer xml; | ||
| xml.open_tag("a"); | ||
| xml.open_tag("b"); | ||
| xml.simple_tag("c", "d"); | ||
| xml.close_tag("b"); | ||
| xml.text("escaping: & < > \" '"); | ||
|
|
||
| REQUIRE(xml.buf == R"(<a><b><c>d</c></b>escaping: & < > " ')"); | ||
|
|
||
| xml = XmlSerializer(); | ||
| xml.emit_declaration(); | ||
| xml.start_complex_open_tag("a").text_attr("b", "<").text_attr("c", " ").finish_self_closing_complex_tag(); | ||
| REQUIRE(xml.buf == R"(<?xml version="1.0" encoding="utf-8"?><a b="<" c=" "/>)"); | ||
|
|
||
| xml = XmlSerializer(); | ||
| xml.start_complex_open_tag("a").finish_complex_open_tag(); | ||
| REQUIRE(xml.buf == R"(<a>)"); | ||
|
|
||
| xml = XmlSerializer(); | ||
| xml.line_break(); | ||
| xml.open_tag("a").line_break().line_break(); | ||
| xml.close_tag("a").line_break().line_break(); | ||
| REQUIRE(xml.buf == "\n<a>\n \n </a>\n\n"); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.