/src/CMake/Source/cmFileAPIConfigureLog.cxx
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #include "cmFileAPIConfigureLog.h" |
4 | | |
5 | | #include <cm3p/json/value.h> |
6 | | |
7 | | #include "cmFileAPI.h" |
8 | | #include "cmStringAlgorithms.h" |
9 | | #include "cmake.h" |
10 | | |
11 | | namespace { |
12 | | |
13 | | class ConfigureLog |
14 | | { |
15 | | cmFileAPI& FileAPI; |
16 | | unsigned int Version; |
17 | | |
18 | | Json::Value DumpPath(); |
19 | | Json::Value DumpEventKindNames(); |
20 | | |
21 | | public: |
22 | | ConfigureLog(cmFileAPI& fileAPI, unsigned int version); |
23 | | Json::Value Dump(); |
24 | | }; |
25 | | |
26 | | ConfigureLog::ConfigureLog(cmFileAPI& fileAPI, unsigned int version) |
27 | 0 | : FileAPI(fileAPI) |
28 | 0 | , Version(version) |
29 | 0 | { |
30 | 0 | static_cast<void>(this->Version); |
31 | 0 | } |
32 | | |
33 | | Json::Value ConfigureLog::Dump() |
34 | 0 | { |
35 | 0 | Json::Value configureLog = Json::objectValue; |
36 | 0 | configureLog["path"] = this->DumpPath(); |
37 | 0 | configureLog["eventKindNames"] = this->DumpEventKindNames(); |
38 | 0 | return configureLog; |
39 | 0 | } |
40 | | |
41 | | Json::Value ConfigureLog::DumpPath() |
42 | 0 | { |
43 | 0 | return cmStrCat(this->FileAPI.GetCMakeInstance()->GetHomeOutputDirectory(), |
44 | 0 | "/CMakeFiles/CMakeConfigureLog.yaml"); |
45 | 0 | } |
46 | | |
47 | | Json::Value ConfigureLog::DumpEventKindNames() |
48 | 0 | { |
49 | | // Report at most one version of each event kind. |
50 | | // If a new event kind is added, increment ConfigureLogV1Minor. |
51 | | // If a new version of an existing event kind is added, a new |
52 | | // major version of the configureLog object kind is needed. |
53 | 0 | Json::Value eventKindNames = Json::arrayValue; |
54 | 0 | if (this->Version == 1) { |
55 | 0 | eventKindNames.append("message-v1"); // WriteMessageEvent |
56 | 0 | eventKindNames.append("try_compile-v1"); // WriteTryCompileEvent |
57 | 0 | eventKindNames.append("try_run-v1"); // WriteTryRunEvent |
58 | 0 | eventKindNames.append("find-v1"); // WriteFindBaseEvent |
59 | 0 | eventKindNames.append("find_package-v1"); // WriteFindPackageEvent |
60 | 0 | } |
61 | 0 | return eventKindNames; |
62 | 0 | } |
63 | | } |
64 | | |
65 | | Json::Value cmFileAPIConfigureLogDump(cmFileAPI& fileAPI, unsigned int version) |
66 | 0 | { |
67 | 0 | ConfigureLog configureLog(fileAPI, version); |
68 | 0 | return configureLog.Dump(); |
69 | 0 | } |