cmServerProtocol.cxx 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234
  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 "cmServerProtocol.h"
  4. #include "cmAlgorithms.h"
  5. #include "cmExternalMakefileProjectGenerator.h"
  6. #include "cmFileMonitor.h"
  7. #include "cmGeneratorExpression.h"
  8. #include "cmGeneratorTarget.h"
  9. #include "cmGlobalGenerator.h"
  10. #include "cmLinkLineComputer.h"
  11. #include "cmListFileCache.h"
  12. #include "cmLocalGenerator.h"
  13. #include "cmMakefile.h"
  14. #include "cmServer.h"
  15. #include "cmServerDictionary.h"
  16. #include "cmSourceFile.h"
  17. #include "cmState.h"
  18. #include "cmStateDirectory.h"
  19. #include "cmStateSnapshot.h"
  20. #include "cmStateTypes.h"
  21. #include "cmSystemTools.h"
  22. #include "cmTarget.h"
  23. #include "cm_uv.h"
  24. #include "cmake.h"
  25. #include <algorithm>
  26. #include <cassert>
  27. #include <cstddef>
  28. #include <functional>
  29. #include <limits>
  30. #include <map>
  31. #include <set>
  32. #include <string>
  33. #include <unordered_map>
  34. #include <vector>
  35. // Get rid of some windows macros:
  36. #undef max
  37. namespace {
  38. std::vector<std::string> getConfigurations(const cmake* cm)
  39. {
  40. std::vector<std::string> configurations;
  41. auto makefiles = cm->GetGlobalGenerator()->GetMakefiles();
  42. if (makefiles.empty()) {
  43. return configurations;
  44. }
  45. makefiles[0]->GetConfigurations(configurations);
  46. if (configurations.empty()) {
  47. configurations.push_back("");
  48. }
  49. return configurations;
  50. }
  51. bool hasString(const Json::Value& v, const std::string& s)
  52. {
  53. return !v.isNull() &&
  54. std::any_of(v.begin(), v.end(),
  55. [s](const Json::Value& i) { return i.asString() == s; });
  56. }
  57. template <class T>
  58. Json::Value fromStringList(const T& in)
  59. {
  60. Json::Value result = Json::arrayValue;
  61. for (const std::string& i : in) {
  62. result.append(i);
  63. }
  64. return result;
  65. }
  66. std::vector<std::string> toStringList(const Json::Value& in)
  67. {
  68. std::vector<std::string> result;
  69. for (const auto& it : in) {
  70. result.push_back(it.asString());
  71. }
  72. return result;
  73. }
  74. void getCMakeInputs(const cmGlobalGenerator* gg, const std::string& sourceDir,
  75. const std::string& buildDir,
  76. std::vector<std::string>* internalFiles,
  77. std::vector<std::string>* explicitFiles,
  78. std::vector<std::string>* tmpFiles)
  79. {
  80. const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/';
  81. std::vector<cmMakefile*> const& makefiles = gg->GetMakefiles();
  82. for (auto it = makefiles.begin(); it != makefiles.end(); ++it) {
  83. const std::vector<std::string> listFiles = (*it)->GetListFiles();
  84. for (auto jt = listFiles.begin(); jt != listFiles.end(); ++jt) {
  85. const std::string startOfFile = jt->substr(0, cmakeRootDir.size());
  86. const bool isInternal = (startOfFile == cmakeRootDir);
  87. const bool isTemporary = !isInternal && (jt->find(buildDir + '/') == 0);
  88. std::string toAdd = *jt;
  89. if (!sourceDir.empty()) {
  90. const std::string& relative =
  91. cmSystemTools::RelativePath(sourceDir.c_str(), jt->c_str());
  92. if (toAdd.size() > relative.size()) {
  93. toAdd = relative;
  94. }
  95. }
  96. if (isInternal) {
  97. if (internalFiles) {
  98. internalFiles->push_back(toAdd);
  99. }
  100. } else {
  101. if (isTemporary) {
  102. if (tmpFiles) {
  103. tmpFiles->push_back(toAdd);
  104. }
  105. } else {
  106. if (explicitFiles) {
  107. explicitFiles->push_back(toAdd);
  108. }
  109. }
  110. }
  111. }
  112. }
  113. }
  114. } // namespace
  115. cmServerRequest::cmServerRequest(cmServer* server, cmConnection* connection,
  116. const std::string& t, const std::string& c,
  117. const Json::Value& d)
  118. : Type(t)
  119. , Cookie(c)
  120. , Data(d)
  121. , Connection(connection)
  122. , m_Server(server)
  123. {
  124. }
  125. void cmServerRequest::ReportProgress(int min, int current, int max,
  126. const std::string& message) const
  127. {
  128. this->m_Server->WriteProgress(*this, min, current, max, message);
  129. }
  130. void cmServerRequest::ReportMessage(const std::string& message,
  131. const std::string& title) const
  132. {
  133. m_Server->WriteMessage(*this, message, title);
  134. }
  135. cmServerResponse cmServerRequest::Reply(const Json::Value& data) const
  136. {
  137. cmServerResponse response(*this);
  138. response.SetData(data);
  139. return response;
  140. }
  141. cmServerResponse cmServerRequest::ReportError(const std::string& message) const
  142. {
  143. cmServerResponse response(*this);
  144. response.SetError(message);
  145. return response;
  146. }
  147. cmServerResponse::cmServerResponse(const cmServerRequest& request)
  148. : Type(request.Type)
  149. , Cookie(request.Cookie)
  150. {
  151. }
  152. void cmServerResponse::SetData(const Json::Value& data)
  153. {
  154. assert(this->m_Payload == PAYLOAD_UNKNOWN);
  155. if (!data[kCOOKIE_KEY].isNull() || !data[kTYPE_KEY].isNull()) {
  156. this->SetError("Response contains cookie or type field.");
  157. return;
  158. }
  159. this->m_Payload = PAYLOAD_DATA;
  160. this->m_Data = data;
  161. }
  162. void cmServerResponse::SetError(const std::string& message)
  163. {
  164. assert(this->m_Payload == PAYLOAD_UNKNOWN);
  165. this->m_Payload = PAYLOAD_ERROR;
  166. this->m_ErrorMessage = message;
  167. }
  168. bool cmServerResponse::IsComplete() const
  169. {
  170. return this->m_Payload != PAYLOAD_UNKNOWN;
  171. }
  172. bool cmServerResponse::IsError() const
  173. {
  174. assert(this->m_Payload != PAYLOAD_UNKNOWN);
  175. return this->m_Payload == PAYLOAD_ERROR;
  176. }
  177. std::string cmServerResponse::ErrorMessage() const
  178. {
  179. if (this->m_Payload == PAYLOAD_ERROR) {
  180. return this->m_ErrorMessage;
  181. }
  182. return std::string();
  183. }
  184. Json::Value cmServerResponse::Data() const
  185. {
  186. assert(this->m_Payload != PAYLOAD_UNKNOWN);
  187. return this->m_Data;
  188. }
  189. bool cmServerProtocol::Activate(cmServer* server,
  190. const cmServerRequest& request,
  191. std::string* errorMessage)
  192. {
  193. assert(server);
  194. this->m_Server = server;
  195. this->m_CMakeInstance = std::make_unique<cmake>(cmake::RoleProject);
  196. const bool result = this->DoActivate(request, errorMessage);
  197. if (!result) {
  198. this->m_CMakeInstance = CM_NULLPTR;
  199. }
  200. return result;
  201. }
  202. cmFileMonitor* cmServerProtocol::FileMonitor() const
  203. {
  204. return this->m_Server ? this->m_Server->FileMonitor() : nullptr;
  205. }
  206. void cmServerProtocol::SendSignal(const std::string& name,
  207. const Json::Value& data) const
  208. {
  209. if (this->m_Server) {
  210. this->m_Server->WriteSignal(name, data);
  211. }
  212. }
  213. cmake* cmServerProtocol::CMakeInstance() const
  214. {
  215. return this->m_CMakeInstance.get();
  216. }
  217. bool cmServerProtocol::DoActivate(const cmServerRequest& /*request*/,
  218. std::string* /*errorMessage*/)
  219. {
  220. return true;
  221. }
  222. std::pair<int, int> cmServerProtocol1::ProtocolVersion() const
  223. {
  224. return std::make_pair(1, 1);
  225. }
  226. static void setErrorMessage(std::string* errorMessage, const std::string& text)
  227. {
  228. if (errorMessage) {
  229. *errorMessage = text;
  230. }
  231. }
  232. static bool testHomeDirectory(cmState* state, std::string& value,
  233. std::string* errorMessage)
  234. {
  235. const std::string cachedValue =
  236. std::string(state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY"));
  237. if (value.empty()) {
  238. value = cachedValue;
  239. return true;
  240. }
  241. const std::string suffix = "/CMakeLists.txt";
  242. const std::string cachedValueCML = cachedValue + suffix;
  243. const std::string valueCML = value + suffix;
  244. if (!cmSystemTools::SameFile(valueCML, cachedValueCML)) {
  245. setErrorMessage(errorMessage,
  246. std::string("\"CMAKE_HOME_DIRECTORY\" is set but "
  247. "incompatible with configured "
  248. "source directory value."));
  249. return false;
  250. }
  251. return true;
  252. }
  253. static bool testValue(cmState* state, const std::string& key,
  254. std::string& value, const std::string& keyDescription,
  255. std::string* errorMessage)
  256. {
  257. const char* entry = state->GetCacheEntryValue(key);
  258. const std::string cachedValue =
  259. entry == nullptr ? std::string() : std::string(entry);
  260. if (value.empty()) {
  261. value = cachedValue;
  262. }
  263. if (!cachedValue.empty() && cachedValue != value) {
  264. setErrorMessage(errorMessage, std::string("\"") + key +
  265. "\" is set but incompatible with configured " +
  266. keyDescription + " value.");
  267. return false;
  268. }
  269. return true;
  270. }
  271. bool cmServerProtocol1::DoActivate(const cmServerRequest& request,
  272. std::string* errorMessage)
  273. {
  274. std::string sourceDirectory = request.Data[kSOURCE_DIRECTORY_KEY].asString();
  275. const std::string buildDirectory =
  276. request.Data[kBUILD_DIRECTORY_KEY].asString();
  277. std::string generator = request.Data[kGENERATOR_KEY].asString();
  278. std::string extraGenerator = request.Data[kEXTRA_GENERATOR_KEY].asString();
  279. std::string toolset = request.Data[kTOOLSET_KEY].asString();
  280. std::string platform = request.Data[kPLATFORM_KEY].asString();
  281. if (buildDirectory.empty()) {
  282. setErrorMessage(errorMessage, std::string("\"") + kBUILD_DIRECTORY_KEY +
  283. "\" is missing.");
  284. return false;
  285. }
  286. cmake* cm = CMakeInstance();
  287. if (cmSystemTools::PathExists(buildDirectory)) {
  288. if (!cmSystemTools::FileIsDirectory(buildDirectory)) {
  289. setErrorMessage(errorMessage, std::string("\"") + kBUILD_DIRECTORY_KEY +
  290. "\" exists but is not a directory.");
  291. return false;
  292. }
  293. const std::string cachePath = cm->FindCacheFile(buildDirectory);
  294. if (cm->LoadCache(cachePath)) {
  295. cmState* state = cm->GetState();
  296. // Check generator:
  297. if (!testValue(state, "CMAKE_GENERATOR", generator, "generator",
  298. errorMessage)) {
  299. return false;
  300. }
  301. // check extra generator:
  302. if (!testValue(state, "CMAKE_EXTRA_GENERATOR", extraGenerator,
  303. "extra generator", errorMessage)) {
  304. return false;
  305. }
  306. // check sourcedir:
  307. if (!testHomeDirectory(state, sourceDirectory, errorMessage)) {
  308. return false;
  309. }
  310. // check toolset:
  311. if (!testValue(state, "CMAKE_GENERATOR_TOOLSET", toolset, "toolset",
  312. errorMessage)) {
  313. return false;
  314. }
  315. // check platform:
  316. if (!testValue(state, "CMAKE_GENERATOR_PLATFORM", platform, "platform",
  317. errorMessage)) {
  318. return false;
  319. }
  320. }
  321. }
  322. if (sourceDirectory.empty()) {
  323. setErrorMessage(errorMessage, std::string("\"") + kSOURCE_DIRECTORY_KEY +
  324. "\" is unset but required.");
  325. return false;
  326. }
  327. if (!cmSystemTools::FileIsDirectory(sourceDirectory)) {
  328. setErrorMessage(errorMessage, std::string("\"") + kSOURCE_DIRECTORY_KEY +
  329. "\" is not a directory.");
  330. return false;
  331. }
  332. if (generator.empty()) {
  333. setErrorMessage(errorMessage, std::string("\"") + kGENERATOR_KEY +
  334. "\" is unset but required.");
  335. return false;
  336. }
  337. std::vector<cmake::GeneratorInfo> generators;
  338. cm->GetRegisteredGenerators(generators);
  339. auto baseIt = std::find_if(generators.begin(), generators.end(),
  340. [&generator](const cmake::GeneratorInfo& info) {
  341. return info.name == generator;
  342. });
  343. if (baseIt == generators.end()) {
  344. setErrorMessage(errorMessage, std::string("Generator \"") + generator +
  345. "\" not supported.");
  346. return false;
  347. }
  348. auto extraIt = std::find_if(
  349. generators.begin(), generators.end(),
  350. [&generator, &extraGenerator](const cmake::GeneratorInfo& info) {
  351. return info.baseName == generator && info.extraName == extraGenerator;
  352. });
  353. if (extraIt == generators.end()) {
  354. setErrorMessage(errorMessage,
  355. std::string("The combination of generator \"" + generator +
  356. "\" and extra generator \"" + extraGenerator +
  357. "\" is not supported."));
  358. return false;
  359. }
  360. if (!extraIt->supportsToolset && !toolset.empty()) {
  361. setErrorMessage(errorMessage,
  362. std::string("Toolset was provided but is not supported by "
  363. "the requested generator."));
  364. return false;
  365. }
  366. if (!extraIt->supportsPlatform && !platform.empty()) {
  367. setErrorMessage(errorMessage,
  368. std::string("Platform was provided but is not supported "
  369. "by the requested generator."));
  370. return false;
  371. }
  372. this->GeneratorInfo =
  373. GeneratorInformation(generator, extraGenerator, toolset, platform,
  374. sourceDirectory, buildDirectory);
  375. this->m_State = STATE_ACTIVE;
  376. return true;
  377. }
  378. void cmServerProtocol1::HandleCMakeFileChanges(const std::string& path,
  379. int event, int status)
  380. {
  381. assert(status == 0);
  382. static_cast<void>(status);
  383. if (!m_isDirty) {
  384. m_isDirty = true;
  385. SendSignal(kDIRTY_SIGNAL, Json::objectValue);
  386. }
  387. Json::Value obj = Json::objectValue;
  388. obj[kPATH_KEY] = path;
  389. Json::Value properties = Json::arrayValue;
  390. if (event & UV_RENAME) {
  391. properties.append(kRENAME_PROPERTY_VALUE);
  392. }
  393. if (event & UV_CHANGE) {
  394. properties.append(kCHANGE_PROPERTY_VALUE);
  395. }
  396. obj[kPROPERTIES_KEY] = properties;
  397. SendSignal(kFILE_CHANGE_SIGNAL, obj);
  398. }
  399. const cmServerResponse cmServerProtocol1::Process(
  400. const cmServerRequest& request)
  401. {
  402. assert(this->m_State >= STATE_ACTIVE);
  403. if (request.Type == kCACHE_TYPE) {
  404. return this->ProcessCache(request);
  405. }
  406. if (request.Type == kCMAKE_INPUTS_TYPE) {
  407. return this->ProcessCMakeInputs(request);
  408. }
  409. if (request.Type == kCODE_MODEL_TYPE) {
  410. return this->ProcessCodeModel(request);
  411. }
  412. if (request.Type == kCOMPUTE_TYPE) {
  413. return this->ProcessCompute(request);
  414. }
  415. if (request.Type == kCONFIGURE_TYPE) {
  416. return this->ProcessConfigure(request);
  417. }
  418. if (request.Type == kFILESYSTEM_WATCHERS_TYPE) {
  419. return this->ProcessFileSystemWatchers(request);
  420. }
  421. if (request.Type == kGLOBAL_SETTINGS_TYPE) {
  422. return this->ProcessGlobalSettings(request);
  423. }
  424. if (request.Type == kSET_GLOBAL_SETTINGS_TYPE) {
  425. return this->ProcessSetGlobalSettings(request);
  426. }
  427. return request.ReportError("Unknown command!");
  428. }
  429. bool cmServerProtocol1::IsExperimental() const
  430. {
  431. return true;
  432. }
  433. cmServerResponse cmServerProtocol1::ProcessCache(
  434. const cmServerRequest& request)
  435. {
  436. if (this->m_State < STATE_CONFIGURED) {
  437. return request.ReportError("This project was not configured yet.");
  438. }
  439. cmState* state = this->CMakeInstance()->GetState();
  440. Json::Value result = Json::objectValue;
  441. std::vector<std::string> allKeys = state->GetCacheEntryKeys();
  442. Json::Value list = Json::arrayValue;
  443. std::vector<std::string> keys = toStringList(request.Data[kKEYS_KEY]);
  444. if (keys.empty()) {
  445. keys = allKeys;
  446. } else {
  447. for (const auto& i : keys) {
  448. if (std::find(allKeys.begin(), allKeys.end(), i) == allKeys.end()) {
  449. return request.ReportError("Key \"" + i + "\" not found in cache.");
  450. }
  451. }
  452. }
  453. std::sort(keys.begin(), keys.end());
  454. for (const auto& key : keys) {
  455. Json::Value entry = Json::objectValue;
  456. entry[kKEY_KEY] = key;
  457. entry[kTYPE_KEY] =
  458. cmState::CacheEntryTypeToString(state->GetCacheEntryType(key));
  459. entry[kVALUE_KEY] = state->GetCacheEntryValue(key);
  460. Json::Value props = Json::objectValue;
  461. bool haveProperties = false;
  462. for (const auto& prop : state->GetCacheEntryPropertyList(key)) {
  463. haveProperties = true;
  464. props[prop] = state->GetCacheEntryProperty(key, prop);
  465. }
  466. if (haveProperties) {
  467. entry[kPROPERTIES_KEY] = props;
  468. }
  469. list.append(entry);
  470. }
  471. result[kCACHE_KEY] = list;
  472. return request.Reply(result);
  473. }
  474. cmServerResponse cmServerProtocol1::ProcessCMakeInputs(
  475. const cmServerRequest& request)
  476. {
  477. if (this->m_State < STATE_CONFIGURED) {
  478. return request.ReportError("This instance was not yet configured.");
  479. }
  480. const cmake* cm = this->CMakeInstance();
  481. const cmGlobalGenerator* gg = cm->GetGlobalGenerator();
  482. const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot();
  483. const std::string buildDir = cm->GetHomeOutputDirectory();
  484. const std::string sourceDir = cm->GetHomeDirectory();
  485. Json::Value result = Json::objectValue;
  486. result[kSOURCE_DIRECTORY_KEY] = sourceDir;
  487. result[kCMAKE_ROOT_DIRECTORY_KEY] = cmakeRootDir;
  488. std::vector<std::string> internalFiles;
  489. std::vector<std::string> explicitFiles;
  490. std::vector<std::string> tmpFiles;
  491. getCMakeInputs(gg, sourceDir, buildDir, &internalFiles, &explicitFiles,
  492. &tmpFiles);
  493. Json::Value array = Json::arrayValue;
  494. Json::Value tmp = Json::objectValue;
  495. tmp[kIS_CMAKE_KEY] = true;
  496. tmp[kIS_TEMPORARY_KEY] = false;
  497. tmp[kSOURCES_KEY] = fromStringList(internalFiles);
  498. array.append(tmp);
  499. tmp = Json::objectValue;
  500. tmp[kIS_CMAKE_KEY] = false;
  501. tmp[kIS_TEMPORARY_KEY] = false;
  502. tmp[kSOURCES_KEY] = fromStringList(explicitFiles);
  503. array.append(tmp);
  504. tmp = Json::objectValue;
  505. tmp[kIS_CMAKE_KEY] = false;
  506. tmp[kIS_TEMPORARY_KEY] = true;
  507. tmp[kSOURCES_KEY] = fromStringList(tmpFiles);
  508. array.append(tmp);
  509. result[kBUILD_FILES_KEY] = array;
  510. return request.Reply(result);
  511. }
  512. class LanguageData
  513. {
  514. public:
  515. bool operator==(const LanguageData& other) const;
  516. void SetDefines(const std::set<std::string>& defines);
  517. bool IsGenerated = false;
  518. std::string Language;
  519. std::string Flags;
  520. std::vector<std::string> Defines;
  521. std::vector<std::pair<std::string, bool> > IncludePathList;
  522. };
  523. bool LanguageData::operator==(const LanguageData& other) const
  524. {
  525. return Language == other.Language && Defines == other.Defines &&
  526. Flags == other.Flags && IncludePathList == other.IncludePathList &&
  527. IsGenerated == other.IsGenerated;
  528. }
  529. void LanguageData::SetDefines(const std::set<std::string>& defines)
  530. {
  531. std::vector<std::string> result;
  532. for (const auto& i : defines) {
  533. result.push_back(i);
  534. }
  535. std::sort(result.begin(), result.end());
  536. Defines = result;
  537. }
  538. namespace std {
  539. template <>
  540. struct hash<LanguageData>
  541. {
  542. std::size_t operator()(const LanguageData& in) const
  543. {
  544. using std::hash;
  545. size_t result =
  546. hash<std::string>()(in.Language) ^ hash<std::string>()(in.Flags);
  547. for (const auto& i : in.IncludePathList) {
  548. result = result ^ (hash<std::string>()(i.first) ^
  549. (i.second ? std::numeric_limits<size_t>::max() : 0));
  550. }
  551. for (const auto& i : in.Defines) {
  552. result = result ^ hash<std::string>()(i);
  553. }
  554. result =
  555. result ^ (in.IsGenerated ? std::numeric_limits<size_t>::max() : 0);
  556. return result;
  557. }
  558. };
  559. } // namespace std
  560. static Json::Value DumpSourceFileGroup(const LanguageData& data,
  561. const std::vector<std::string>& files,
  562. const std::string& baseDir)
  563. {
  564. Json::Value result = Json::objectValue;
  565. if (!data.Language.empty()) {
  566. result[kLANGUAGE_KEY] = data.Language;
  567. if (!data.Flags.empty()) {
  568. result[kCOMPILE_FLAGS_KEY] = data.Flags;
  569. }
  570. if (!data.IncludePathList.empty()) {
  571. Json::Value includes = Json::arrayValue;
  572. for (const auto& i : data.IncludePathList) {
  573. Json::Value tmp = Json::objectValue;
  574. tmp[kPATH_KEY] = i.first;
  575. if (i.second) {
  576. tmp[kIS_SYSTEM_KEY] = i.second;
  577. }
  578. includes.append(tmp);
  579. }
  580. result[kINCLUDE_PATH_KEY] = includes;
  581. }
  582. if (!data.Defines.empty()) {
  583. result[kDEFINES_KEY] = fromStringList(data.Defines);
  584. }
  585. }
  586. result[kIS_GENERATED_KEY] = data.IsGenerated;
  587. Json::Value sourcesValue = Json::arrayValue;
  588. for (const auto& i : files) {
  589. const std::string relPath =
  590. cmSystemTools::RelativePath(baseDir.c_str(), i.c_str());
  591. sourcesValue.append(relPath.size() < i.size() ? relPath : i);
  592. }
  593. result[kSOURCES_KEY] = sourcesValue;
  594. return result;
  595. }
  596. static Json::Value DumpSourceFilesList(
  597. cmGeneratorTarget* target, const std::string& config,
  598. const std::map<std::string, LanguageData>& languageDataMap)
  599. {
  600. // Collect sourcefile groups:
  601. std::vector<cmSourceFile*> files;
  602. target->GetSourceFiles(files, config);
  603. std::unordered_map<LanguageData, std::vector<std::string> > fileGroups;
  604. for (cmSourceFile* file : files) {
  605. LanguageData fileData;
  606. fileData.Language = file->GetLanguage();
  607. if (!fileData.Language.empty()) {
  608. const LanguageData& ld = languageDataMap.at(fileData.Language);
  609. cmLocalGenerator* lg = target->GetLocalGenerator();
  610. std::string compileFlags = ld.Flags;
  611. if (const char* cflags = file->GetProperty("COMPILE_FLAGS")) {
  612. cmGeneratorExpression ge;
  613. auto cge = ge.Parse(cflags);
  614. const char* processed =
  615. cge->Evaluate(target->GetLocalGenerator(), config);
  616. lg->AppendFlags(compileFlags, processed);
  617. }
  618. fileData.Flags = compileFlags;
  619. fileData.IncludePathList = ld.IncludePathList;
  620. std::set<std::string> defines;
  621. lg->AppendDefines(defines, file->GetProperty("COMPILE_DEFINITIONS"));
  622. const std::string defPropName =
  623. "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
  624. lg->AppendDefines(defines, file->GetProperty(defPropName));
  625. defines.insert(ld.Defines.begin(), ld.Defines.end());
  626. fileData.SetDefines(defines);
  627. }
  628. fileData.IsGenerated = file->GetPropertyAsBool("GENERATED");
  629. std::vector<std::string>& groupFileList = fileGroups[fileData];
  630. groupFileList.push_back(file->GetFullPath());
  631. }
  632. const std::string baseDir = target->Makefile->GetCurrentSourceDirectory();
  633. Json::Value result = Json::arrayValue;
  634. for (auto it = fileGroups.begin(); it != fileGroups.end(); ++it) {
  635. Json::Value group = DumpSourceFileGroup(it->first, it->second, baseDir);
  636. if (!group.isNull()) {
  637. result.append(group);
  638. }
  639. }
  640. return result;
  641. }
  642. static Json::Value DumpBacktrace(const cmListFileBacktrace& backtrace)
  643. {
  644. Json::Value result = Json::arrayValue;
  645. cmListFileBacktrace backtraceCopy = backtrace;
  646. while (!backtraceCopy.Top().FilePath.empty()) {
  647. Json::Value entry = Json::objectValue;
  648. entry[kPATH_KEY] = backtraceCopy.Top().FilePath;
  649. if (backtraceCopy.Top().Line) {
  650. entry[kLINE_NUMBER_KEY] = (int)backtraceCopy.Top().Line;
  651. }
  652. if (!backtraceCopy.Top().Name.empty()) {
  653. entry[kNAME_KEY] = backtraceCopy.Top().Name;
  654. }
  655. result.append(std::move(entry));
  656. backtraceCopy = backtraceCopy.Pop();
  657. }
  658. return result;
  659. }
  660. static void DumpBacktraceRange(Json::Value& result, const std::string& type,
  661. const cmBacktraceRange& range)
  662. {
  663. for (const auto& bt : range) {
  664. Json::Value obj = Json::objectValue;
  665. obj[kTYPE_KEY] = type;
  666. obj[kBACKTRACE_KEY] = DumpBacktrace(bt);
  667. result.append(obj);
  668. }
  669. }
  670. static Json::Value DumpTarget(cmGeneratorTarget* target,
  671. const std::string& config)
  672. {
  673. cmLocalGenerator* lg = target->GetLocalGenerator();
  674. const cmState* state = lg->GetState();
  675. const cmStateEnums::TargetType type = target->GetType();
  676. const std::string typeName = state->GetTargetTypeName(type);
  677. Json::Value ttl = Json::arrayValue;
  678. ttl.append("EXECUTABLE");
  679. ttl.append("STATIC_LIBRARY");
  680. ttl.append("SHARED_LIBRARY");
  681. ttl.append("MODULE_LIBRARY");
  682. ttl.append("OBJECT_LIBRARY");
  683. ttl.append("UTILITY");
  684. ttl.append("INTERFACE_LIBRARY");
  685. if (!hasString(ttl, typeName) || target->IsImported()) {
  686. return Json::Value();
  687. }
  688. Json::Value result = Json::objectValue;
  689. result[kNAME_KEY] = target->GetName();
  690. result[kTYPE_KEY] = typeName;
  691. result[kSOURCE_DIRECTORY_KEY] = lg->GetCurrentSourceDirectory();
  692. result[kBUILD_DIRECTORY_KEY] = lg->GetCurrentBinaryDirectory();
  693. if (type == cmStateEnums::INTERFACE_LIBRARY) {
  694. return result;
  695. }
  696. result[kFULL_NAME_KEY] = target->GetFullName(config);
  697. Json::Value crossRefs = Json::objectValue;
  698. crossRefs[kBACKTRACE_KEY] = DumpBacktrace(target->Target->GetBacktrace());
  699. Json::Value statements = Json::arrayValue;
  700. DumpBacktraceRange(statements, "target_compile_definitions",
  701. target->Target->GetCompileDefinitionsBacktraces());
  702. DumpBacktraceRange(statements, "target_include_directories",
  703. target->Target->GetIncludeDirectoriesBacktraces());
  704. DumpBacktraceRange(statements, "target_compile_options",
  705. target->Target->GetCompileOptionsBacktraces());
  706. DumpBacktraceRange(statements, "target_link_libraries",
  707. target->Target->GetLinkImplementationBacktraces());
  708. crossRefs[kRELATED_STATEMENTS_KEY] = std::move(statements);
  709. result[kTARGET_CROSS_REFERENCES_KEY] = std::move(crossRefs);
  710. if (target->HaveWellDefinedOutputFiles()) {
  711. Json::Value artifacts = Json::arrayValue;
  712. artifacts.append(
  713. target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact));
  714. if (target->IsDLLPlatform()) {
  715. artifacts.append(
  716. target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact));
  717. const cmGeneratorTarget::OutputInfo* output =
  718. target->GetOutputInfo(config);
  719. if (output && !output->PdbDir.empty()) {
  720. artifacts.append(output->PdbDir + '/' + target->GetPDBName(config));
  721. }
  722. }
  723. result[kARTIFACTS_KEY] = artifacts;
  724. result[kLINKER_LANGUAGE_KEY] = target->GetLinkerLanguage(config);
  725. std::string linkLibs;
  726. std::string linkFlags;
  727. std::string linkLanguageFlags;
  728. std::string frameworkPath;
  729. std::string linkPath;
  730. cmLinkLineComputer linkLineComputer(lg,
  731. lg->GetStateSnapshot().GetDirectory());
  732. lg->GetTargetFlags(&linkLineComputer, config, linkLibs, linkLanguageFlags,
  733. linkFlags, frameworkPath, linkPath, target);
  734. linkLibs = cmSystemTools::TrimWhitespace(linkLibs);
  735. linkFlags = cmSystemTools::TrimWhitespace(linkFlags);
  736. linkLanguageFlags = cmSystemTools::TrimWhitespace(linkLanguageFlags);
  737. frameworkPath = cmSystemTools::TrimWhitespace(frameworkPath);
  738. linkPath = cmSystemTools::TrimWhitespace(linkPath);
  739. if (!cmSystemTools::TrimWhitespace(linkLibs).empty()) {
  740. result[kLINK_LIBRARIES_KEY] = linkLibs;
  741. }
  742. if (!cmSystemTools::TrimWhitespace(linkFlags).empty()) {
  743. result[kLINK_FLAGS_KEY] = linkFlags;
  744. }
  745. if (!cmSystemTools::TrimWhitespace(linkLanguageFlags).empty()) {
  746. result[kLINK_LANGUAGE_FLAGS_KEY] = linkLanguageFlags;
  747. }
  748. if (!frameworkPath.empty()) {
  749. result[kFRAMEWORK_PATH_KEY] = frameworkPath;
  750. }
  751. if (!linkPath.empty()) {
  752. result[kLINK_PATH_KEY] = linkPath;
  753. }
  754. const std::string sysroot =
  755. lg->GetMakefile()->GetSafeDefinition("CMAKE_SYSROOT");
  756. if (!sysroot.empty()) {
  757. result[kSYSROOT_KEY] = sysroot;
  758. }
  759. }
  760. std::set<std::string> languages;
  761. target->GetLanguages(languages, config);
  762. std::map<std::string, LanguageData> languageDataMap;
  763. for (const auto& lang : languages) {
  764. LanguageData& ld = languageDataMap[lang];
  765. ld.Language = lang;
  766. lg->GetTargetCompileFlags(target, config, lang, ld.Flags);
  767. std::set<std::string> defines;
  768. lg->GetTargetDefines(target, config, lang, defines);
  769. ld.SetDefines(defines);
  770. std::vector<std::string> includePathList;
  771. lg->GetIncludeDirectories(includePathList, target, lang, config, true);
  772. for (auto i : includePathList) {
  773. ld.IncludePathList.push_back(
  774. std::make_pair(i, target->IsSystemIncludeDirectory(i, config)));
  775. }
  776. }
  777. Json::Value sourceGroupsValue =
  778. DumpSourceFilesList(target, config, languageDataMap);
  779. if (!sourceGroupsValue.empty()) {
  780. result[kFILE_GROUPS_KEY] = sourceGroupsValue;
  781. }
  782. return result;
  783. }
  784. static Json::Value DumpTargetsList(
  785. const std::vector<cmLocalGenerator*>& generators, const std::string& config)
  786. {
  787. Json::Value result = Json::arrayValue;
  788. std::vector<cmGeneratorTarget*> targetList;
  789. for (const auto& lgIt : generators) {
  790. auto list = lgIt->GetGeneratorTargets();
  791. targetList.insert(targetList.end(), list.begin(), list.end());
  792. }
  793. std::sort(targetList.begin(), targetList.end());
  794. for (cmGeneratorTarget* target : targetList) {
  795. Json::Value tmp = DumpTarget(target, config);
  796. if (!tmp.isNull()) {
  797. result.append(tmp);
  798. }
  799. }
  800. return result;
  801. }
  802. static Json::Value DumpProjectList(const cmake* cm, std::string const& config)
  803. {
  804. Json::Value result = Json::arrayValue;
  805. auto globalGen = cm->GetGlobalGenerator();
  806. for (const auto& projectIt : globalGen->GetProjectMap()) {
  807. Json::Value pObj = Json::objectValue;
  808. pObj[kNAME_KEY] = projectIt.first;
  809. // All Projects must have at least one local generator
  810. assert(!projectIt.second.empty());
  811. const cmLocalGenerator* lg = projectIt.second.at(0);
  812. // Project structure information:
  813. const cmMakefile* mf = lg->GetMakefile();
  814. pObj[kSOURCE_DIRECTORY_KEY] = mf->GetCurrentSourceDirectory();
  815. pObj[kBUILD_DIRECTORY_KEY] = mf->GetCurrentBinaryDirectory();
  816. pObj[kTARGETS_KEY] = DumpTargetsList(projectIt.second, config);
  817. result.append(pObj);
  818. }
  819. return result;
  820. }
  821. static Json::Value DumpConfiguration(const cmake* cm,
  822. const std::string& config)
  823. {
  824. Json::Value result = Json::objectValue;
  825. result[kNAME_KEY] = config;
  826. result[kPROJECTS_KEY] = DumpProjectList(cm, config);
  827. return result;
  828. }
  829. static Json::Value DumpConfigurationsList(const cmake* cm)
  830. {
  831. Json::Value result = Json::arrayValue;
  832. for (const std::string& c : getConfigurations(cm)) {
  833. result.append(DumpConfiguration(cm, c));
  834. }
  835. return result;
  836. }
  837. cmServerResponse cmServerProtocol1::ProcessCodeModel(
  838. const cmServerRequest& request)
  839. {
  840. if (this->m_State != STATE_COMPUTED) {
  841. return request.ReportError("No build system was generated yet.");
  842. }
  843. Json::Value result = Json::objectValue;
  844. result[kCONFIGURATIONS_KEY] = DumpConfigurationsList(this->CMakeInstance());
  845. return request.Reply(result);
  846. }
  847. cmServerResponse cmServerProtocol1::ProcessCompute(
  848. const cmServerRequest& request)
  849. {
  850. if (this->m_State > STATE_CONFIGURED) {
  851. return request.ReportError("This build system was already generated.");
  852. }
  853. if (this->m_State < STATE_CONFIGURED) {
  854. return request.ReportError("This project was not configured yet.");
  855. }
  856. cmake* cm = this->CMakeInstance();
  857. int ret = cm->Generate();
  858. if (ret < 0) {
  859. return request.ReportError("Failed to compute build system.");
  860. }
  861. m_State = STATE_COMPUTED;
  862. return request.Reply(Json::Value());
  863. }
  864. cmServerResponse cmServerProtocol1::ProcessConfigure(
  865. const cmServerRequest& request)
  866. {
  867. if (this->m_State == STATE_INACTIVE) {
  868. return request.ReportError("This instance is inactive.");
  869. }
  870. FileMonitor()->StopMonitoring();
  871. std::string errorMessage;
  872. cmake* cm = this->CMakeInstance();
  873. this->GeneratorInfo.SetupGenerator(cm, &errorMessage);
  874. if (!errorMessage.empty()) {
  875. return request.ReportError(errorMessage);
  876. }
  877. // Make sure the types of cacheArguments matches (if given):
  878. std::vector<std::string> cacheArgs = { "unused" };
  879. bool cacheArgumentsError = false;
  880. const Json::Value passedArgs = request.Data[kCACHE_ARGUMENTS_KEY];
  881. if (!passedArgs.isNull()) {
  882. if (passedArgs.isString()) {
  883. cacheArgs.push_back(passedArgs.asString());
  884. } else if (passedArgs.isArray()) {
  885. for (auto i = passedArgs.begin(); i != passedArgs.end(); ++i) {
  886. if (!i->isString()) {
  887. cacheArgumentsError = true;
  888. break;
  889. }
  890. cacheArgs.push_back(i->asString());
  891. }
  892. } else {
  893. cacheArgumentsError = true;
  894. }
  895. }
  896. if (cacheArgumentsError) {
  897. request.ReportError(
  898. "cacheArguments must be unset, a string or an array of strings.");
  899. }
  900. std::string sourceDir = cm->GetHomeDirectory();
  901. const std::string buildDir = cm->GetHomeOutputDirectory();
  902. cmGlobalGenerator* gg = cm->GetGlobalGenerator();
  903. if (buildDir.empty()) {
  904. return request.ReportError("No build directory set via Handshake.");
  905. }
  906. if (cm->LoadCache(buildDir)) {
  907. // build directory has been set up before
  908. const char* cachedSourceDir =
  909. cm->GetState()->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY");
  910. if (!cachedSourceDir) {
  911. return request.ReportError("No CMAKE_HOME_DIRECTORY found in cache.");
  912. }
  913. if (sourceDir.empty()) {
  914. sourceDir = std::string(cachedSourceDir);
  915. cm->SetHomeDirectory(sourceDir);
  916. }
  917. const char* cachedGenerator =
  918. cm->GetState()->GetInitializedCacheValue("CMAKE_GENERATOR");
  919. if (cachedGenerator) {
  920. if (gg && gg->GetName() != cachedGenerator) {
  921. return request.ReportError("Configured generator does not match with "
  922. "CMAKE_GENERATOR found in cache.");
  923. }
  924. }
  925. } else {
  926. // build directory has not been set up before
  927. if (sourceDir.empty()) {
  928. return request.ReportError("No sourceDirectory set via "
  929. "setGlobalSettings and no cache found in "
  930. "buildDirectory.");
  931. }
  932. }
  933. cmSystemTools::ResetErrorOccuredFlag(); // Reset error state
  934. if (cm->AddCMakePaths() != 1) {
  935. return request.ReportError("Failed to set CMake paths.");
  936. }
  937. if (!cm->SetCacheArgs(cacheArgs)) {
  938. return request.ReportError("cacheArguments could not be set.");
  939. }
  940. int ret = cm->Configure();
  941. if (ret < 0) {
  942. return request.ReportError("Configuration failed.");
  943. }
  944. std::vector<std::string> toWatchList;
  945. getCMakeInputs(gg, std::string(), buildDir, nullptr, &toWatchList, nullptr);
  946. FileMonitor()->MonitorPaths(toWatchList,
  947. [this](const std::string& p, int e, int s) {
  948. this->HandleCMakeFileChanges(p, e, s);
  949. });
  950. m_State = STATE_CONFIGURED;
  951. m_isDirty = false;
  952. return request.Reply(Json::Value());
  953. }
  954. cmServerResponse cmServerProtocol1::ProcessGlobalSettings(
  955. const cmServerRequest& request)
  956. {
  957. cmake* cm = this->CMakeInstance();
  958. Json::Value obj = Json::objectValue;
  959. // Capabilities information:
  960. obj[kCAPABILITIES_KEY] = cm->ReportCapabilitiesJson(true);
  961. obj[kDEBUG_OUTPUT_KEY] = cm->GetDebugOutput();
  962. obj[kTRACE_KEY] = cm->GetTrace();
  963. obj[kTRACE_EXPAND_KEY] = cm->GetTraceExpand();
  964. obj[kWARN_UNINITIALIZED_KEY] = cm->GetWarnUninitialized();
  965. obj[kWARN_UNUSED_KEY] = cm->GetWarnUnused();
  966. obj[kWARN_UNUSED_CLI_KEY] = cm->GetWarnUnusedCli();
  967. obj[kCHECK_SYSTEM_VARS_KEY] = cm->GetCheckSystemVars();
  968. obj[kSOURCE_DIRECTORY_KEY] = this->GeneratorInfo.SourceDirectory;
  969. obj[kBUILD_DIRECTORY_KEY] = this->GeneratorInfo.BuildDirectory;
  970. // Currently used generator:
  971. obj[kGENERATOR_KEY] = this->GeneratorInfo.GeneratorName;
  972. obj[kEXTRA_GENERATOR_KEY] = this->GeneratorInfo.ExtraGeneratorName;
  973. return request.Reply(obj);
  974. }
  975. static void setBool(const cmServerRequest& request, const std::string& key,
  976. std::function<void(bool)> const& setter)
  977. {
  978. if (request.Data[key].isNull()) {
  979. return;
  980. }
  981. setter(request.Data[key].asBool());
  982. }
  983. cmServerResponse cmServerProtocol1::ProcessSetGlobalSettings(
  984. const cmServerRequest& request)
  985. {
  986. const std::vector<std::string> boolValues = {
  987. kDEBUG_OUTPUT_KEY, kTRACE_KEY, kTRACE_EXPAND_KEY,
  988. kWARN_UNINITIALIZED_KEY, kWARN_UNUSED_KEY, kWARN_UNUSED_CLI_KEY,
  989. kCHECK_SYSTEM_VARS_KEY
  990. };
  991. for (const auto& i : boolValues) {
  992. if (!request.Data[i].isNull() && !request.Data[i].isBool()) {
  993. return request.ReportError("\"" + i +
  994. "\" must be unset or a bool value.");
  995. }
  996. }
  997. cmake* cm = this->CMakeInstance();
  998. setBool(request, kDEBUG_OUTPUT_KEY,
  999. [cm](bool e) { cm->SetDebugOutputOn(e); });
  1000. setBool(request, kTRACE_KEY, [cm](bool e) { cm->SetTrace(e); });
  1001. setBool(request, kTRACE_EXPAND_KEY, [cm](bool e) { cm->SetTraceExpand(e); });
  1002. setBool(request, kWARN_UNINITIALIZED_KEY,
  1003. [cm](bool e) { cm->SetWarnUninitialized(e); });
  1004. setBool(request, kWARN_UNUSED_KEY, [cm](bool e) { cm->SetWarnUnused(e); });
  1005. setBool(request, kWARN_UNUSED_CLI_KEY,
  1006. [cm](bool e) { cm->SetWarnUnusedCli(e); });
  1007. setBool(request, kCHECK_SYSTEM_VARS_KEY,
  1008. [cm](bool e) { cm->SetCheckSystemVars(e); });
  1009. return request.Reply(Json::Value());
  1010. }
  1011. cmServerResponse cmServerProtocol1::ProcessFileSystemWatchers(
  1012. const cmServerRequest& request)
  1013. {
  1014. const cmFileMonitor* const fm = FileMonitor();
  1015. Json::Value result = Json::objectValue;
  1016. Json::Value files = Json::arrayValue;
  1017. for (const auto& f : fm->WatchedFiles()) {
  1018. files.append(f);
  1019. }
  1020. Json::Value directories = Json::arrayValue;
  1021. for (const auto& d : fm->WatchedDirectories()) {
  1022. directories.append(d);
  1023. }
  1024. result[kWATCHED_FILES_KEY] = files;
  1025. result[kWATCHED_DIRECTORIES_KEY] = directories;
  1026. return request.Reply(result);
  1027. }
  1028. cmServerProtocol1::GeneratorInformation::GeneratorInformation(
  1029. const std::string& generatorName, const std::string& extraGeneratorName,
  1030. const std::string& toolset, const std::string& platform,
  1031. const std::string& sourceDirectory, const std::string& buildDirectory)
  1032. : GeneratorName(generatorName)
  1033. , ExtraGeneratorName(extraGeneratorName)
  1034. , Toolset(toolset)
  1035. , Platform(platform)
  1036. , SourceDirectory(sourceDirectory)
  1037. , BuildDirectory(buildDirectory)
  1038. {
  1039. }
  1040. void cmServerProtocol1::GeneratorInformation::SetupGenerator(
  1041. cmake* cm, std::string* errorMessage)
  1042. {
  1043. const std::string fullGeneratorName =
  1044. cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
  1045. GeneratorName, ExtraGeneratorName);
  1046. cm->SetHomeDirectory(SourceDirectory);
  1047. cm->SetHomeOutputDirectory(BuildDirectory);
  1048. cmGlobalGenerator* gg = cm->CreateGlobalGenerator(fullGeneratorName);
  1049. if (!gg) {
  1050. setErrorMessage(
  1051. errorMessage,
  1052. std::string("Could not set up the requested combination of \"") +
  1053. kGENERATOR_KEY + "\" and \"" + kEXTRA_GENERATOR_KEY + "\"");
  1054. return;
  1055. }
  1056. cm->SetGlobalGenerator(gg);
  1057. cm->SetGeneratorToolset(Toolset);
  1058. cm->SetGeneratorPlatform(Platform);
  1059. }