summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-09-13 12:48:29 (GMT)
committerBrad King <brad.king@kitware.com>2018-12-12 11:40:10 (GMT)
commit8fce59848b52f71ae310fcd64fcf943fb2c42bf6 (patch)
tree7e686c97356b70e6b26225b0db2e3528ee62c11e /Source
parenteb2ec41a0422e9acd4961e32f6f28c20846a292a (diff)
downloadCMake-8fce59848b52f71ae310fcd64fcf943fb2c42bf6.zip
CMake-8fce59848b52f71ae310fcd64fcf943fb2c42bf6.tar.gz
CMake-8fce59848b52f71ae310fcd64fcf943fb2c42bf6.tar.bz2
fileapi: Add protocol v1 support for client-specific query files
Add support for client-owned stateless query files. These allow clients to *own* requests for major object versions and get all those recognized by CMake. Issue: #18398
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFileAPI.cxx27
-rw-r--r--Source/cmFileAPI.h4
2 files changed, 29 insertions, 2 deletions
diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx
index 23e0ced..e401b58 100644
--- a/Source/cmFileAPI.cxx
+++ b/Source/cmFileAPI.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileAPI.h"
+#include "cmAlgorithms.h"
#include "cmCryptoHash.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
@@ -42,7 +43,9 @@ void cmFileAPI::ReadQueries()
// Read the queries and save for later.
for (std::string& query : queries) {
- if (!cmFileAPI::ReadQuery(query, this->TopQuery.Known)) {
+ if (cmHasLiteralPrefix(query, "client-")) {
+ this->ReadClient(query);
+ } else if (!cmFileAPI::ReadQuery(query, this->TopQuery.Known)) {
this->TopQuery.Unknown.push_back(std::move(query));
}
}
@@ -176,6 +179,21 @@ bool cmFileAPI::ReadQuery(std::string const& query,
return false;
}
+void cmFileAPI::ReadClient(std::string const& client)
+{
+ // Load queries for the client.
+ std::string clientDir = this->APIv1 + "/query/" + client;
+ std::vector<std::string> queries = this->LoadDir(clientDir);
+
+ // Read the queries and save for later.
+ Query& clientQuery = this->ClientQueries[client];
+ for (std::string& query : queries) {
+ if (!this->ReadQuery(query, clientQuery.Known)) {
+ clientQuery.Unknown.push_back(std::move(query));
+ }
+ }
+}
+
Json::Value cmFileAPI::BuildReplyIndex()
{
Json::Value index(Json::objectValue);
@@ -184,7 +202,12 @@ Json::Value cmFileAPI::BuildReplyIndex()
index["cmake"] = this->BuildCMake();
// Reply to all queries that we loaded.
- index["reply"] = this->BuildReply(this->TopQuery);
+ Json::Value& reply = index["reply"] = this->BuildReply(this->TopQuery);
+ for (auto const& client : this->ClientQueries) {
+ std::string const& clientName = client.first;
+ Query const& clientQuery = client.second;
+ reply[clientName] = this->BuildReply(clientQuery);
+ }
// Move our index of generated objects into its field.
Json::Value& objects = index["objects"] = Json::arrayValue;
diff --git a/Source/cmFileAPI.h b/Source/cmFileAPI.h
index 39b054d..589b837 100644
--- a/Source/cmFileAPI.h
+++ b/Source/cmFileAPI.h
@@ -77,6 +77,9 @@ private:
/** The content of the top-level query directory. */
Query TopQuery;
+ /** The content of each "client-$client" query directory. */
+ std::map<std::string, Query> ClientQueries;
+
/** Reply index object generated for object kind/version.
This populates the "objects" field of the reply index. */
std::map<Object, Json::Value> ReplyIndexObjects;
@@ -91,6 +94,7 @@ private:
static bool ReadQuery(std::string const& query,
std::vector<Object>& objects);
+ void ReadClient(std::string const& client);
Json::Value BuildReplyIndex();
Json::Value BuildCMake();