cmDebuggerVariablesHelper.cxx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmDebuggerVariablesHelper.h"
  4. #include <algorithm>
  5. #include <cstddef>
  6. #include <functional>
  7. #include <iomanip>
  8. #include <iterator>
  9. #include <map>
  10. #include <sstream>
  11. #include "cm_codecvt_Encoding.hxx"
  12. #include "cmDebuggerStackFrame.h"
  13. #include "cmDebuggerVariables.h"
  14. #include "cmFileSet.h"
  15. #include "cmGlobalGenerator.h"
  16. #include "cmList.h"
  17. #include "cmListFileCache.h"
  18. #include "cmMakefile.h"
  19. #include "cmPropertyMap.h"
  20. #include "cmState.h"
  21. #include "cmStateSnapshot.h"
  22. #include "cmTarget.h"
  23. #include "cmTest.h"
  24. #include "cmValue.h"
  25. #include "cmake.h"
  26. namespace cmDebugger {
  27. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::Create(
  28. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  29. std::string const& name, bool supportsVariableType,
  30. cmPolicies::PolicyMap const& policyMap)
  31. {
  32. static std::map<cmPolicies::PolicyStatus, std::string> policyStatusString = {
  33. { cmPolicies::PolicyStatus::OLD, "OLD" },
  34. { cmPolicies::PolicyStatus::WARN, "WARN" },
  35. { cmPolicies::PolicyStatus::NEW, "NEW" },
  36. { cmPolicies::PolicyStatus::REQUIRED_IF_USED, "REQUIRED_IF_USED" },
  37. { cmPolicies::PolicyStatus::REQUIRED_ALWAYS, "REQUIRED_ALWAYS" }
  38. };
  39. return std::make_shared<cmDebuggerVariables>(
  40. variablesManager, name, supportsVariableType, [=]() {
  41. std::vector<cmDebuggerVariableEntry> ret;
  42. ret.reserve(cmPolicies::CMPCOUNT);
  43. for (int i = 0; i < cmPolicies::CMPCOUNT; ++i) {
  44. if (policyMap.IsDefined(static_cast<cmPolicies::PolicyID>(i))) {
  45. auto status = policyMap.Get(static_cast<cmPolicies::PolicyID>(i));
  46. std::ostringstream ss;
  47. ss << "CMP" << std::setfill('0') << std::setw(4) << i;
  48. ret.emplace_back(ss.str(), policyStatusString[status]);
  49. }
  50. }
  51. return ret;
  52. });
  53. }
  54. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  55. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  56. std::string const& name, bool supportsVariableType,
  57. std::vector<std::pair<std::string, std::string>> const& list)
  58. {
  59. if (list.empty()) {
  60. return {};
  61. }
  62. auto listVariables = std::make_shared<cmDebuggerVariables>(
  63. variablesManager, name, supportsVariableType, [=]() {
  64. std::vector<cmDebuggerVariableEntry> ret;
  65. ret.reserve(list.size());
  66. for (auto const& kv : list) {
  67. ret.emplace_back(kv.first, kv.second);
  68. }
  69. return ret;
  70. });
  71. listVariables->SetValue(std::to_string(list.size()));
  72. return listVariables;
  73. }
  74. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  75. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  76. std::string const& name, bool supportsVariableType,
  77. cmBTStringRange const& entries)
  78. {
  79. if (entries.empty()) {
  80. return {};
  81. }
  82. auto sourceEntries = std::make_shared<cmDebuggerVariables>(
  83. variablesManager, name, supportsVariableType);
  84. for (auto const& entry : entries) {
  85. auto arrayVariables = std::make_shared<cmDebuggerVariables>(
  86. variablesManager, entry.Value, supportsVariableType, [=]() {
  87. cmList items{ entry.Value };
  88. std::vector<cmDebuggerVariableEntry> ret;
  89. ret.reserve(items.size());
  90. int i = 0;
  91. for (std::string const& item : items) {
  92. ret.emplace_back("[" + std::to_string(i++) + "]", item);
  93. }
  94. return ret;
  95. });
  96. arrayVariables->SetEnableSorting(false);
  97. sourceEntries->AddSubVariables(arrayVariables);
  98. }
  99. sourceEntries->SetValue(std::to_string(entries.size()));
  100. return sourceEntries;
  101. }
  102. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  103. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  104. std::string const& name, bool supportsVariableType,
  105. std::set<std::string> const& values)
  106. {
  107. if (values.empty()) {
  108. return {};
  109. }
  110. auto arrayVariables = std::make_shared<cmDebuggerVariables>(
  111. variablesManager, name, supportsVariableType, [=]() {
  112. std::vector<cmDebuggerVariableEntry> ret;
  113. ret.reserve(values.size());
  114. int i = 0;
  115. for (std::string const& value : values) {
  116. ret.emplace_back("[" + std::to_string(i++) + "]", value);
  117. }
  118. return ret;
  119. });
  120. arrayVariables->SetValue(std::to_string(values.size()));
  121. arrayVariables->SetEnableSorting(false);
  122. return arrayVariables;
  123. }
  124. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  125. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  126. std::string const& name, bool supportsVariableType,
  127. std::vector<std::string> const& values)
  128. {
  129. if (values.empty()) {
  130. return {};
  131. }
  132. auto arrayVariables = std::make_shared<cmDebuggerVariables>(
  133. variablesManager, name, supportsVariableType, [=]() {
  134. std::vector<cmDebuggerVariableEntry> ret;
  135. ret.reserve(values.size());
  136. int i = 0;
  137. for (std::string const& value : values) {
  138. ret.emplace_back("[" + std::to_string(i++) + "]", value);
  139. }
  140. return ret;
  141. });
  142. arrayVariables->SetValue(std::to_string(values.size()));
  143. arrayVariables->SetEnableSorting(false);
  144. return arrayVariables;
  145. }
  146. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  147. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  148. std::string const& name, bool supportsVariableType,
  149. std::vector<BT<std::string>> const& list)
  150. {
  151. if (list.empty()) {
  152. return {};
  153. }
  154. auto variables = std::make_shared<cmDebuggerVariables>(
  155. variablesManager, name, supportsVariableType, [=]() {
  156. std::vector<cmDebuggerVariableEntry> ret;
  157. ret.reserve(list.size());
  158. int i = 0;
  159. for (auto const& item : list) {
  160. ret.emplace_back("[" + std::to_string(i++) + "]", item.Value);
  161. }
  162. return ret;
  163. });
  164. variables->SetValue(std::to_string(list.size()));
  165. variables->SetEnableSorting(false);
  166. return variables;
  167. }
  168. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  169. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  170. std::string const& name, bool supportsVariableType, cmFileSet* fileSet)
  171. {
  172. if (!fileSet) {
  173. return {};
  174. }
  175. static auto visibilityString = [](cmFileSetVisibility visibility) {
  176. switch (visibility) {
  177. case cmFileSetVisibility::Private:
  178. return "Private";
  179. case cmFileSetVisibility::Public:
  180. return "Public";
  181. case cmFileSetVisibility::Interface:
  182. return "Interface";
  183. default:
  184. return "Unknown";
  185. }
  186. };
  187. auto variables = std::make_shared<cmDebuggerVariables>(
  188. variablesManager, name, supportsVariableType, [=]() {
  189. std::vector<cmDebuggerVariableEntry> ret{
  190. { "Name", fileSet->GetName() },
  191. { "Type", fileSet->GetType() },
  192. { "Visibility", visibilityString(fileSet->GetVisibility()) },
  193. };
  194. return ret;
  195. });
  196. variables->AddSubVariables(CreateIfAny(variablesManager, "Directories",
  197. supportsVariableType,
  198. fileSet->GetDirectoryEntries()));
  199. variables->AddSubVariables(CreateIfAny(variablesManager, "Files",
  200. supportsVariableType,
  201. fileSet->GetFileEntries()));
  202. return variables;
  203. }
  204. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  205. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  206. std::string const& name, bool supportsVariableType,
  207. std::vector<cmFileSet*> const& fileSets)
  208. {
  209. if (fileSets.empty()) {
  210. return {};
  211. }
  212. auto fileSetsVariables = std::make_shared<cmDebuggerVariables>(
  213. variablesManager, name, supportsVariableType);
  214. for (auto const& fileSet : fileSets) {
  215. fileSetsVariables->AddSubVariables(CreateIfAny(
  216. variablesManager, fileSet->GetName(), supportsVariableType, fileSet));
  217. }
  218. return fileSetsVariables;
  219. }
  220. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  221. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  222. std::string const& name, bool supportsVariableType,
  223. std::vector<cmTarget*> const& targets)
  224. {
  225. if (targets.empty()) {
  226. return {};
  227. }
  228. auto targetsVariables = std::make_shared<cmDebuggerVariables>(
  229. variablesManager, name, supportsVariableType);
  230. for (auto const& target : targets) {
  231. auto targetVariables = std::make_shared<cmDebuggerVariables>(
  232. variablesManager, target->GetName(), supportsVariableType, [=]() {
  233. std::vector<cmDebuggerVariableEntry> ret = {
  234. { "InstallPath", target->GetInstallPath() },
  235. { "IsAIX", target->IsAIX() },
  236. { "IsAndroidGuiExecutable", target->IsAndroidGuiExecutable() },
  237. { "IsAppBundleOnApple", target->IsAppBundleOnApple() },
  238. { "IsDLLPlatform", target->IsDLLPlatform() },
  239. { "IsExecutableWithExports", target->IsExecutableWithExports() },
  240. { "IsFrameworkOnApple", target->IsFrameworkOnApple() },
  241. { "IsImported", target->IsImported() },
  242. { "IsImportedGloballyVisible", target->IsImportedGloballyVisible() },
  243. { "IsPerConfig", target->IsPerConfig() },
  244. { "Name", target->GetName() },
  245. { "RuntimeInstallPath", target->GetRuntimeInstallPath() },
  246. { "Type", cmState::GetTargetTypeName(target->GetType()) },
  247. };
  248. return ret;
  249. });
  250. targetVariables->SetValue(cmState::GetTargetTypeName(target->GetType()));
  251. targetVariables->AddSubVariables(Create(variablesManager, "PolicyMap",
  252. supportsVariableType,
  253. target->GetPolicyMap()));
  254. targetVariables->AddSubVariables(
  255. CreateIfAny(variablesManager, "Properties", supportsVariableType,
  256. target->GetProperties().GetList()));
  257. targetVariables->AddSubVariables(
  258. CreateIfAny(variablesManager, "IncludeDirectories", supportsVariableType,
  259. target->GetIncludeDirectoriesEntries()));
  260. targetVariables->AddSubVariables(CreateIfAny(variablesManager, "Sources",
  261. supportsVariableType,
  262. target->GetSourceEntries()));
  263. targetVariables->AddSubVariables(
  264. CreateIfAny(variablesManager, "CompileDefinitions", supportsVariableType,
  265. target->GetCompileDefinitionsEntries()));
  266. targetVariables->AddSubVariables(
  267. CreateIfAny(variablesManager, "CompileFeatures", supportsVariableType,
  268. target->GetCompileFeaturesEntries()));
  269. targetVariables->AddSubVariables(
  270. CreateIfAny(variablesManager, "CompileOptions", supportsVariableType,
  271. target->GetCompileOptionsEntries()));
  272. targetVariables->AddSubVariables(
  273. CreateIfAny(variablesManager, "CxxModuleSets", supportsVariableType,
  274. target->GetCxxModuleSetsEntries()));
  275. targetVariables->AddSubVariables(
  276. CreateIfAny(variablesManager, "HeaderSets", supportsVariableType,
  277. target->GetHeaderSetsEntries()));
  278. targetVariables->AddSubVariables(CreateIfAny(
  279. variablesManager, "InterfaceHeaderSets", supportsVariableType,
  280. target->GetInterfaceHeaderSetsEntries()));
  281. targetVariables->AddSubVariables(
  282. CreateIfAny(variablesManager, "LinkDirectories", supportsVariableType,
  283. target->GetLinkDirectoriesEntries()));
  284. targetVariables->AddSubVariables(CreateIfAny(
  285. variablesManager, "LinkImplementations", supportsVariableType,
  286. target->GetLinkImplementationEntries()));
  287. targetVariables->AddSubVariables(CreateIfAny(
  288. variablesManager, "LinkInterfaceDirects", supportsVariableType,
  289. target->GetLinkInterfaceDirectEntries()));
  290. targetVariables->AddSubVariables(CreateIfAny(
  291. variablesManager, "LinkInterfaceDirectExcludes", supportsVariableType,
  292. target->GetLinkInterfaceDirectExcludeEntries()));
  293. targetVariables->AddSubVariables(
  294. CreateIfAny(variablesManager, "LinkInterfaces", supportsVariableType,
  295. target->GetLinkInterfaceEntries()));
  296. targetVariables->AddSubVariables(
  297. CreateIfAny(variablesManager, "LinkOptions", supportsVariableType,
  298. target->GetLinkOptionsEntries()));
  299. targetVariables->AddSubVariables(CreateIfAny(
  300. variablesManager, "SystemIncludeDirectories", supportsVariableType,
  301. target->GetSystemIncludeDirectories()));
  302. targetVariables->AddSubVariables(CreateIfAny(variablesManager, "Makefile",
  303. supportsVariableType,
  304. target->GetMakefile()));
  305. targetVariables->AddSubVariables(
  306. CreateIfAny(variablesManager, "GlobalGenerator", supportsVariableType,
  307. target->GetGlobalGenerator()));
  308. std::vector<cmFileSet*> allFileSets;
  309. auto allFileSetNames = target->GetAllFileSetNames();
  310. allFileSets.reserve(allFileSetNames.size());
  311. for (auto const& fileSetName : allFileSetNames) {
  312. allFileSets.emplace_back(target->GetFileSet(fileSetName));
  313. }
  314. targetVariables->AddSubVariables(CreateIfAny(
  315. variablesManager, "AllFileSets", supportsVariableType, allFileSets));
  316. std::vector<cmFileSet*> allInterfaceFileSets;
  317. auto allInterfaceFileSetNames = target->GetAllInterfaceFileSets();
  318. allInterfaceFileSets.reserve(allInterfaceFileSetNames.size());
  319. for (auto const& interfaceFileSetName : allInterfaceFileSetNames) {
  320. allInterfaceFileSets.emplace_back(
  321. target->GetFileSet(interfaceFileSetName));
  322. }
  323. targetVariables->AddSubVariables(
  324. CreateIfAny(variablesManager, "AllInterfaceFileSets",
  325. supportsVariableType, allInterfaceFileSets));
  326. targetVariables->SetIgnoreEmptyStringEntries(true);
  327. targetsVariables->AddSubVariables(targetVariables);
  328. }
  329. targetsVariables->SetValue(std::to_string(targets.size()));
  330. return targetsVariables;
  331. }
  332. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::Create(
  333. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  334. std::string const& name, bool supportsVariableType,
  335. std::shared_ptr<cmDebuggerStackFrame> const& frame)
  336. {
  337. auto variables = std::make_shared<cmDebuggerVariables>(
  338. variablesManager, name, supportsVariableType, [=]() {
  339. return std::vector<cmDebuggerVariableEntry>{ { "CurrentLine",
  340. frame->GetLine() } };
  341. });
  342. auto closureKeys = frame->GetMakefile()->GetStateSnapshot().ClosureKeys();
  343. auto locals = std::make_shared<cmDebuggerVariables>(
  344. variablesManager, "Locals", supportsVariableType, [=]() {
  345. std::vector<cmDebuggerVariableEntry> ret;
  346. ret.reserve(closureKeys.size());
  347. for (auto const& key : closureKeys) {
  348. ret.emplace_back(
  349. key, frame->GetMakefile()->GetStateSnapshot().GetDefinition(key));
  350. }
  351. return ret;
  352. });
  353. locals->SetValue(std::to_string(closureKeys.size()));
  354. variables->AddSubVariables(locals);
  355. std::function<bool(std::string const&)> isDirectory =
  356. [](std::string const& key) {
  357. size_t pos1 = key.rfind("_DIR");
  358. size_t pos2 = key.rfind("_DIRECTORY");
  359. return !((pos1 == std::string::npos || pos1 != key.size() - 4) &&
  360. (pos2 == std::string::npos || pos2 != key.size() - 10));
  361. };
  362. auto directorySize =
  363. std::count_if(closureKeys.begin(), closureKeys.end(), isDirectory);
  364. auto directories = std::make_shared<cmDebuggerVariables>(
  365. variablesManager, "Directories", supportsVariableType, [=]() {
  366. std::vector<cmDebuggerVariableEntry> ret;
  367. ret.reserve(directorySize);
  368. for (auto const& key : closureKeys) {
  369. if (isDirectory(key)) {
  370. ret.emplace_back(
  371. key, frame->GetMakefile()->GetStateSnapshot().GetDefinition(key));
  372. }
  373. }
  374. return ret;
  375. });
  376. directories->SetValue(std::to_string(directorySize));
  377. variables->AddSubVariables(directories);
  378. auto cacheVariables = std::make_shared<cmDebuggerVariables>(
  379. variablesManager, "CacheVariables", supportsVariableType);
  380. auto* state = frame->GetMakefile()->GetCMakeInstance()->GetState();
  381. auto keys = state->GetCacheEntryKeys();
  382. for (auto const& key : keys) {
  383. auto entry = std::make_shared<cmDebuggerVariables>(
  384. variablesManager,
  385. key + ":" +
  386. cmState::CacheEntryTypeToString(state->GetCacheEntryType(key)),
  387. supportsVariableType, [=]() {
  388. std::vector<cmDebuggerVariableEntry> ret;
  389. auto properties = state->GetCacheEntryPropertyList(key);
  390. ret.reserve(properties.size() + 2);
  391. for (auto const& propertyName : properties) {
  392. ret.emplace_back(propertyName,
  393. state->GetCacheEntryProperty(key, propertyName));
  394. }
  395. ret.emplace_back(
  396. "TYPE",
  397. cmState::CacheEntryTypeToString(state->GetCacheEntryType(key)));
  398. ret.emplace_back("VALUE", state->GetCacheEntryValue(key));
  399. return ret;
  400. });
  401. entry->SetValue(state->GetCacheEntryValue(key));
  402. cacheVariables->AddSubVariables(entry);
  403. }
  404. cacheVariables->SetValue(std::to_string(keys.size()));
  405. variables->AddSubVariables(cacheVariables);
  406. auto targetVariables =
  407. CreateIfAny(variablesManager, "Targets", supportsVariableType,
  408. frame->GetMakefile()->GetOrderedTargets());
  409. variables->AddSubVariables(targetVariables);
  410. std::vector<cmTest*> tests;
  411. frame->GetMakefile()->GetTests(
  412. frame->GetMakefile()->GetDefaultConfiguration(), tests);
  413. variables->AddSubVariables(
  414. CreateIfAny(variablesManager, "Tests", supportsVariableType, tests));
  415. return variables;
  416. }
  417. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  418. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  419. std::string const& name, bool supportsVariableType, cmTest* test)
  420. {
  421. if (!test) {
  422. return {};
  423. }
  424. auto variables = std::make_shared<cmDebuggerVariables>(
  425. variablesManager, name, supportsVariableType, [=]() {
  426. std::vector<cmDebuggerVariableEntry> ret{
  427. { "CommandExpandLists", test->GetCommandExpandLists() },
  428. { "Name", test->GetName() },
  429. { "OldStyle", test->GetOldStyle() },
  430. };
  431. return ret;
  432. });
  433. variables->AddSubVariables(CreateIfAny(
  434. variablesManager, "Command", supportsVariableType, test->GetCommand()));
  435. variables->AddSubVariables(CreateIfAny(variablesManager, "Properties",
  436. supportsVariableType,
  437. test->GetProperties().GetList()));
  438. return variables;
  439. }
  440. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  441. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  442. std::string const& name, bool supportsVariableType,
  443. std::vector<cmTest*> const& tests)
  444. {
  445. if (tests.empty()) {
  446. return {};
  447. }
  448. auto variables = std::make_shared<cmDebuggerVariables>(
  449. variablesManager, name, supportsVariableType);
  450. for (auto const& test : tests) {
  451. variables->AddSubVariables(CreateIfAny(variablesManager, test->GetName(),
  452. supportsVariableType, test));
  453. }
  454. variables->SetValue(std::to_string(tests.size()));
  455. return variables;
  456. }
  457. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  458. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  459. std::string const& name, bool supportsVariableType, cmMakefile* mf)
  460. {
  461. if (!mf) {
  462. return {};
  463. }
  464. auto AppleSDKTypeString = [&](cmMakefile::AppleSDK sdk) {
  465. switch (sdk) {
  466. case cmMakefile::AppleSDK::MacOS:
  467. return "MacOS";
  468. case cmMakefile::AppleSDK::IPhoneOS:
  469. return "IPhoneOS";
  470. case cmMakefile::AppleSDK::IPhoneSimulator:
  471. return "IPhoneSimulator";
  472. case cmMakefile::AppleSDK::AppleTVOS:
  473. return "AppleTVOS";
  474. case cmMakefile::AppleSDK::AppleTVSimulator:
  475. return "AppleTVSimulator";
  476. default:
  477. return "Unknown";
  478. }
  479. };
  480. auto variables = std::make_shared<cmDebuggerVariables>(
  481. variablesManager, name, supportsVariableType, [=]() {
  482. std::vector<cmDebuggerVariableEntry> ret = {
  483. { "DefineFlags", mf->GetDefineFlags() },
  484. { "DirectoryId", mf->GetDirectoryId().String },
  485. { "IsRootMakefile", mf->IsRootMakefile() },
  486. { "HomeDirectory", mf->GetHomeDirectory() },
  487. { "HomeOutputDirectory", mf->GetHomeOutputDirectory() },
  488. { "CurrentSourceDirectory", mf->GetCurrentSourceDirectory() },
  489. { "CurrentBinaryDirectory", mf->GetCurrentBinaryDirectory() },
  490. { "PlatformIs32Bit", mf->PlatformIs32Bit() },
  491. { "PlatformIs64Bit", mf->PlatformIs64Bit() },
  492. { "PlatformIsx32", mf->PlatformIsx32() },
  493. { "AppleSDKType", AppleSDKTypeString(mf->GetAppleSDKType()) },
  494. { "PlatformIsAppleEmbedded", mf->PlatformIsAppleEmbedded() }
  495. };
  496. return ret;
  497. });
  498. variables->AddSubVariables(CreateIfAny(
  499. variablesManager, "ListFiles", supportsVariableType, mf->GetListFiles()));
  500. variables->AddSubVariables(CreateIfAny(variablesManager, "OutputFiles",
  501. supportsVariableType,
  502. mf->GetOutputFiles()));
  503. variables->SetIgnoreEmptyStringEntries(true);
  504. variables->SetValue(mf->GetDirectoryId().String);
  505. return variables;
  506. }
  507. std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
  508. std::shared_ptr<cmDebuggerVariablesManager> const& variablesManager,
  509. std::string const& name, bool supportsVariableType, cmGlobalGenerator* gen)
  510. {
  511. if (!gen) {
  512. return {};
  513. }
  514. auto makeFileEncodingString = [](codecvt_Encoding encoding) {
  515. switch (encoding) {
  516. case codecvt_Encoding::None:
  517. return "None";
  518. case codecvt_Encoding::UTF8:
  519. return "UTF8";
  520. case codecvt_Encoding::UTF8_WITH_BOM:
  521. return "UTF8_WITH_BOM";
  522. case codecvt_Encoding::ANSI:
  523. return "ANSI";
  524. case codecvt_Encoding::ConsoleOutput:
  525. return "ConsoleOutput";
  526. default:
  527. return "Unknown";
  528. }
  529. };
  530. auto variables = std::make_shared<cmDebuggerVariables>(
  531. variablesManager, name, supportsVariableType, [=]() {
  532. std::vector<cmDebuggerVariableEntry> ret = {
  533. { "AllTargetName", gen->GetAllTargetName() },
  534. { "CleanTargetName", gen->GetCleanTargetName() },
  535. { "EditCacheCommand", gen->GetEditCacheCommand() },
  536. { "EditCacheTargetName", gen->GetEditCacheTargetName() },
  537. { "ExtraGeneratorName", gen->GetExtraGeneratorName() },
  538. { "ForceUnixPaths", gen->GetForceUnixPaths() },
  539. { "InstallLocalTargetName", gen->GetInstallLocalTargetName() },
  540. { "InstallStripTargetName", gen->GetInstallStripTargetName() },
  541. { "InstallTargetName", gen->GetInstallTargetName() },
  542. { "IsMultiConfig", gen->IsMultiConfig() },
  543. { "Name", gen->GetName() },
  544. { "MakefileEncoding",
  545. makeFileEncodingString(gen->GetMakefileEncoding()) },
  546. { "PackageSourceTargetName", gen->GetPackageSourceTargetName() },
  547. { "PackageTargetName", gen->GetPackageTargetName() },
  548. { "PreinstallTargetName", gen->GetPreinstallTargetName() },
  549. { "NeedSymbolicMark", gen->GetNeedSymbolicMark() },
  550. { "RebuildCacheTargetName", gen->GetRebuildCacheTargetName() },
  551. { "TestTargetName", gen->GetTestTargetName() },
  552. { "UseLinkScript", gen->GetUseLinkScript() },
  553. };
  554. return ret;
  555. });
  556. if (const auto* ic = gen->GetInstallComponents()) {
  557. variables->AddSubVariables(CreateIfAny(
  558. variablesManager, "InstallComponents", supportsVariableType, *ic));
  559. }
  560. variables->SetIgnoreEmptyStringEntries(true);
  561. variables->SetValue(gen->GetName());
  562. return variables;
  563. }
  564. } // namespace cmDebugger