summaryrefslogtreecommitdiffstats
path: root/Source/cmFileAPI.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmFileAPI.cxx')
-rw-r--r--Source/cmFileAPI.cxx57
1 files changed, 57 insertions, 0 deletions
diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx
index b63349a..ec26268 100644
--- a/Source/cmFileAPI.cxx
+++ b/Source/cmFileAPI.cxx
@@ -4,6 +4,7 @@
#include "cmAlgorithms.h"
#include "cmCryptoHash.h"
+#include "cmFileAPICache.h"
#include "cmFileAPICodemodel.h"
#include "cmGlobalGenerator.h"
#include "cmSystemTools.h"
@@ -236,6 +237,17 @@ bool cmFileAPI::ReadQuery(std::string const& query,
objects.push_back(o);
return true;
}
+ if (kindName == ObjectKindName(ObjectKind::Cache)) {
+ Object o;
+ o.Kind = ObjectKind::Cache;
+ if (verStr == "v2") {
+ o.Version = 2;
+ } else {
+ return false;
+ }
+ objects.push_back(o);
+ return true;
+ }
if (kindName == ObjectKindName(ObjectKind::InternalTest)) {
Object o;
o.Kind = ObjectKind::InternalTest;
@@ -374,6 +386,7 @@ const char* cmFileAPI::ObjectKindName(ObjectKind kind)
// Keep in sync with ObjectKind enum.
static const char* objectKindNames[] = {
"codemodel", //
+ "cache", //
"__test" //
};
return objectKindNames[size_t(kind)];
@@ -395,6 +408,9 @@ Json::Value cmFileAPI::BuildObject(Object const& object)
case ObjectKind::CodeModel:
value = this->BuildCodeModel(object);
break;
+ case ObjectKind::Cache:
+ value = this->BuildCache(object);
+ break;
case ObjectKind::InternalTest:
value = this->BuildInternalTest(object);
break;
@@ -447,6 +463,8 @@ cmFileAPI::ClientRequest cmFileAPI::BuildClientRequest(
if (kindName == this->ObjectKindName(ObjectKind::CodeModel)) {
r.Kind = ObjectKind::CodeModel;
+ } else if (kindName == this->ObjectKindName(ObjectKind::Cache)) {
+ r.Kind = ObjectKind::Cache;
} else if (kindName == this->ObjectKindName(ObjectKind::InternalTest)) {
r.Kind = ObjectKind::InternalTest;
} else {
@@ -468,6 +486,9 @@ cmFileAPI::ClientRequest cmFileAPI::BuildClientRequest(
case ObjectKind::CodeModel:
this->BuildClientRequestCodeModel(r, versions);
break;
+ case ObjectKind::Cache:
+ this->BuildClientRequestCache(r, versions);
+ break;
case ObjectKind::InternalTest:
this->BuildClientRequestInternalTest(r, versions);
break;
@@ -649,6 +670,42 @@ Json::Value cmFileAPI::BuildCodeModel(Object const& object)
return codemodel;
}
+// The "cache" object kind.
+
+static unsigned int const CacheV2Minor = 0;
+
+void cmFileAPI::BuildClientRequestCache(
+ ClientRequest& r, std::vector<RequestVersion> const& versions)
+{
+ // Select a known version from those requested.
+ for (RequestVersion const& v : versions) {
+ if ((v.Major == 2 && v.Minor <= CacheV2Minor)) {
+ r.Version = v.Major;
+ break;
+ }
+ }
+ if (!r.Version) {
+ r.Error = NoSupportedVersion(versions);
+ }
+}
+
+Json::Value cmFileAPI::BuildCache(Object const& object)
+{
+ using namespace std::placeholders;
+ Json::Value cache = cmFileAPICacheDump(*this, object.Version);
+ cache["kind"] = this->ObjectKindName(object.Kind);
+
+ Json::Value& version = cache["version"] = Json::objectValue;
+ if (object.Version == 2) {
+ version["major"] = 2;
+ version["minor"] = CacheV2Minor;
+ } else {
+ return cache; // should be unreachable
+ }
+
+ return cache;
+}
+
// The "__test" object kind is for internal testing of CMake.
static unsigned int const InternalTestV1Minor = 3;