cmState.cxx 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2015 Stephen Kelly <[email protected]>
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmState.h"
  11. #include "cmake.h"
  12. #include "cmCacheManager.h"
  13. #include "cmCommand.h"
  14. #include "cmAlgorithms.h"
  15. #include "cmDefinitions.h"
  16. #include <assert.h>
  17. struct cmState::SnapshotDataType
  18. {
  19. cmState::PositionType ScopeParent;
  20. cmState::PositionType DirectoryParent;
  21. cmLinkedTree<cmState::PolicyStackEntry>::iterator Policies;
  22. cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyRoot;
  23. cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyScope;
  24. cmState::SnapshotType SnapshotType;
  25. cmLinkedTree<std::string>::iterator ExecutionListFile;
  26. cmLinkedTree<cmState::BuildsystemDirectoryStateType>::iterator
  27. BuildSystemDirectory;
  28. cmLinkedTree<cmDefinitions>::iterator Vars;
  29. cmLinkedTree<cmDefinitions>::iterator Root;
  30. cmLinkedTree<cmDefinitions>::iterator Parent;
  31. std::string EntryPointCommand;
  32. long EntryPointLine;
  33. std::vector<std::string>::size_type IncludeDirectoryPosition;
  34. std::vector<std::string>::size_type CompileDefinitionsPosition;
  35. std::vector<std::string>::size_type CompileOptionsPosition;
  36. };
  37. struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap
  38. {
  39. typedef cmPolicies::PolicyMap derived;
  40. PolicyStackEntry(bool w = false): derived(), Weak(w) {}
  41. PolicyStackEntry(derived const& d, bool w): derived(d), Weak(w) {}
  42. PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {}
  43. bool Weak;
  44. };
  45. struct cmState::BuildsystemDirectoryStateType
  46. {
  47. cmState::PositionType DirectoryEnd;
  48. std::string Location;
  49. std::string OutputLocation;
  50. std::vector<std::string> CurrentSourceDirectoryComponents;
  51. std::vector<std::string> CurrentBinaryDirectoryComponents;
  52. // The top-most directories for relative path conversion. Both the
  53. // source and destination location of a relative path conversion
  54. // must be underneath one of these directories (both under source or
  55. // both under binary) in order for the relative path to be evaluated
  56. // safely by the build tools.
  57. std::string RelativePathTopSource;
  58. std::string RelativePathTopBinary;
  59. std::vector<std::string> IncludeDirectories;
  60. std::vector<cmListFileBacktrace> IncludeDirectoryBacktraces;
  61. std::vector<std::string> CompileDefinitions;
  62. std::vector<cmListFileBacktrace> CompileDefinitionsBacktraces;
  63. std::vector<std::string> CompileOptions;
  64. std::vector<cmListFileBacktrace> CompileOptionsBacktraces;
  65. std::string ProjectName;
  66. cmPropertyMap Properties;
  67. std::vector<cmState::Snapshot> Children;
  68. };
  69. cmState::cmState()
  70. : IsInTryCompile(false),
  71. WindowsShell(false),
  72. WindowsVSIDE(false),
  73. WatcomWMake(false),
  74. MinGWMake(false),
  75. NMake(false),
  76. MSYSShell(false)
  77. {
  78. this->CacheManager = new cmCacheManager;
  79. }
  80. cmState::~cmState()
  81. {
  82. delete this->CacheManager;
  83. cmDeleteAll(this->Commands);
  84. }
  85. const char* cmCacheEntryTypes[] =
  86. { "BOOL",
  87. "PATH",
  88. "FILEPATH",
  89. "STRING",
  90. "INTERNAL",
  91. "STATIC",
  92. "UNINITIALIZED",
  93. 0
  94. };
  95. const char*
  96. cmState::CacheEntryTypeToString(cmState::CacheEntryType type)
  97. {
  98. if ( type > 6 )
  99. {
  100. return cmCacheEntryTypes[6];
  101. }
  102. return cmCacheEntryTypes[type];
  103. }
  104. cmState::CacheEntryType
  105. cmState::StringToCacheEntryType(const char* s)
  106. {
  107. int i = 0;
  108. while(cmCacheEntryTypes[i])
  109. {
  110. if(strcmp(s, cmCacheEntryTypes[i]) == 0)
  111. {
  112. return static_cast<cmState::CacheEntryType>(i);
  113. }
  114. ++i;
  115. }
  116. return STRING;
  117. }
  118. bool cmState::IsCacheEntryType(std::string const& key)
  119. {
  120. for(int i=0; cmCacheEntryTypes[i]; ++i)
  121. {
  122. if(strcmp(key.c_str(), cmCacheEntryTypes[i]) == 0)
  123. {
  124. return true;
  125. }
  126. }
  127. return false;
  128. }
  129. bool cmState::LoadCache(const std::string& path, bool internal,
  130. std::set<std::string>& excludes,
  131. std::set<std::string>& includes)
  132. {
  133. return this->CacheManager->LoadCache(path, internal,
  134. excludes, includes);
  135. }
  136. bool cmState::SaveCache(const std::string& path)
  137. {
  138. return this->CacheManager->SaveCache(path);
  139. }
  140. bool cmState::DeleteCache(const std::string& path)
  141. {
  142. return this->CacheManager->DeleteCache(path);
  143. }
  144. std::vector<std::string> cmState::GetCacheEntryKeys() const
  145. {
  146. std::vector<std::string> definitions;
  147. definitions.reserve(this->CacheManager->GetSize());
  148. cmCacheManager::CacheIterator cit =
  149. this->CacheManager->GetCacheIterator();
  150. for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
  151. {
  152. definitions.push_back(cit.GetName());
  153. }
  154. return definitions;
  155. }
  156. const char* cmState::GetCacheEntryValue(std::string const& key) const
  157. {
  158. cmCacheManager::CacheEntry* e = this->CacheManager
  159. ->GetCacheEntry(key);
  160. if (!e)
  161. {
  162. return 0;
  163. }
  164. return e->Value.c_str();
  165. }
  166. const char*
  167. cmState::GetInitializedCacheValue(std::string const& key) const
  168. {
  169. return this->CacheManager->GetInitializedCacheValue(key);
  170. }
  171. cmState::CacheEntryType
  172. cmState::GetCacheEntryType(std::string const& key) const
  173. {
  174. cmCacheManager::CacheIterator it =
  175. this->CacheManager->GetCacheIterator(key.c_str());
  176. return it.GetType();
  177. }
  178. void cmState::SetCacheEntryValue(std::string const& key,
  179. std::string const& value)
  180. {
  181. this->CacheManager->SetCacheEntryValue(key, value);
  182. }
  183. void cmState::SetCacheEntryProperty(std::string const& key,
  184. std::string const& propertyName,
  185. std::string const& value)
  186. {
  187. cmCacheManager::CacheIterator it =
  188. this->CacheManager->GetCacheIterator(key.c_str());
  189. it.SetProperty(propertyName, value.c_str());
  190. }
  191. void cmState::SetCacheEntryBoolProperty(std::string const& key,
  192. std::string const& propertyName,
  193. bool value)
  194. {
  195. cmCacheManager::CacheIterator it =
  196. this->CacheManager->GetCacheIterator(key.c_str());
  197. it.SetProperty(propertyName, value);
  198. }
  199. const char* cmState::GetCacheEntryProperty(std::string const& key,
  200. std::string const& propertyName)
  201. {
  202. cmCacheManager::CacheIterator it = this->CacheManager
  203. ->GetCacheIterator(key.c_str());
  204. if (!it.PropertyExists(propertyName))
  205. {
  206. return 0;
  207. }
  208. return it.GetProperty(propertyName);
  209. }
  210. bool cmState::GetCacheEntryPropertyAsBool(std::string const& key,
  211. std::string const& propertyName)
  212. {
  213. return this->CacheManager
  214. ->GetCacheIterator(key.c_str()).GetPropertyAsBool(propertyName);
  215. }
  216. void cmState::AddCacheEntry(const std::string& key, const char* value,
  217. const char* helpString,
  218. cmState::CacheEntryType type)
  219. {
  220. this->CacheManager->AddCacheEntry(key, value,
  221. helpString, type);
  222. }
  223. void cmState::RemoveCacheEntry(std::string const& key)
  224. {
  225. this->CacheManager->RemoveCacheEntry(key);
  226. }
  227. void cmState::AppendCacheEntryProperty(const std::string& key,
  228. const std::string& property,
  229. const std::string& value,
  230. bool asString)
  231. {
  232. this->CacheManager
  233. ->GetCacheIterator(key.c_str()).AppendProperty(property,
  234. value.c_str(),
  235. asString);
  236. }
  237. void cmState::RemoveCacheEntryProperty(std::string const& key,
  238. std::string const& propertyName)
  239. {
  240. this->CacheManager
  241. ->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0);
  242. }
  243. cmState::Snapshot cmState::Reset()
  244. {
  245. this->GlobalProperties.clear();
  246. this->PropertyDefinitions.clear();
  247. PositionType pos = this->SnapshotData.Truncate();
  248. this->ExecutionListFiles.Truncate();
  249. {
  250. cmLinkedTree<BuildsystemDirectoryStateType>::iterator it =
  251. this->BuildsystemDirectory.Truncate();
  252. it->IncludeDirectories.clear();
  253. it->IncludeDirectoryBacktraces.clear();
  254. it->CompileDefinitions.clear();
  255. it->CompileDefinitionsBacktraces.clear();
  256. it->CompileOptions.clear();
  257. it->CompileOptionsBacktraces.clear();
  258. it->DirectoryEnd = pos;
  259. it->Properties.clear();
  260. it->Children.clear();
  261. }
  262. this->PolicyStack.Clear();
  263. pos->Policies = this->PolicyStack.Root();
  264. pos->PolicyRoot = this->PolicyStack.Root();
  265. pos->PolicyScope = this->PolicyStack.Root();
  266. assert(pos->Policies.IsValid());
  267. assert(pos->PolicyRoot.IsValid());
  268. {
  269. std::string srcDir =
  270. cmDefinitions::Get("CMAKE_SOURCE_DIR", pos->Vars, pos->Root);
  271. std::string binDir =
  272. cmDefinitions::Get("CMAKE_BINARY_DIR", pos->Vars, pos->Root);
  273. this->VarTree.Clear();
  274. pos->Vars = this->VarTree.Extend(this->VarTree.Root());
  275. pos->Parent = this->VarTree.Root();
  276. pos->Root = this->VarTree.Root();
  277. pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir.c_str());
  278. pos->Vars->Set("CMAKE_BINARY_DIR", binDir.c_str());
  279. }
  280. this->DefineProperty
  281. ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
  282. "", "", true);
  283. this->DefineProperty
  284. ("RULE_LAUNCH_LINK", cmProperty::DIRECTORY,
  285. "", "", true);
  286. this->DefineProperty
  287. ("RULE_LAUNCH_CUSTOM", cmProperty::DIRECTORY,
  288. "", "", true);
  289. this->DefineProperty
  290. ("RULE_LAUNCH_COMPILE", cmProperty::TARGET,
  291. "", "", true);
  292. this->DefineProperty
  293. ("RULE_LAUNCH_LINK", cmProperty::TARGET,
  294. "", "", true);
  295. this->DefineProperty
  296. ("RULE_LAUNCH_CUSTOM", cmProperty::TARGET,
  297. "", "", true);
  298. return Snapshot(this, pos);
  299. }
  300. void cmState::DefineProperty(const std::string& name,
  301. cmProperty::ScopeType scope,
  302. const char *ShortDescription,
  303. const char *FullDescription,
  304. bool chained)
  305. {
  306. this->PropertyDefinitions[scope].DefineProperty(name,scope,ShortDescription,
  307. FullDescription,
  308. chained);
  309. }
  310. cmPropertyDefinition const* cmState
  311. ::GetPropertyDefinition(const std::string& name,
  312. cmProperty::ScopeType scope) const
  313. {
  314. if (this->IsPropertyDefined(name,scope))
  315. {
  316. cmPropertyDefinitionMap const& defs =
  317. this->PropertyDefinitions.find(scope)->second;
  318. return &defs.find(name)->second;
  319. }
  320. return 0;
  321. }
  322. bool cmState::IsPropertyDefined(const std::string& name,
  323. cmProperty::ScopeType scope) const
  324. {
  325. std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::const_iterator it
  326. = this->PropertyDefinitions.find(scope);
  327. if (it == this->PropertyDefinitions.end())
  328. {
  329. return false;
  330. }
  331. return it->second.IsPropertyDefined(name);
  332. }
  333. bool cmState::IsPropertyChained(const std::string& name,
  334. cmProperty::ScopeType scope) const
  335. {
  336. std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::const_iterator it
  337. = this->PropertyDefinitions.find(scope);
  338. if (it == this->PropertyDefinitions.end())
  339. {
  340. return false;
  341. }
  342. return it->second.IsPropertyChained(name);
  343. }
  344. void cmState::SetLanguageEnabled(std::string const& l)
  345. {
  346. std::vector<std::string>::iterator it =
  347. std::lower_bound(this->EnabledLanguages.begin(),
  348. this->EnabledLanguages.end(), l);
  349. if (it == this->EnabledLanguages.end() || *it != l)
  350. {
  351. this->EnabledLanguages.insert(it, l);
  352. }
  353. }
  354. bool cmState::GetLanguageEnabled(std::string const& l) const
  355. {
  356. return std::binary_search(this->EnabledLanguages.begin(),
  357. this->EnabledLanguages.end(), l);
  358. }
  359. std::vector<std::string> cmState::GetEnabledLanguages() const
  360. {
  361. return this->EnabledLanguages;
  362. }
  363. void cmState::SetEnabledLanguages(std::vector<std::string> const& langs)
  364. {
  365. this->EnabledLanguages = langs;
  366. }
  367. void cmState::ClearEnabledLanguages()
  368. {
  369. this->EnabledLanguages.clear();
  370. }
  371. bool cmState::GetIsInTryCompile() const
  372. {
  373. return this->IsInTryCompile;
  374. }
  375. void cmState::SetIsInTryCompile(bool b)
  376. {
  377. this->IsInTryCompile = b;
  378. }
  379. void cmState::RenameCommand(std::string const& oldName,
  380. std::string const& newName)
  381. {
  382. // if the command already exists, free the old one
  383. std::string sOldName = cmSystemTools::LowerCase(oldName);
  384. std::string sNewName = cmSystemTools::LowerCase(newName);
  385. std::map<std::string, cmCommand*>::iterator pos =
  386. this->Commands.find(sOldName);
  387. if ( pos == this->Commands.end() )
  388. {
  389. return;
  390. }
  391. cmCommand* cmd = pos->second;
  392. pos = this->Commands.find(sNewName);
  393. if (pos != this->Commands.end())
  394. {
  395. delete pos->second;
  396. this->Commands.erase(pos);
  397. }
  398. this->Commands.insert(std::make_pair(sNewName, cmd));
  399. pos = this->Commands.find(sOldName);
  400. this->Commands.erase(pos);
  401. }
  402. void cmState::AddCommand(cmCommand* command)
  403. {
  404. std::string name = cmSystemTools::LowerCase(command->GetName());
  405. // if the command already exists, free the old one
  406. std::map<std::string, cmCommand*>::iterator pos = this->Commands.find(name);
  407. if (pos != this->Commands.end())
  408. {
  409. delete pos->second;
  410. this->Commands.erase(pos);
  411. }
  412. this->Commands.insert(std::make_pair(name, command));
  413. }
  414. void cmState::RemoveUnscriptableCommands()
  415. {
  416. std::vector<std::string> unscriptableCommands;
  417. for (std::map<std::string, cmCommand*>::iterator
  418. pos = this->Commands.begin();
  419. pos != this->Commands.end(); )
  420. {
  421. if (!pos->second->IsScriptable())
  422. {
  423. delete pos->second;
  424. this->Commands.erase(pos++);
  425. }
  426. else
  427. {
  428. ++pos;
  429. }
  430. }
  431. }
  432. cmCommand* cmState::GetCommand(std::string const& name) const
  433. {
  434. cmCommand* command = 0;
  435. std::string sName = cmSystemTools::LowerCase(name);
  436. std::map<std::string, cmCommand*>::const_iterator pos =
  437. this->Commands.find(sName);
  438. if (pos != this->Commands.end())
  439. {
  440. command = (*pos).second;
  441. }
  442. return command;
  443. }
  444. std::vector<std::string> cmState::GetCommandNames() const
  445. {
  446. std::vector<std::string> commandNames;
  447. commandNames.reserve(this->Commands.size());
  448. std::map<std::string, cmCommand*>::const_iterator cmds
  449. = this->Commands.begin();
  450. for ( ; cmds != this->Commands.end(); ++ cmds )
  451. {
  452. commandNames.push_back(cmds->first);
  453. }
  454. return commandNames;
  455. }
  456. void cmState::RemoveUserDefinedCommands()
  457. {
  458. std::vector<cmCommand*> renamedCommands;
  459. for(std::map<std::string, cmCommand*>::iterator j = this->Commands.begin();
  460. j != this->Commands.end(); )
  461. {
  462. if (j->second->IsA("cmMacroHelperCommand") ||
  463. j->second->IsA("cmFunctionHelperCommand"))
  464. {
  465. delete j->second;
  466. this->Commands.erase(j++);
  467. }
  468. else if (j->first != j->second->GetName())
  469. {
  470. renamedCommands.push_back(j->second);
  471. this->Commands.erase(j++);
  472. }
  473. else
  474. {
  475. ++j;
  476. }
  477. }
  478. for (std::vector<cmCommand*>::const_iterator it = renamedCommands.begin();
  479. it != renamedCommands.end(); ++it)
  480. {
  481. this->Commands[cmSystemTools::LowerCase((*it)->GetName())] = *it;
  482. }
  483. }
  484. void cmState::SetGlobalProperty(const std::string& prop, const char* value)
  485. {
  486. this->GlobalProperties.SetProperty(prop, value);
  487. }
  488. void cmState::AppendGlobalProperty(const std::string& prop,
  489. const char* value, bool asString)
  490. {
  491. this->GlobalProperties.AppendProperty(prop, value, asString);
  492. }
  493. const char *cmState::GetGlobalProperty(const std::string& prop)
  494. {
  495. if ( prop == "CACHE_VARIABLES" )
  496. {
  497. std::vector<std::string> cacheKeys = this->GetCacheEntryKeys();
  498. this->SetGlobalProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";").c_str());
  499. }
  500. else if ( prop == "COMMANDS" )
  501. {
  502. std::vector<std::string> commands = this->GetCommandNames();
  503. this->SetGlobalProperty("COMMANDS", cmJoin(commands, ";").c_str());
  504. }
  505. else if ( prop == "IN_TRY_COMPILE" )
  506. {
  507. this->SetGlobalProperty("IN_TRY_COMPILE",
  508. this->IsInTryCompile ? "1" : "0");
  509. }
  510. else if ( prop == "ENABLED_LANGUAGES" )
  511. {
  512. std::string langs;
  513. langs = cmJoin(this->EnabledLanguages, ";");
  514. this->SetGlobalProperty("ENABLED_LANGUAGES", langs.c_str());
  515. }
  516. #define STRING_LIST_ELEMENT(F) ";" #F
  517. if (prop == "CMAKE_C_KNOWN_FEATURES")
  518. {
  519. return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1;
  520. }
  521. if (prop == "CMAKE_CXX_KNOWN_FEATURES")
  522. {
  523. return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
  524. }
  525. #undef STRING_LIST_ELEMENT
  526. return this->GlobalProperties.GetPropertyValue(prop);
  527. }
  528. bool cmState::GetGlobalPropertyAsBool(const std::string& prop)
  529. {
  530. return cmSystemTools::IsOn(this->GetGlobalProperty(prop));
  531. }
  532. void cmState::SetSourceDirectory(std::string const& sourceDirectory)
  533. {
  534. this->SourceDirectory = sourceDirectory;
  535. cmSystemTools::ConvertToUnixSlashes(this->SourceDirectory);
  536. cmSystemTools::SplitPath(
  537. cmSystemTools::CollapseFullPath(this->SourceDirectory),
  538. this->SourceDirectoryComponents);
  539. }
  540. const char* cmState::GetSourceDirectory() const
  541. {
  542. return this->SourceDirectory.c_str();
  543. }
  544. std::vector<std::string> const& cmState::GetSourceDirectoryComponents() const
  545. {
  546. return this->SourceDirectoryComponents;
  547. }
  548. void cmState::SetBinaryDirectory(std::string const& binaryDirectory)
  549. {
  550. this->BinaryDirectory = binaryDirectory;
  551. cmSystemTools::ConvertToUnixSlashes(this->BinaryDirectory);
  552. cmSystemTools::SplitPath(
  553. cmSystemTools::CollapseFullPath(this->BinaryDirectory),
  554. this->BinaryDirectoryComponents);
  555. }
  556. void cmState::SetWindowsShell(bool windowsShell)
  557. {
  558. this->WindowsShell = windowsShell;
  559. }
  560. bool cmState::UseWindowsShell() const
  561. {
  562. return this->WindowsShell;
  563. }
  564. void cmState::SetWindowsVSIDE(bool windowsVSIDE)
  565. {
  566. this->WindowsVSIDE = windowsVSIDE;
  567. }
  568. bool cmState::UseWindowsVSIDE() const
  569. {
  570. return this->WindowsVSIDE;
  571. }
  572. void cmState::SetWatcomWMake(bool watcomWMake)
  573. {
  574. this->WatcomWMake = watcomWMake;
  575. }
  576. bool cmState::UseWatcomWMake() const
  577. {
  578. return this->WatcomWMake;
  579. }
  580. void cmState::SetMinGWMake(bool minGWMake)
  581. {
  582. this->MinGWMake = minGWMake;
  583. }
  584. bool cmState::UseMinGWMake() const
  585. {
  586. return this->MinGWMake;
  587. }
  588. void cmState::SetNMake(bool nMake)
  589. {
  590. this->NMake = nMake;
  591. }
  592. bool cmState::UseNMake() const
  593. {
  594. return this->NMake;
  595. }
  596. void cmState::SetMSYSShell(bool mSYSShell)
  597. {
  598. this->MSYSShell = mSYSShell;
  599. }
  600. bool cmState::UseMSYSShell() const
  601. {
  602. return this->MSYSShell;
  603. }
  604. unsigned int cmState::GetCacheMajorVersion() const
  605. {
  606. return this->CacheManager->GetCacheMajorVersion();
  607. }
  608. unsigned int cmState::GetCacheMinorVersion() const
  609. {
  610. return this->CacheManager->GetCacheMinorVersion();
  611. }
  612. const char* cmState::GetBinaryDirectory() const
  613. {
  614. return this->BinaryDirectory.c_str();
  615. }
  616. std::vector<std::string> const& cmState::GetBinaryDirectoryComponents() const
  617. {
  618. return this->BinaryDirectoryComponents;
  619. }
  620. void cmState::Directory::ComputeRelativePathTopSource()
  621. {
  622. // Relative path conversion inside the source tree is not used to
  623. // construct relative paths passed to build tools so it is safe to use
  624. // even when the source is a network path.
  625. cmState::Snapshot snapshot = this->Snapshot_;
  626. std::vector<cmState::Snapshot> snapshots;
  627. snapshots.push_back(snapshot);
  628. while (true)
  629. {
  630. snapshot = snapshot.GetBuildsystemDirectoryParent();
  631. if (snapshot.IsValid())
  632. {
  633. snapshots.push_back(snapshot);
  634. }
  635. else
  636. {
  637. break;
  638. }
  639. }
  640. std::string result = snapshots.front().GetDirectory().GetCurrentSource();
  641. for (std::vector<cmState::Snapshot>::const_iterator it =
  642. snapshots.begin() + 1; it != snapshots.end(); ++it)
  643. {
  644. std::string currentSource = it->GetDirectory().GetCurrentSource();
  645. if(cmSystemTools::IsSubDirectory(result, currentSource))
  646. {
  647. result = currentSource;
  648. }
  649. }
  650. this->DirectoryState->RelativePathTopSource = result;
  651. }
  652. void cmState::Directory::ComputeRelativePathTopBinary()
  653. {
  654. cmState::Snapshot snapshot = this->Snapshot_;
  655. std::vector<cmState::Snapshot> snapshots;
  656. snapshots.push_back(snapshot);
  657. while (true)
  658. {
  659. snapshot = snapshot.GetBuildsystemDirectoryParent();
  660. if (snapshot.IsValid())
  661. {
  662. snapshots.push_back(snapshot);
  663. }
  664. else
  665. {
  666. break;
  667. }
  668. }
  669. std::string result =
  670. snapshots.front().GetDirectory().GetCurrentBinary();
  671. for (std::vector<cmState::Snapshot>::const_iterator it =
  672. snapshots.begin() + 1; it != snapshots.end(); ++it)
  673. {
  674. std::string currentBinary = it->GetDirectory().GetCurrentBinary();
  675. if(cmSystemTools::IsSubDirectory(result, currentBinary))
  676. {
  677. result = currentBinary;
  678. }
  679. }
  680. // The current working directory on Windows cannot be a network
  681. // path. Therefore relative paths cannot work when the binary tree
  682. // is a network path.
  683. if(result.size() < 2 || result.substr(0, 2) != "//")
  684. {
  685. this->DirectoryState->RelativePathTopBinary = result;
  686. }
  687. else
  688. {
  689. this->DirectoryState->RelativePathTopBinary = "";
  690. }
  691. }
  692. cmState::Snapshot cmState::CreateBaseSnapshot()
  693. {
  694. PositionType pos = this->SnapshotData.Extend(this->SnapshotData.Root());
  695. pos->DirectoryParent = this->SnapshotData.Root();
  696. pos->ScopeParent = this->SnapshotData.Root();
  697. pos->SnapshotType = BaseType;
  698. pos->BuildSystemDirectory =
  699. this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root());
  700. pos->ExecutionListFile =
  701. this->ExecutionListFiles.Extend(this->ExecutionListFiles.Root());
  702. pos->IncludeDirectoryPosition = 0;
  703. pos->CompileDefinitionsPosition = 0;
  704. pos->CompileOptionsPosition = 0;
  705. pos->BuildSystemDirectory->DirectoryEnd = pos;
  706. pos->Policies = this->PolicyStack.Root();
  707. pos->PolicyRoot = this->PolicyStack.Root();
  708. pos->PolicyScope = this->PolicyStack.Root();
  709. assert(pos->Policies.IsValid());
  710. assert(pos->PolicyRoot.IsValid());
  711. pos->Vars = this->VarTree.Extend(this->VarTree.Root());
  712. assert(pos->Vars.IsValid());
  713. pos->Parent = this->VarTree.Root();
  714. pos->Root = this->VarTree.Root();
  715. return cmState::Snapshot(this, pos);
  716. }
  717. cmState::Snapshot
  718. cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
  719. std::string const& entryPointCommand,
  720. long entryPointLine)
  721. {
  722. assert(originSnapshot.IsValid());
  723. PositionType pos = this->SnapshotData.Extend(originSnapshot.Position);
  724. pos->EntryPointLine = entryPointLine;
  725. pos->EntryPointCommand = entryPointCommand;
  726. pos->DirectoryParent = originSnapshot.Position;
  727. pos->ScopeParent = originSnapshot.Position;
  728. pos->SnapshotType = BuildsystemDirectoryType;
  729. pos->BuildSystemDirectory =
  730. this->BuildsystemDirectory.Extend(
  731. originSnapshot.Position->BuildSystemDirectory);
  732. pos->ExecutionListFile =
  733. this->ExecutionListFiles.Extend(
  734. originSnapshot.Position->ExecutionListFile);
  735. pos->BuildSystemDirectory->DirectoryEnd = pos;
  736. pos->Policies = originSnapshot.Position->Policies;
  737. pos->PolicyRoot = originSnapshot.Position->Policies;
  738. pos->PolicyScope = originSnapshot.Position->Policies;
  739. assert(pos->Policies.IsValid());
  740. assert(pos->PolicyRoot.IsValid());
  741. cmLinkedTree<cmDefinitions>::iterator origin =
  742. originSnapshot.Position->Vars;
  743. pos->Parent = origin;
  744. pos->Root = origin;
  745. pos->Vars = this->VarTree.Extend(origin);
  746. cmState::Snapshot snapshot = cmState::Snapshot(this, pos);
  747. originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot);
  748. snapshot.InitializeFromParent();
  749. snapshot.SetDirectoryDefinitions();
  750. return snapshot;
  751. }
  752. cmState::Snapshot
  753. cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot,
  754. std::string const& entryPointCommand,
  755. long entryPointLine,
  756. std::string const& fileName)
  757. {
  758. PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
  759. *originSnapshot.Position);
  760. pos->ScopeParent = originSnapshot.Position;
  761. pos->EntryPointLine = entryPointLine;
  762. pos->EntryPointCommand = entryPointCommand;
  763. pos->SnapshotType = FunctionCallType;
  764. pos->ExecutionListFile = this->ExecutionListFiles.Extend(
  765. originSnapshot.Position->ExecutionListFile, fileName);
  766. pos->BuildSystemDirectory->DirectoryEnd = pos;
  767. pos->PolicyScope = originSnapshot.Position->Policies;
  768. assert(originSnapshot.Position->Vars.IsValid());
  769. cmLinkedTree<cmDefinitions>::iterator origin =
  770. originSnapshot.Position->Vars;
  771. pos->Parent = origin;
  772. pos->Vars = this->VarTree.Extend(origin);
  773. return cmState::Snapshot(this, pos);
  774. }
  775. cmState::Snapshot
  776. cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot,
  777. std::string const& entryPointCommand,
  778. long entryPointLine,
  779. std::string const& fileName)
  780. {
  781. PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
  782. *originSnapshot.Position);
  783. pos->EntryPointLine = entryPointLine;
  784. pos->EntryPointCommand = entryPointCommand;
  785. pos->SnapshotType = MacroCallType;
  786. pos->ExecutionListFile = this->ExecutionListFiles.Extend(
  787. originSnapshot.Position->ExecutionListFile, fileName);
  788. assert(originSnapshot.Position->Vars.IsValid());
  789. pos->BuildSystemDirectory->DirectoryEnd = pos;
  790. pos->PolicyScope = originSnapshot.Position->Policies;
  791. return cmState::Snapshot(this, pos);
  792. }
  793. cmState::Snapshot
  794. cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot,
  795. const std::string& entryPointCommand,
  796. long entryPointLine,
  797. const std::string& fileName)
  798. {
  799. PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
  800. *originSnapshot.Position);
  801. pos->EntryPointLine = entryPointLine;
  802. pos->EntryPointCommand = entryPointCommand;
  803. pos->SnapshotType = CallStackType;
  804. pos->ExecutionListFile = this->ExecutionListFiles.Extend(
  805. originSnapshot.Position->ExecutionListFile, fileName);
  806. assert(originSnapshot.Position->Vars.IsValid());
  807. pos->BuildSystemDirectory->DirectoryEnd = pos;
  808. pos->PolicyScope = originSnapshot.Position->Policies;
  809. return cmState::Snapshot(this, pos);
  810. }
  811. cmState::Snapshot
  812. cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot,
  813. std::string const& entryPointCommand,
  814. long entryPointLine)
  815. {
  816. PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
  817. *originSnapshot.Position);
  818. pos->ScopeParent = originSnapshot.Position;
  819. pos->EntryPointLine = entryPointLine;
  820. pos->EntryPointCommand = entryPointCommand;
  821. pos->SnapshotType = VariableScopeType;
  822. assert(originSnapshot.Position->Vars.IsValid());
  823. cmLinkedTree<cmDefinitions>::iterator origin =
  824. originSnapshot.Position->Vars;
  825. pos->Parent = origin;
  826. pos->Vars = this->VarTree.Extend(origin);
  827. assert(pos->Vars.IsValid());
  828. return cmState::Snapshot(this, pos);
  829. }
  830. cmState::Snapshot
  831. cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot,
  832. const std::string& entryPointCommand,
  833. long entryPointLine,
  834. const std::string& fileName)
  835. {
  836. PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
  837. *originSnapshot.Position);
  838. pos->EntryPointLine = entryPointLine;
  839. pos->EntryPointCommand = entryPointCommand;
  840. pos->SnapshotType = InlineListFileType;
  841. pos->ExecutionListFile = this->ExecutionListFiles.Extend(
  842. originSnapshot.Position->ExecutionListFile, fileName);
  843. pos->BuildSystemDirectory->DirectoryEnd = pos;
  844. pos->PolicyScope = originSnapshot.Position->Policies;
  845. return cmState::Snapshot(this, pos);
  846. }
  847. cmState::Snapshot
  848. cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot)
  849. {
  850. PositionType pos = this->SnapshotData.Extend(originSnapshot.Position,
  851. *originSnapshot.Position);
  852. pos->SnapshotType = PolicyScopeType;
  853. pos->BuildSystemDirectory->DirectoryEnd = pos;
  854. pos->PolicyScope = originSnapshot.Position->Policies;
  855. return cmState::Snapshot(this, pos);
  856. }
  857. cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot)
  858. {
  859. PositionType pos = originSnapshot.Position;
  860. PositionType prevPos = pos;
  861. ++prevPos;
  862. prevPos->IncludeDirectoryPosition =
  863. prevPos->BuildSystemDirectory->IncludeDirectories.size();
  864. prevPos->CompileDefinitionsPosition =
  865. prevPos->BuildSystemDirectory->CompileDefinitions.size();
  866. prevPos->CompileOptionsPosition =
  867. prevPos->BuildSystemDirectory->CompileOptions.size();
  868. prevPos->BuildSystemDirectory->DirectoryEnd = prevPos;
  869. return Snapshot(this, prevPos);
  870. }
  871. cmState::Snapshot::Snapshot(cmState* state)
  872. : State(state)
  873. , Position()
  874. {
  875. }
  876. std::vector<cmState::Snapshot> cmState::Snapshot::GetChildren()
  877. {
  878. return this->Position->BuildSystemDirectory->Children;
  879. }
  880. cmState::Snapshot::Snapshot(cmState* state, PositionType position)
  881. : State(state),
  882. Position(position)
  883. {
  884. }
  885. cmState::SnapshotType cmState::Snapshot::GetType() const
  886. {
  887. return this->Position->SnapshotType;
  888. }
  889. const char* cmState::Directory::GetCurrentSource() const
  890. {
  891. return this->DirectoryState->Location.c_str();
  892. }
  893. void cmState::Directory::SetCurrentSource(std::string const& dir)
  894. {
  895. std::string& loc = this->DirectoryState->Location;
  896. loc = dir;
  897. cmSystemTools::ConvertToUnixSlashes(loc);
  898. loc = cmSystemTools::CollapseFullPath(loc);
  899. cmSystemTools::SplitPath(
  900. loc,
  901. this->DirectoryState->CurrentSourceDirectoryComponents);
  902. this->ComputeRelativePathTopSource();
  903. this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc.c_str());
  904. }
  905. const char* cmState::Directory::GetCurrentBinary() const
  906. {
  907. return this->DirectoryState->OutputLocation.c_str();
  908. }
  909. void cmState::Directory::SetCurrentBinary(std::string const& dir)
  910. {
  911. std::string& loc = this->DirectoryState->OutputLocation;
  912. loc = dir;
  913. cmSystemTools::ConvertToUnixSlashes(loc);
  914. loc = cmSystemTools::CollapseFullPath(loc);
  915. cmSystemTools::SplitPath(
  916. loc,
  917. this->DirectoryState->CurrentBinaryDirectoryComponents);
  918. this->ComputeRelativePathTopBinary();
  919. this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc.c_str());
  920. }
  921. void cmState::Snapshot::SetListFile(const std::string& listfile)
  922. {
  923. *this->Position->ExecutionListFile = listfile;
  924. }
  925. std::vector<std::string> const&
  926. cmState::Directory::GetCurrentSourceComponents() const
  927. {
  928. return this->DirectoryState->CurrentSourceDirectoryComponents;
  929. }
  930. std::vector<std::string> const&
  931. cmState::Directory::GetCurrentBinaryComponents() const
  932. {
  933. return this->DirectoryState->CurrentBinaryDirectoryComponents;
  934. }
  935. const char* cmState::Directory::GetRelativePathTopSource() const
  936. {
  937. return this->DirectoryState->RelativePathTopSource.c_str();
  938. }
  939. const char* cmState::Directory::GetRelativePathTopBinary() const
  940. {
  941. return this->DirectoryState->RelativePathTopBinary.c_str();
  942. }
  943. void cmState::Directory::SetRelativePathTopSource(const char* dir)
  944. {
  945. this->DirectoryState->RelativePathTopSource = dir;
  946. }
  947. void cmState::Directory::SetRelativePathTopBinary(const char* dir)
  948. {
  949. this->DirectoryState->RelativePathTopBinary = dir;
  950. }
  951. std::string cmState::Snapshot::GetExecutionListFile() const
  952. {
  953. return *this->Position->ExecutionListFile;
  954. }
  955. std::string cmState::Snapshot::GetEntryPointCommand() const
  956. {
  957. return this->Position->EntryPointCommand;
  958. }
  959. long cmState::Snapshot::GetEntryPointLine() const
  960. {
  961. return this->Position->EntryPointLine;
  962. }
  963. bool cmState::Snapshot::IsValid() const
  964. {
  965. return this->State && this->Position.IsValid()
  966. ? this->Position != this->State->SnapshotData.Root()
  967. : false;
  968. }
  969. cmState::Snapshot cmState::Snapshot::GetBuildsystemDirectoryParent() const
  970. {
  971. Snapshot snapshot;
  972. if (!this->State || this->Position == this->State->SnapshotData.Root())
  973. {
  974. return snapshot;
  975. }
  976. PositionType parentPos = this->Position->DirectoryParent;
  977. if (parentPos != this->State->SnapshotData.Root())
  978. {
  979. snapshot = Snapshot(this->State,
  980. parentPos->BuildSystemDirectory->DirectoryEnd);
  981. }
  982. return snapshot;
  983. }
  984. cmState::Snapshot cmState::Snapshot::GetCallStackParent() const
  985. {
  986. assert(this->State);
  987. assert(this->Position != this->State->SnapshotData.Root());
  988. Snapshot snapshot;
  989. PositionType parentPos = this->Position;
  990. while(parentPos->SnapshotType == cmState::PolicyScopeType)
  991. {
  992. ++parentPos;
  993. }
  994. if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType
  995. || parentPos->SnapshotType == cmState::BaseType)
  996. {
  997. return snapshot;
  998. }
  999. ++parentPos;
  1000. while(parentPos->SnapshotType == cmState::PolicyScopeType)
  1001. {
  1002. ++parentPos;
  1003. }
  1004. if (parentPos == this->State->SnapshotData.Root())
  1005. {
  1006. return snapshot;
  1007. }
  1008. snapshot = Snapshot(this->State, parentPos);
  1009. return snapshot;
  1010. }
  1011. void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak)
  1012. {
  1013. PositionType pos = this->Position;
  1014. pos->Policies =
  1015. this->State->PolicyStack.Extend(pos->Policies,
  1016. PolicyStackEntry(entry, weak));
  1017. }
  1018. bool cmState::Snapshot::PopPolicy()
  1019. {
  1020. PositionType pos = this->Position;
  1021. if (pos->Policies == pos->PolicyScope)
  1022. {
  1023. return false;
  1024. }
  1025. ++pos->Policies;
  1026. return true;
  1027. }
  1028. bool cmState::Snapshot::CanPopPolicyScope()
  1029. {
  1030. return this->Position->Policies == this->Position->PolicyScope;
  1031. }
  1032. void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id,
  1033. cmPolicies::PolicyStatus status)
  1034. {
  1035. // Update the policy stack from the top to the top-most strong entry.
  1036. bool previous_was_weak = true;
  1037. for(cmLinkedTree<PolicyStackEntry>::iterator psi = this->Position->Policies;
  1038. previous_was_weak && psi != this->Position->PolicyRoot; ++psi)
  1039. {
  1040. psi->Set(id, status);
  1041. previous_was_weak = psi->Weak;
  1042. }
  1043. }
  1044. cmPolicies::PolicyStatus
  1045. cmState::Snapshot::GetPolicy(cmPolicies::PolicyID id) const
  1046. {
  1047. cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id);
  1048. if(status == cmPolicies::REQUIRED_ALWAYS ||
  1049. status == cmPolicies::REQUIRED_IF_USED)
  1050. {
  1051. return status;
  1052. }
  1053. cmLinkedTree<BuildsystemDirectoryStateType>::iterator dir =
  1054. this->Position->BuildSystemDirectory;
  1055. while (true)
  1056. {
  1057. assert(dir.IsValid());
  1058. cmLinkedTree<PolicyStackEntry>::iterator leaf =
  1059. dir->DirectoryEnd->Policies;
  1060. cmLinkedTree<PolicyStackEntry>::iterator root =
  1061. dir->DirectoryEnd->PolicyRoot;
  1062. for( ; leaf != root; ++leaf)
  1063. {
  1064. if(leaf->IsDefined(id))
  1065. {
  1066. status = leaf->Get(id);
  1067. return status;
  1068. }
  1069. }
  1070. cmState::PositionType e = dir->DirectoryEnd;
  1071. cmState::PositionType p = e->DirectoryParent;
  1072. if (p == this->State->SnapshotData.Root())
  1073. {
  1074. break;
  1075. }
  1076. dir = p->BuildSystemDirectory;
  1077. }
  1078. return status;
  1079. }
  1080. bool cmState::Snapshot::HasDefinedPolicyCMP0011()
  1081. {
  1082. return !this->Position->Policies->IsEmpty();
  1083. }
  1084. const char* cmState::Snapshot::GetDefinition(std::string const& name) const
  1085. {
  1086. assert(this->Position->Vars.IsValid());
  1087. return cmDefinitions::Get(name, this->Position->Vars,
  1088. this->Position->Root);
  1089. }
  1090. bool cmState::Snapshot::IsInitialized(std::string const& name) const
  1091. {
  1092. return cmDefinitions::HasKey(name, this->Position->Vars,
  1093. this->Position->Root);
  1094. }
  1095. void cmState::Snapshot::SetDefinition(std::string const& name,
  1096. std::string const& value)
  1097. {
  1098. this->Position->Vars->Set(name, value.c_str());
  1099. }
  1100. void cmState::Snapshot::RemoveDefinition(std::string const& name)
  1101. {
  1102. this->Position->Vars->Set(name, 0);
  1103. }
  1104. std::vector<std::string> cmState::Snapshot::UnusedKeys() const
  1105. {
  1106. return this->Position->Vars->UnusedKeys();
  1107. }
  1108. std::vector<std::string> cmState::Snapshot::ClosureKeys() const
  1109. {
  1110. return cmDefinitions::ClosureKeys(this->Position->Vars,
  1111. this->Position->Root);
  1112. }
  1113. bool cmState::Snapshot::RaiseScope(std::string const& var, const char* varDef)
  1114. {
  1115. if(this->Position->ScopeParent == this->Position->DirectoryParent)
  1116. {
  1117. Snapshot parentDir = this->GetBuildsystemDirectoryParent();
  1118. if(!parentDir.IsValid())
  1119. {
  1120. return false;
  1121. }
  1122. // Update the definition in the parent directory top scope. This
  1123. // directory's scope was initialized by the closure of the parent
  1124. // scope, so we do not need to localize the definition first.
  1125. if (varDef)
  1126. {
  1127. parentDir.SetDefinition(var, varDef);
  1128. }
  1129. else
  1130. {
  1131. parentDir.RemoveDefinition(var);
  1132. }
  1133. return true;
  1134. }
  1135. // First localize the definition in the current scope.
  1136. cmDefinitions::Raise(var, this->Position->Vars,
  1137. this->Position->Root);
  1138. // Now update the definition in the parent scope.
  1139. this->Position->Parent->Set(var, varDef);
  1140. return true;
  1141. }
  1142. static const std::string cmPropertySentinal = std::string();
  1143. template<typename T, typename U, typename V>
  1144. void InitializeContentFromParent(T& parentContent,
  1145. T& thisContent,
  1146. U& parentBacktraces,
  1147. U& thisBacktraces,
  1148. V& contentEndPosition)
  1149. {
  1150. std::vector<std::string>::const_iterator parentBegin =
  1151. parentContent.begin();
  1152. std::vector<std::string>::const_iterator parentEnd =
  1153. parentContent.end();
  1154. std::vector<std::string>::const_reverse_iterator parentRbegin =
  1155. cmMakeReverseIterator(parentEnd);
  1156. std::vector<std::string>::const_reverse_iterator parentRend =
  1157. parentContent.rend();
  1158. parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinal);
  1159. std::vector<std::string>::const_iterator parentIt = parentRbegin.base();
  1160. thisContent = std::vector<std::string>(parentIt, parentEnd);
  1161. std::vector<cmListFileBacktrace>::const_iterator btIt =
  1162. parentBacktraces.begin() + std::distance(parentBegin, parentIt);
  1163. std::vector<cmListFileBacktrace>::const_iterator btEnd =
  1164. parentBacktraces.end();
  1165. thisBacktraces = std::vector<cmListFileBacktrace>(btIt, btEnd);
  1166. contentEndPosition = thisContent.size();
  1167. }
  1168. void cmState::Snapshot::SetDirectoryDefinitions()
  1169. {
  1170. this->SetDefinition("CMAKE_SOURCE_DIR",
  1171. this->State->GetSourceDirectory());
  1172. this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR",
  1173. this->State->GetSourceDirectory());
  1174. this->SetDefinition("CMAKE_BINARY_DIR",
  1175. this->State->GetBinaryDirectory());
  1176. this->SetDefinition("CMAKE_CURRENT_BINARY_DIR",
  1177. this->State->GetBinaryDirectory());
  1178. }
  1179. void cmState::Snapshot::InitializeFromParent()
  1180. {
  1181. PositionType parent = this->Position->DirectoryParent;
  1182. assert(this->Position->Vars.IsValid());
  1183. assert(parent->Vars.IsValid());
  1184. *this->Position->Vars =
  1185. cmDefinitions::MakeClosure(parent->Vars, parent->Root);
  1186. InitializeContentFromParent(parent->BuildSystemDirectory->IncludeDirectories,
  1187. this->Position->BuildSystemDirectory->IncludeDirectories,
  1188. parent->BuildSystemDirectory->IncludeDirectoryBacktraces,
  1189. this->Position->BuildSystemDirectory->IncludeDirectoryBacktraces,
  1190. this->Position->IncludeDirectoryPosition);
  1191. InitializeContentFromParent(parent->BuildSystemDirectory->CompileDefinitions,
  1192. this->Position->BuildSystemDirectory->CompileDefinitions,
  1193. parent->BuildSystemDirectory->CompileDefinitionsBacktraces,
  1194. this->Position->BuildSystemDirectory->CompileDefinitionsBacktraces,
  1195. this->Position->CompileDefinitionsPosition);
  1196. InitializeContentFromParent(parent->BuildSystemDirectory->CompileOptions,
  1197. this->Position->BuildSystemDirectory->CompileOptions,
  1198. parent->BuildSystemDirectory->CompileOptionsBacktraces,
  1199. this->Position->BuildSystemDirectory->CompileOptionsBacktraces,
  1200. this->Position->CompileOptionsPosition);
  1201. }
  1202. cmState* cmState::Snapshot::GetState() const
  1203. {
  1204. return this->State;
  1205. }
  1206. cmState::Directory cmState::Snapshot::GetDirectory() const
  1207. {
  1208. return Directory(this->Position->BuildSystemDirectory, *this);
  1209. }
  1210. void cmState::Snapshot::SetProjectName(const std::string& name)
  1211. {
  1212. this->Position->BuildSystemDirectory->ProjectName = name;
  1213. }
  1214. std::string cmState::Snapshot::GetProjectName() const
  1215. {
  1216. return this->Position->BuildSystemDirectory->ProjectName;
  1217. }
  1218. cmState::Directory::Directory(
  1219. cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter,
  1220. const cmState::Snapshot& snapshot)
  1221. : DirectoryState(iter), Snapshot_(snapshot)
  1222. {
  1223. }
  1224. template <typename T, typename U>
  1225. cmStringRange GetPropertyContent(T const& content, U contentEndPosition)
  1226. {
  1227. std::vector<std::string>::const_iterator end =
  1228. content.begin() + contentEndPosition;
  1229. std::vector<std::string>::const_reverse_iterator rbegin =
  1230. cmMakeReverseIterator(end);
  1231. rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
  1232. return cmMakeRange(rbegin.base(), end);
  1233. }
  1234. template <typename T, typename U, typename V>
  1235. cmBacktraceRange GetPropertyBacktraces(T const& content,
  1236. U const& backtraces,
  1237. V contentEndPosition)
  1238. {
  1239. std::vector<std::string>::const_iterator entryEnd =
  1240. content.begin() + contentEndPosition;
  1241. std::vector<std::string>::const_reverse_iterator rbegin =
  1242. cmMakeReverseIterator(entryEnd);
  1243. rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
  1244. std::vector<cmListFileBacktrace>::const_iterator it =
  1245. backtraces.begin() + std::distance(content.begin(), rbegin.base());
  1246. std::vector<cmListFileBacktrace>::const_iterator end = backtraces.end();
  1247. return cmMakeRange(it, end);
  1248. }
  1249. template <typename T, typename U, typename V>
  1250. void AppendEntry(T& content, U& backtraces, V& endContentPosition,
  1251. const std::string& value, const cmListFileBacktrace& lfbt)
  1252. {
  1253. if (value.empty())
  1254. {
  1255. return;
  1256. }
  1257. assert(endContentPosition == content.size());
  1258. content.push_back(value);
  1259. backtraces.push_back(lfbt);
  1260. endContentPosition = content.size();
  1261. }
  1262. template <typename T, typename U, typename V>
  1263. void SetContent(T& content, U& backtraces, V& endContentPosition,
  1264. const std::string& vec, const cmListFileBacktrace& lfbt)
  1265. {
  1266. assert(endContentPosition == content.size());
  1267. content.resize(content.size() + 2);
  1268. backtraces.resize(backtraces.size() + 2);
  1269. content.back() = vec;
  1270. backtraces.back() = lfbt;
  1271. endContentPosition = content.size();
  1272. }
  1273. template <typename T, typename U, typename V>
  1274. void ClearContent(T& content, U& backtraces, V& endContentPosition)
  1275. {
  1276. assert(endContentPosition == content.size());
  1277. content.resize(content.size() + 1);
  1278. backtraces.resize(backtraces.size() + 1);
  1279. endContentPosition = content.size();
  1280. }
  1281. cmStringRange
  1282. cmState::Directory::GetIncludeDirectoriesEntries() const
  1283. {
  1284. return GetPropertyContent(this->DirectoryState->IncludeDirectories,
  1285. this->Snapshot_.Position->IncludeDirectoryPosition);
  1286. }
  1287. cmBacktraceRange
  1288. cmState::Directory::GetIncludeDirectoriesEntryBacktraces() const
  1289. {
  1290. return GetPropertyBacktraces(this->DirectoryState->IncludeDirectories,
  1291. this->DirectoryState->IncludeDirectoryBacktraces,
  1292. this->Snapshot_.Position->IncludeDirectoryPosition);
  1293. }
  1294. void cmState::Directory::AppendIncludeDirectoriesEntry(
  1295. const std::string& vec, const cmListFileBacktrace& lfbt)
  1296. {
  1297. AppendEntry(this->DirectoryState->IncludeDirectories,
  1298. this->DirectoryState->IncludeDirectoryBacktraces,
  1299. this->Snapshot_.Position->IncludeDirectoryPosition,
  1300. vec, lfbt);
  1301. }
  1302. void cmState::Directory::PrependIncludeDirectoriesEntry(
  1303. const std::string& vec, const cmListFileBacktrace& lfbt)
  1304. {
  1305. std::vector<std::string>::iterator entryEnd =
  1306. this->DirectoryState->IncludeDirectories.begin()
  1307. + this->Snapshot_.Position->IncludeDirectoryPosition;
  1308. std::vector<std::string>::reverse_iterator rend =
  1309. this->DirectoryState->IncludeDirectories.rend();
  1310. std::vector<std::string>::reverse_iterator rbegin =
  1311. cmMakeReverseIterator(entryEnd);
  1312. rbegin = std::find(rbegin, rend, cmPropertySentinal);
  1313. std::vector<std::string>::iterator entryIt = rbegin.base();
  1314. std::vector<std::string>::iterator entryBegin =
  1315. this->DirectoryState->IncludeDirectories.begin();
  1316. std::vector<cmListFileBacktrace>::iterator btIt =
  1317. this->DirectoryState->IncludeDirectoryBacktraces.begin()
  1318. + std::distance(entryBegin, entryIt);
  1319. this->DirectoryState->IncludeDirectories.insert(entryIt, vec);
  1320. this->DirectoryState->IncludeDirectoryBacktraces.insert(btIt, lfbt);
  1321. this->Snapshot_.Position->IncludeDirectoryPosition =
  1322. this->DirectoryState->IncludeDirectories.size();
  1323. }
  1324. void cmState::Directory::SetIncludeDirectories(
  1325. const std::string& vec, const cmListFileBacktrace& lfbt)
  1326. {
  1327. SetContent(this->DirectoryState->IncludeDirectories,
  1328. this->DirectoryState->IncludeDirectoryBacktraces,
  1329. this->Snapshot_.Position->IncludeDirectoryPosition,
  1330. vec, lfbt);
  1331. }
  1332. void cmState::Directory::ClearIncludeDirectories()
  1333. {
  1334. ClearContent(this->DirectoryState->IncludeDirectories,
  1335. this->DirectoryState->IncludeDirectoryBacktraces,
  1336. this->Snapshot_.Position->IncludeDirectoryPosition);
  1337. }
  1338. cmStringRange cmState::Directory::GetCompileDefinitionsEntries() const
  1339. {
  1340. return GetPropertyContent(this->DirectoryState->CompileDefinitions,
  1341. this->Snapshot_.Position->CompileDefinitionsPosition);
  1342. }
  1343. cmBacktraceRange
  1344. cmState::Directory::GetCompileDefinitionsEntryBacktraces() const
  1345. {
  1346. return GetPropertyBacktraces(this->DirectoryState->CompileDefinitions,
  1347. this->DirectoryState->CompileDefinitionsBacktraces,
  1348. this->Snapshot_.Position->CompileDefinitionsPosition);
  1349. }
  1350. void cmState::Directory::AppendCompileDefinitionsEntry(const std::string& vec,
  1351. const cmListFileBacktrace& lfbt)
  1352. {
  1353. AppendEntry(this->DirectoryState->CompileDefinitions,
  1354. this->DirectoryState->CompileDefinitionsBacktraces,
  1355. this->Snapshot_.Position->CompileDefinitionsPosition,
  1356. vec, lfbt);
  1357. }
  1358. void cmState::Directory::SetCompileDefinitions(const std::string& vec,
  1359. const cmListFileBacktrace& lfbt)
  1360. {
  1361. SetContent(this->DirectoryState->CompileDefinitions,
  1362. this->DirectoryState->CompileDefinitionsBacktraces,
  1363. this->Snapshot_.Position->CompileDefinitionsPosition,
  1364. vec, lfbt);
  1365. }
  1366. void cmState::Directory::ClearCompileDefinitions()
  1367. {
  1368. ClearContent(this->DirectoryState->CompileDefinitions,
  1369. this->DirectoryState->CompileDefinitionsBacktraces,
  1370. this->Snapshot_.Position->CompileDefinitionsPosition);
  1371. }
  1372. cmStringRange cmState::Directory::GetCompileOptionsEntries() const
  1373. {
  1374. return GetPropertyContent(this->DirectoryState->CompileOptions,
  1375. this->Snapshot_.Position->CompileOptionsPosition);
  1376. }
  1377. cmBacktraceRange cmState::Directory::GetCompileOptionsEntryBacktraces() const
  1378. {
  1379. return GetPropertyBacktraces(this->DirectoryState->CompileOptions,
  1380. this->DirectoryState->CompileOptionsBacktraces,
  1381. this->Snapshot_.Position->CompileOptionsPosition);
  1382. }
  1383. void
  1384. cmState::Directory::AppendCompileOptionsEntry(const std::string& vec,
  1385. const cmListFileBacktrace& lfbt)
  1386. {
  1387. AppendEntry(this->DirectoryState->CompileOptions,
  1388. this->DirectoryState->CompileOptionsBacktraces,
  1389. this->Snapshot_.Position->CompileOptionsPosition,
  1390. vec, lfbt);
  1391. }
  1392. void cmState::Directory::SetCompileOptions(const std::string& vec,
  1393. const cmListFileBacktrace& lfbt)
  1394. {
  1395. SetContent(this->DirectoryState->CompileOptions,
  1396. this->DirectoryState->CompileOptionsBacktraces,
  1397. this->Snapshot_.Position->CompileOptionsPosition,
  1398. vec, lfbt);
  1399. }
  1400. void cmState::Directory::ClearCompileOptions()
  1401. {
  1402. ClearContent(this->DirectoryState->CompileOptions,
  1403. this->DirectoryState->CompileOptionsBacktraces,
  1404. this->Snapshot_.Position->CompileOptionsPosition);
  1405. }
  1406. bool cmState::Snapshot::StrictWeakOrder::operator()(
  1407. const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) const
  1408. {
  1409. return lhs.Position.StrictWeakOrdered(rhs.Position);
  1410. }
  1411. void cmState::Directory::SetProperty(const std::string& prop,
  1412. const char* value,
  1413. cmListFileBacktrace lfbt)
  1414. {
  1415. if (prop == "INCLUDE_DIRECTORIES")
  1416. {
  1417. if (!value)
  1418. {
  1419. this->ClearIncludeDirectories();
  1420. return;
  1421. }
  1422. this->SetIncludeDirectories(value, lfbt);
  1423. return;
  1424. }
  1425. if (prop == "COMPILE_OPTIONS")
  1426. {
  1427. if (!value)
  1428. {
  1429. this->ClearCompileOptions();
  1430. return;
  1431. }
  1432. this->SetCompileOptions(value, lfbt);
  1433. return;
  1434. }
  1435. if (prop == "COMPILE_DEFINITIONS")
  1436. {
  1437. if (!value)
  1438. {
  1439. this->ClearCompileDefinitions();
  1440. return;
  1441. }
  1442. this->SetCompileDefinitions(value, lfbt);
  1443. return;
  1444. }
  1445. this->DirectoryState->Properties.SetProperty(prop, value);
  1446. }
  1447. void cmState::Directory::AppendProperty(const std::string& prop,
  1448. const char* value,
  1449. bool asString,
  1450. cmListFileBacktrace lfbt)
  1451. {
  1452. if (prop == "INCLUDE_DIRECTORIES")
  1453. {
  1454. this->AppendIncludeDirectoriesEntry(value, lfbt);
  1455. return;
  1456. }
  1457. if (prop == "COMPILE_OPTIONS")
  1458. {
  1459. this->AppendCompileOptionsEntry(value, lfbt);
  1460. return;
  1461. }
  1462. if (prop == "COMPILE_DEFINITIONS")
  1463. {
  1464. this->AppendCompileDefinitionsEntry(value, lfbt);
  1465. return;
  1466. }
  1467. this->DirectoryState->Properties.AppendProperty(prop, value, asString);
  1468. }
  1469. const char*cmState::Directory::GetProperty(const std::string& prop) const
  1470. {
  1471. const bool chain = this->Snapshot_.State->
  1472. IsPropertyChained(prop, cmProperty::DIRECTORY);
  1473. return this->GetProperty(prop, chain);
  1474. }
  1475. const char*
  1476. cmState::Directory::GetProperty(const std::string& prop, bool chain) const
  1477. {
  1478. static std::string output;
  1479. output = "";
  1480. if (prop == "PARENT_DIRECTORY")
  1481. {
  1482. cmState::Snapshot parent =
  1483. this->Snapshot_.GetBuildsystemDirectoryParent();
  1484. if(parent.IsValid())
  1485. {
  1486. return parent.GetDirectory().GetCurrentSource();
  1487. }
  1488. return "";
  1489. }
  1490. else if (prop == "LISTFILE_STACK")
  1491. {
  1492. std::vector<std::string> listFiles;
  1493. cmState::Snapshot snp = this->Snapshot_;
  1494. while (snp.IsValid())
  1495. {
  1496. listFiles.push_back(snp.GetExecutionListFile());
  1497. snp = snp.GetCallStackParent();
  1498. }
  1499. std::reverse(listFiles.begin(), listFiles.end());
  1500. output = cmJoin(listFiles, ";");
  1501. return output.c_str();
  1502. }
  1503. else if ( prop == "CACHE_VARIABLES" )
  1504. {
  1505. output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";");
  1506. return output.c_str();
  1507. }
  1508. else if (prop == "VARIABLES")
  1509. {
  1510. std::vector<std::string> res = this->Snapshot_.ClosureKeys();
  1511. std::vector<std::string> cacheKeys =
  1512. this->Snapshot_.State->GetCacheEntryKeys();
  1513. res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
  1514. std::sort(res.begin(), res.end());
  1515. output = cmJoin(res, ";");
  1516. return output.c_str();
  1517. }
  1518. else if (prop == "INCLUDE_DIRECTORIES")
  1519. {
  1520. output = cmJoin(this->GetIncludeDirectoriesEntries(), ";");
  1521. return output.c_str();
  1522. }
  1523. else if (prop == "COMPILE_OPTIONS")
  1524. {
  1525. output = cmJoin(this->GetCompileOptionsEntries(), ";");
  1526. return output.c_str();
  1527. }
  1528. else if (prop == "COMPILE_DEFINITIONS")
  1529. {
  1530. output = cmJoin(this->GetCompileDefinitionsEntries(), ";");
  1531. return output.c_str();
  1532. }
  1533. const char *retVal = this->DirectoryState->Properties.GetPropertyValue(prop);
  1534. if (!retVal && chain)
  1535. {
  1536. Snapshot parentSnapshot = this->Snapshot_.GetBuildsystemDirectoryParent();
  1537. if (parentSnapshot.IsValid())
  1538. {
  1539. return parentSnapshot.GetDirectory().GetProperty(prop, chain);
  1540. }
  1541. return this->Snapshot_.State->GetGlobalProperty(prop);
  1542. }
  1543. return retVal;
  1544. }
  1545. bool cmState::Directory::GetPropertyAsBool(const std::string& prop) const
  1546. {
  1547. return cmSystemTools::IsOn(this->GetProperty(prop));
  1548. }
  1549. std::vector<std::string> cmState::Directory::GetPropertyKeys() const
  1550. {
  1551. std::vector<std::string> keys;
  1552. keys.reserve(this->DirectoryState->Properties.size());
  1553. for(cmPropertyMap::const_iterator it =
  1554. this->DirectoryState->Properties.begin();
  1555. it != this->DirectoryState->Properties.end(); ++it)
  1556. {
  1557. keys.push_back(it->first);
  1558. }
  1559. return keys;
  1560. }
  1561. bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs)
  1562. {
  1563. return lhs.Position == rhs.Position;
  1564. }
  1565. bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs)
  1566. {
  1567. return lhs.Position != rhs.Position;
  1568. }
  1569. static bool ParseEntryWithoutType(const std::string& entry,
  1570. std::string& var,
  1571. std::string& value)
  1572. {
  1573. // input line is: key=value
  1574. static cmsys::RegularExpression reg(
  1575. "^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
  1576. // input line is: "key"=value
  1577. static cmsys::RegularExpression regQuoted(
  1578. "^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
  1579. bool flag = false;
  1580. if(regQuoted.find(entry))
  1581. {
  1582. var = regQuoted.match(1);
  1583. value = regQuoted.match(2);
  1584. flag = true;
  1585. }
  1586. else if (reg.find(entry))
  1587. {
  1588. var = reg.match(1);
  1589. value = reg.match(2);
  1590. flag = true;
  1591. }
  1592. // if value is enclosed in single quotes ('foo') then remove them
  1593. // it is used to enclose trailing space or tab
  1594. if (flag &&
  1595. value.size() >= 2 &&
  1596. value[0] == '\'' &&
  1597. value[value.size() - 1] == '\'')
  1598. {
  1599. value = value.substr(1,
  1600. value.size() - 2);
  1601. }
  1602. return flag;
  1603. }
  1604. bool cmState::ParseCacheEntry(const std::string& entry,
  1605. std::string& var,
  1606. std::string& value,
  1607. CacheEntryType& type)
  1608. {
  1609. // input line is: key:type=value
  1610. static cmsys::RegularExpression reg(
  1611. "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
  1612. // input line is: "key":type=value
  1613. static cmsys::RegularExpression regQuoted(
  1614. "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
  1615. bool flag = false;
  1616. if(regQuoted.find(entry))
  1617. {
  1618. var = regQuoted.match(1);
  1619. type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str());
  1620. value = regQuoted.match(3);
  1621. flag = true;
  1622. }
  1623. else if (reg.find(entry))
  1624. {
  1625. var = reg.match(1);
  1626. type = cmState::StringToCacheEntryType(reg.match(2).c_str());
  1627. value = reg.match(3);
  1628. flag = true;
  1629. }
  1630. // if value is enclosed in single quotes ('foo') then remove them
  1631. // it is used to enclose trailing space or tab
  1632. if (flag &&
  1633. value.size() >= 2 &&
  1634. value[0] == '\'' &&
  1635. value[value.size() - 1] == '\'')
  1636. {
  1637. value = value.substr(1,
  1638. value.size() - 2);
  1639. }
  1640. if (!flag)
  1641. {
  1642. return ParseEntryWithoutType(entry, var, value);
  1643. }
  1644. return flag;
  1645. }