aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
authorras0219 <robertallenschumacher@gmail.com>2020-06-26 12:16:02 -0700
committerGitHub <noreply@github.com>2020-06-26 12:16:02 -0700
commit91e798afd899f84654f25e3d7f5beb276c6bd5af (patch)
treefcc620a5c63d3523c03c9c30c56188b13276b5a5 /toolsrc/include
parent7ebb42a4d9d8b384bc3128dd571ec9bba8cdd599 (diff)
downloadvcpkg-91e798afd899f84654f25e3d7f5beb276c6bd5af.tar.gz
vcpkg-91e798afd899f84654f25e3d7f5beb276c6bd5af.zip
[vcpkg] Implementation of --x-binarysource=nuget (and friends) (#12058)
* [vcpkg] Initial implementation of --x-binarysource=nuget * [vcpkg] Remove double-double quoting of CMake arguments * [vcpkg] Update nuget.exe to 5.5.1 to support Azure DevOps Artifacts * [vcpkg] Enable batching of NuGet server calls with prefetch(). Add `interactive` binarysource. * [vcpkg] Add `nugetconfig` binary source * [vcpkg] Short circuit querying remote NuGet servers once all refs are found * [vcpkg] Add experimental help for binary caching * [vcpkg] Improved NuGet cache package descriptions and version formatting * [vcpkg] Rename `CmdLineBuilder::build()` to extract() * [vcpkg-help] Ascii-betize help topics * [vcpkg] Add tests for cmdlinebuilder. Improve handling of quotes and slashes. * [vcpkg] Addressing code review comments * [vcpkg] Add tests for vcpkg::reformat_version() * [vcpkg] Added test for vcpkg::generate_nuspec() * [vcpkg] Add tests for vcpkg::XmlSerializer * [vcpkg] Addressed code review comment * [vcpkg] Add test for vcpkg::Strings::find_first_of * [vcpkg] Fix machine-specific paths in test for vcpkg::generate_nuspec() Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg/base/strings.h2
-rw-r--r--toolsrc/include/vcpkg/base/system.process.h12
-rw-r--r--toolsrc/include/vcpkg/base/util.h13
-rw-r--r--toolsrc/include/vcpkg/binarycaching.h12
-rw-r--r--toolsrc/include/vcpkg/binarycaching.private.h54
-rw-r--r--toolsrc/include/vcpkg/build.h3
-rw-r--r--toolsrc/include/vcpkg/vcpkgcmdarguments.h1
7 files changed, 95 insertions, 2 deletions
diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h
index 425d846df..17bef7675 100644
--- a/toolsrc/include/vcpkg/base/strings.h
+++ b/toolsrc/include/vcpkg/base/strings.h
@@ -175,6 +175,8 @@ namespace vcpkg::Strings
std::vector<std::string> split(const std::string& s, const char delimiter);
+ const char* find_first_of(StringView searched, StringView candidates);
+
std::vector<StringView> find_all_enclosed(StringView input, StringView left_delim, StringView right_delim);
StringView find_exactly_one_enclosed(StringView input, StringView left_tag, StringView right_tag);
diff --git a/toolsrc/include/vcpkg/base/system.process.h b/toolsrc/include/vcpkg/base/system.process.h
index 0e6a92444..91faa5985 100644
--- a/toolsrc/include/vcpkg/base/system.process.h
+++ b/toolsrc/include/vcpkg/base/system.process.h
@@ -23,6 +23,18 @@ namespace vcpkg::System
const fs::path& cmake_script,
const std::vector<CMakeVariable>& pass_variables);
+ struct CmdLineBuilder
+ {
+ CmdLineBuilder& path_arg(const fs::path& p) { return string_arg(p.u8string()); }
+ CmdLineBuilder& string_arg(StringView s);
+ std::string extract() noexcept { return std::move(buf); }
+
+ operator ZStringView() const { return buf; }
+
+ private:
+ std::string buf;
+ };
+
fs::path get_exe_path_of_current_process();
struct ExitCodeAndOutput
diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h
index 89f2c51d6..a5b56028b 100644
--- a/toolsrc/include/vcpkg/base/util.h
+++ b/toolsrc/include/vcpkg/base/util.h
@@ -49,6 +49,19 @@ namespace vcpkg::Util
}
}
+ template<class Range, class Pred, class E = ElementT<Range>>
+ std::vector<E> filter(const Range& xs, Pred&& f)
+ {
+ std::vector<E> ret;
+
+ for (auto&& x : xs)
+ {
+ if (f(x)) ret.push_back(x);
+ }
+
+ return ret;
+ }
+
template<class Range, class Func>
using FmapOut = std::remove_reference_t<decltype(std::declval<Func&>()(*std::declval<Range>().begin()))>;
diff --git a/toolsrc/include/vcpkg/binarycaching.h b/toolsrc/include/vcpkg/binarycaching.h
index 88f529c22..d343d6c42 100644
--- a/toolsrc/include/vcpkg/binarycaching.h
+++ b/toolsrc/include/vcpkg/binarycaching.h
@@ -8,6 +8,7 @@
namespace vcpkg::Dependencies
{
struct InstallPlanAction;
+ struct ActionPlan;
}
namespace vcpkg::Build
{
@@ -27,10 +28,17 @@ namespace vcpkg
struct IBinaryProvider
{
virtual ~IBinaryProvider() = default;
- virtual void prefetch() = 0;
+ /// Gives the BinaryProvider an opportunity to batch any downloading or server communication for executing
+ /// `plan`.
+ virtual void prefetch(const VcpkgPaths& paths, const Dependencies::ActionPlan& plan) = 0;
+ /// Attempts to restore the package referenced by `action` into the packages directory.
virtual RestoreResult try_restore(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0;
+ /// Called upon a successful build of `action`
virtual void push_success(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) = 0;
+ /// Called upon a failure during the build of `action`
virtual void push_failure(const VcpkgPaths& paths, const std::string& abi_tag, const PackageSpec& spec) = 0;
+ /// Requests the result of `try_restore()` without actually downloading the package. Used by CI to determine
+ /// missing packages.
virtual RestoreResult precheck(const VcpkgPaths& paths,
const Dependencies::InstallPlanAction& action,
bool purge_tombstones) = 0;
@@ -42,4 +50,6 @@ namespace vcpkg
View<std::string> args);
ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs_pure(const std::string& env_string,
View<std::string> args);
+
+ void help_topic_binary_caching(const VcpkgPaths& paths);
}
diff --git a/toolsrc/include/vcpkg/binarycaching.private.h b/toolsrc/include/vcpkg/binarycaching.private.h
new file mode 100644
index 000000000..f1fd046de
--- /dev/null
+++ b/toolsrc/include/vcpkg/binarycaching.private.h
@@ -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();
+ };
+
+} \ No newline at end of file
diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h
index e2e28b08a..804cb6673 100644
--- a/toolsrc/include/vcpkg/build.h
+++ b/toolsrc/include/vcpkg/build.h
@@ -284,7 +284,8 @@ namespace vcpkg::Build
struct AbiInfo
{
std::unique_ptr<PreBuildInfo> pre_build_info;
- const Toolset* toolset;
+ Optional<const Toolset&> toolset;
+ Optional<const std::string&> triplet_abi;
std::string package_abi;
Optional<fs::path> abi_tag_file;
};
diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h
index 378aa9703..690245d08 100644
--- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h
+++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h
@@ -92,6 +92,7 @@ namespace vcpkg
void example(StringView example_text);
void header(StringView name);
void blank();
+ void text(StringView text, int indent = 0);
std::string m_str;
};