diff options
author | Brad King <brad.king@kitware.com> | 2019-06-07 14:22:34 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-06-07 15:08:38 (GMT) |
commit | c932f498426609beb14b9339c2a7dec3ea624998 (patch) | |
tree | 42e9db048344d39a576abe368dd111ba2f4afa4d | |
parent | 6696855f72adebbb40d475c39dace1e9f855ca2a (diff) | |
download | CMake-c932f498426609beb14b9339c2a7dec3ea624998.zip CMake-c932f498426609beb14b9339c2a7dec3ea624998.tar.gz CMake-c932f498426609beb14b9339c2a7dec3ea624998.tar.bz2 |
cmake: Teach -E capabilities to report supported fileapi requests
Fixes: #19339
-rw-r--r-- | Help/manual/cmake-file-api.7.rst | 2 | ||||
-rw-r--r-- | Help/manual/cmake.1.rst | 16 | ||||
-rw-r--r-- | Source/cmFileAPI.cxx | 32 | ||||
-rw-r--r-- | Source/cmFileAPI.h | 3 | ||||
-rw-r--r-- | Source/cmake.cxx | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CommandLine/E_capabilities-stdout.txt | 2 |
6 files changed, 55 insertions, 1 deletions
diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst index f3e0208..04b6ed2 100644 --- a/Help/manual/cmake-file-api.7.rst +++ b/Help/manual/cmake-file-api.7.rst @@ -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 ============ diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index f1d02eb..13cba71 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -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. diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx index 9cb484c..ed45398 100644 --- a/Source/cmFileAPI.cxx +++ b/Source/cmFileAPI.cxx @@ -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; +} diff --git a/Source/cmFileAPI.h b/Source/cmFileAPI.h index 1315532..602efa8 100644 --- a/Source/cmFileAPI.h +++ b/Source/cmFileAPI.h @@ -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; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 0dca578..3772f09 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -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; diff --git a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt index 6c5ea44..b4b170e 100644 --- a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt +++ b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt @@ -1 +1 @@ -^{.*}$ +^{"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":{.*}}$ |