aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
authorras0219 <533828+ras0219@users.noreply.github.com>2020-08-13 18:36:33 -0700
committerGitHub <noreply@github.com>2020-08-13 18:36:33 -0700
commit0b5bbe30d940c597242cefa899dc93168054e466 (patch)
treea02a36758c8d4f794194dd37b48a7649fc143ee3 /toolsrc/include
parent5bb91a9452c2155e8ccd69c88629af24507249d4 (diff)
downloadvcpkg-0b5bbe30d940c597242cefa899dc93168054e466.tar.gz
vcpkg-0b5bbe30d940c597242cefa899dc93168054e466.zip
[vcpkg] Lift `--x-json` to a global option, implement experimental `x-package-info` command (#12845)
* [vcpkg] Improve error reporting in vcpkg::Json * [vcpkg] Lift --x-json to a common option * [vcpkg] Address warnings-as-errors in VS2015 * [vcpkg] Remove unused local * [vcpkg] Extract vcpkg::Install::get_cmake_usage * [vcpkg] Implement vcpkg::serialize_ipv(ipv, paths) * [vcpkg] Implement x-package-info to enable tooling * [vcpkg] Fixup tests to respect new cli mode Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg/base/json.h4
-rw-r--r--toolsrc/include/vcpkg/binaryparagraph.h2
-rw-r--r--toolsrc/include/vcpkg/commands.info.h13
-rw-r--r--toolsrc/include/vcpkg/install.h11
-rw-r--r--toolsrc/include/vcpkg/statusparagraph.h2
-rw-r--r--toolsrc/include/vcpkg/vcpkgcmdarguments.h4
6 files changed, 33 insertions, 3 deletions
diff --git a/toolsrc/include/vcpkg/base/json.h b/toolsrc/include/vcpkg/base/json.h
index b7adde38f..a4ad44ebd 100644
--- a/toolsrc/include/vcpkg/base/json.h
+++ b/toolsrc/include/vcpkg/base/json.h
@@ -227,13 +227,13 @@ namespace vcpkg::Json
Value& operator[](StringView key) noexcept
{
auto res = this->get(key);
- vcpkg::Checks::check_exit(VCPKG_LINE_INFO, res);
+ vcpkg::Checks::check_exit(VCPKG_LINE_INFO, res, "missing key: \"%s\"", key);
return *res;
}
const Value& operator[](StringView key) const noexcept
{
auto res = this->get(key);
- vcpkg::Checks::check_exit(VCPKG_LINE_INFO, res);
+ vcpkg::Checks::check_exit(VCPKG_LINE_INFO, res, "missing key: \"%s\"", key);
return *res;
}
diff --git a/toolsrc/include/vcpkg/binaryparagraph.h b/toolsrc/include/vcpkg/binaryparagraph.h
index 2d2e4cf20..f10c41af0 100644
--- a/toolsrc/include/vcpkg/binaryparagraph.h
+++ b/toolsrc/include/vcpkg/binaryparagraph.h
@@ -39,7 +39,7 @@ namespace vcpkg
std::vector<std::string> default_features;
std::vector<std::string> dependencies;
std::string abi;
- Type type;
+ Type type = {Type::UNKNOWN};
};
bool operator==(const BinaryParagraph&, const BinaryParagraph&);
diff --git a/toolsrc/include/vcpkg/commands.info.h b/toolsrc/include/vcpkg/commands.info.h
new file mode 100644
index 000000000..556d1eb01
--- /dev/null
+++ b/toolsrc/include/vcpkg/commands.info.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <vcpkg/commands.interface.h>
+
+namespace vcpkg::Commands::Info
+{
+ extern const CommandStructure COMMAND_STRUCTURE;
+
+ struct InfoCommand : PathsCommand
+ {
+ virtual void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) const override;
+ };
+}
diff --git a/toolsrc/include/vcpkg/install.h b/toolsrc/include/vcpkg/install.h
index 0ba0932e0..f85d48d8d 100644
--- a/toolsrc/include/vcpkg/install.h
+++ b/toolsrc/include/vcpkg/install.h
@@ -2,6 +2,7 @@
#include <vcpkg/base/chrono.h>
+#include <vcpkg/binaryparagraph.h>
#include <vcpkg/build.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgcmdarguments.h>
@@ -90,6 +91,16 @@ namespace vcpkg::Install
const Build::IBuildLogsRecorder& build_logs_recorder,
const CMakeVars::CMakeVarProvider& var_provider);
+ struct CMakeUsageInfo
+ {
+ std::string message;
+ bool usage_file = false;
+ Optional<bool> header_only;
+ std::map<std::string, std::vector<std::string>> cmake_targets_map;
+ };
+
+ CMakeUsageInfo get_cmake_usage(const BinaryParagraph& bpgh, const VcpkgPaths& paths);
+
extern const CommandStructure COMMAND_STRUCTURE;
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, Triplet default_triplet);
diff --git a/toolsrc/include/vcpkg/statusparagraph.h b/toolsrc/include/vcpkg/statusparagraph.h
index dde4ecb19..cf4c3c046 100644
--- a/toolsrc/include/vcpkg/statusparagraph.h
+++ b/toolsrc/include/vcpkg/statusparagraph.h
@@ -61,4 +61,6 @@ namespace vcpkg
const StatusParagraph* core;
std::vector<const StatusParagraph*> features;
};
+
+ Json::Value serialize_ipv(const InstalledPackageView& ipv, const struct VcpkgPaths& paths);
}
diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h
index 82c4f6dc2..84cd7c599 100644
--- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h
+++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h
@@ -153,6 +153,9 @@ namespace vcpkg
constexpr static StringLiteral WAIT_FOR_LOCK_SWITCH = "x-wait-for-lock";
Optional<bool> wait_for_lock = nullopt;
+ constexpr static StringLiteral JSON_SWITCH = "x-json";
+ Optional<bool> json = nullopt;
+
// feature flags
constexpr static StringLiteral FEATURE_FLAGS_ENV = "VCPKG_FEATURE_FLAGS";
constexpr static StringLiteral FEATURE_FLAGS_ARG = "feature-flags";
@@ -169,6 +172,7 @@ namespace vcpkg
bool binary_caching_enabled() const { return binary_caching.value_or(true); }
bool compiler_tracking_enabled() const { return compiler_tracking.value_or(true); }
+ bool output_json() const { return json.value_or(false); }
std::string command;
std::vector<std::string> command_arguments;