diff options
author | Brad King <brad.king@kitware.com> | 2014-07-18 18:04:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-07-21 15:00:34 (GMT) |
commit | 133cd996d161cd349e67d90052ac4e20d9488620 (patch) | |
tree | 856d96a96c176a48aa1993018a078dc67c2019ce /Source/cmTarget.cxx | |
parent | a4d58722a47b3712d1f78683371f88a3b6182a59 (diff) | |
download | CMake-133cd996d161cd349e67d90052ac4e20d9488620.zip CMake-133cd996d161cd349e67d90052ac4e20d9488620.tar.gz CMake-133cd996d161cd349e67d90052ac4e20d9488620.tar.bz2 |
cmTarget: Drop internal cache of build properties
These use a huge amount of memory that accumulates as generation
proceeds. On the Unix Makefiles generator, only GetIncludeDirectories
and GetCompileDefinitions are even called more than once per target
(once for build files, once for dependency scanning preprocessor info).
Another approach will be needed to avoid duplicate computation in the
cases where it does occur.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 134 |
1 files changed, 43 insertions, 91 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a812df7..9d00591 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -196,11 +196,9 @@ public: public: TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge, cmLinkImplItem const& item = NoLinkImplItem) - : ge(cge), Cached(false), LinkImplItem(item) + : ge(cge), LinkImplItem(item) {} const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge; - std::vector<std::string> CachedEntries; - bool Cached; cmLinkImplItem const& LinkImplItem; }; std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; @@ -635,49 +633,37 @@ static bool processSources(cmTarget const* tgt, for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator it = entries.begin(), end = entries.end(); it != end; ++it) { - bool cacheSources = false; - std::vector<std::string> entrySources = (*it)->CachedEntries; - if(entrySources.empty()) + std::vector<std::string> entrySources; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt, + tgt, + dagChecker), + entrySources); + + if ((*it)->ge->GetHadContextSensitiveCondition()) { - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - tgt, - dagChecker), - entrySources); + contextDependent = true; + } - if ((*it)->ge->GetHadContextSensitiveCondition()) - { - contextDependent = true; - } - else if (mf->IsGeneratingBuildSystem()) - { - cacheSources = true; - } + for(std::vector<std::string>::iterator i = entrySources.begin(); + i != entrySources.end(); ++i) + { + std::string& src = *i; - for(std::vector<std::string>::iterator i = entrySources.begin(); - i != entrySources.end(); ++i) + cmSourceFile* sf = mf->GetOrCreateSource(src); + std::string e; + src = sf->GetFullPath(&e); + if(src.empty()) { - std::string& src = *i; - - cmSourceFile* sf = mf->GetOrCreateSource(src); - std::string e; - src = sf->GetFullPath(&e); - if(src.empty()) + if(!e.empty()) { - if(!e.empty()) - { - cmake* cm = mf->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e, - tgt->GetBacktrace()); - } - return contextDependent; + cmake* cm = mf->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e, + tgt->GetBacktrace()); } - } - if (cacheSources) - { - (*it)->CachedEntries = entrySources; + return contextDependent; } } std::string usedSources; @@ -2003,27 +1989,14 @@ static void processIncludeDirectories(cmTarget const* tgt, std::string const& targetName = item; bool const fromImported = item.Target && item.Target->IsImported(); bool const checkCMP0027 = item.FromGenex; - bool testIsOff = true; - bool cacheIncludes = false; - std::vector<std::string>& entryIncludes = (*it)->CachedEntries; - if(!entryIncludes.empty()) - { - testIsOff = false; - } - else - { - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - dagChecker), - entryIncludes); - if (mf->IsGeneratingBuildSystem() - && !(*it)->ge->GetHadContextSensitiveCondition()) - { - cacheIncludes = true; - } - } + std::vector<std::string> entryIncludes; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt, + dagChecker), + entryIncludes); + std::string usedIncludes; for(std::vector<std::string>::iterator li = entryIncludes.begin(); li != entryIncludes.end(); ++li) @@ -2105,7 +2078,7 @@ static void processIncludeDirectories(cmTarget const* tgt, } } - if (testIsOff && !cmSystemTools::IsOff(li->c_str())) + if (!cmSystemTools::IsOff(li->c_str())) { cmSystemTools::ConvertToUnixSlashes(*li); } @@ -2120,10 +2093,6 @@ static void processIncludeDirectories(cmTarget const* tgt, } } } - if (cacheIncludes) - { - (*it)->CachedEntries = entryIncludes; - } if (!usedIncludes.empty()) { mf->GetCMakeInstance()->IssueMessage(cmake::LOG, @@ -2229,33 +2198,16 @@ static void processCompileOptionsInternal(cmTarget const* tgt, for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator it = entries.begin(), end = entries.end(); it != end; ++it) { - std::vector<std::string>& entriesRef = (*it)->CachedEntries; - std::vector<std::string> localEntries; - std::vector<std::string>* entryOptions = &entriesRef; - if(!(*it)->Cached) - { - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, - config, - false, - tgt, - dagChecker), - localEntries); - if (mf->IsGeneratingBuildSystem() - && !(*it)->ge->GetHadContextSensitiveCondition()) - { - // Cache the result. - *entryOptions = localEntries; - (*it)->Cached = true; - } - else - { - // Use the context-sensitive results here. - entryOptions = &localEntries; - } - } + std::vector<std::string> entryOptions; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt, + dagChecker), + entryOptions); std::string usedOptions; for(std::vector<std::string>::iterator - li = entryOptions->begin(); li != entryOptions->end(); ++li) + li = entryOptions.begin(); li != entryOptions.end(); ++li) { std::string const& opt = *li; |