Commit c932f498 authored by Brad King's avatar Brad King

cmake: Teach -E capabilities to report supported fileapi requests

Fixes: #19339
parent 6696855f
......@@ -379,6 +379,8 @@ finds the file missing, that means a concurrent CMake has generated
a new reply. The client may simply start again by reading the new
reply index file.
.. _`file-api object kinds`:
Object Kinds
============
......
......@@ -423,6 +423,22 @@ Available commands are:
A list of strings with all the extra generators compatible with
the generator.
``fileApi``
Optional member that is present when the :manual:`cmake-file-api(7)`
is available. The value is a JSON object with one member:
``requests``
A JSON array containing zero or more supported file-api requests.
Each request is a JSON object with members:
``kind``
Specifies one of the supported :ref:`file-api object kinds`.
``version``
A JSON array whose elements are each a JSON object containing
``major`` and ``minor`` members specifying non-negative integer
version components.
``serverMode``
``true`` if cmake supports server-mode and ``false`` otherwise.
......
......@@ -801,3 +801,35 @@ Json::Value cmFileAPI::BuildInternalTest(Object const& object)
}
return test;
}
Json::Value cmFileAPI::ReportCapabilities()
{
Json::Value capabilities = Json::objectValue;
Json::Value& requests = capabilities["requests"] = Json::arrayValue;
{
Json::Value request = Json::objectValue;
request["kind"] = ObjectKindName(ObjectKind::CodeModel);
Json::Value& versions = request["version"] = Json::arrayValue;
versions.append(BuildVersion(2, CodeModelV2Minor));
requests.append(std::move(request));
}
{
Json::Value request = Json::objectValue;
request["kind"] = ObjectKindName(ObjectKind::Cache);
Json::Value& versions = request["version"] = Json::arrayValue;
versions.append(BuildVersion(2, CacheV2Minor));
requests.append(std::move(request));
}
{
Json::Value request = Json::objectValue;
request["kind"] = ObjectKindName(ObjectKind::CMakeFiles);
Json::Value& versions = request["version"] = Json::arrayValue;
versions.append(BuildVersion(1, CMakeFilesV1Minor));
requests.append(std::move(request));
}
return capabilities;
}
......@@ -36,6 +36,9 @@ public:
and holding the original object. Other JSON types are unchanged. */
Json::Value MaybeJsonFile(Json::Value in, std::string const& prefix);
/** Report file-api capabilities for cmake -E capabilities. */
static Json::Value ReportCapabilities();
private:
cmake* CMakeInstance;
......
......@@ -284,6 +284,7 @@ Json::Value cmake::ReportCapabilitiesJson() const
generators.append(i.second);
}
obj["generators"] = generators;
obj["fileApi"] = cmFileAPI::ReportCapabilities();
obj["serverMode"] = true;
return obj;
......
^{.*}$
^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":0}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":true,"version":{.*}}$
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment