diff options
author | Brad King <brad.king@kitware.com> | 2018-09-13 12:48:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-12-12 11:40:10 (GMT) |
commit | 8fce59848b52f71ae310fcd64fcf943fb2c42bf6 (patch) | |
tree | 7e686c97356b70e6b26225b0db2e3528ee62c11e /Source/cmFileAPI.cxx | |
parent | eb2ec41a0422e9acd4961e32f6f28c20846a292a (diff) | |
download | CMake-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/cmFileAPI.cxx')
-rw-r--r-- | Source/cmFileAPI.cxx | 27 |
1 files changed, 25 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; |