diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmFileCommand.cxx | 7 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionEvaluationFile.cxx | 40 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionEvaluationFile.h | 15 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 56 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 8 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 26 | ||||
-rw-r--r-- | Source/cmLinkedTree.h | 6 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 48 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 155 | ||||
-rw-r--r-- | Source/cmMakefile.h | 22 | ||||
-rw-r--r-- | Source/cmState.cxx | 171 | ||||
-rw-r--r-- | Source/cmState.h | 15 | ||||
-rw-r--r-- | Source/cmXCodeObject.cxx | 6 |
15 files changed, 345 insertions, 234 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9a7ae8b..c9fec35 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150804) +set(CMake_VERSION_PATCH 20150806) #set(CMake_VERSION_RC 1) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 0daed66..87faf84 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3573,11 +3573,8 @@ void cmFileCommand::AddEvaluationFile(const std::string &inputName, cmsys::auto_ptr<cmCompiledGeneratorExpression> conditionCge = conditionGe.Parse(condition); - this->Makefile->GetGlobalGenerator()->AddEvaluationFile(inputName, - outputCge, - this->Makefile, - conditionCge, - inputIsContent); + this->Makefile->AddEvaluationFile(inputName, outputCge, + conditionCge, inputIsContent); } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 92ff314..e4d9f10 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -25,19 +25,18 @@ cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile( const std::string &input, cmsys::auto_ptr<cmCompiledGeneratorExpression> outputFileExpr, - cmMakefile *makefile, cmsys::auto_ptr<cmCompiledGeneratorExpression> condition, bool inputIsContent) : Input(input), OutputFileExpr(outputFileExpr), - Makefile(makefile), Condition(condition), InputIsContent(inputIsContent) { } //---------------------------------------------------------------------------- -void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, +void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg, + const std::string& config, const std::string& lang, cmCompiledGeneratorExpression* inputExpression, std::map<std::string, std::string> &outputFiles, mode_t perm) @@ -45,7 +44,8 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, std::string rawCondition = this->Condition->GetInput(); if (!rawCondition.empty()) { - std::string condResult = this->Condition->Evaluate(this->Makefile, config, + std::string condResult = this->Condition->Evaluate(lg->GetMakefile(), + config, false, 0, 0, 0, lang); if (condResult == "0") { @@ -56,16 +56,17 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, std::ostringstream e; e << "Evaluation file condition \"" << rawCondition << "\" did " "not evaluate to valid content. Got \"" << condResult << "\"."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } } const std::string outputFileName - = this->OutputFileExpr->Evaluate(this->Makefile, config, + = this->OutputFileExpr->Evaluate(lg->GetMakefile(), config, false, 0, 0, 0, lang); const std::string outputContent - = inputExpression->Evaluate(this->Makefile, config, + = inputExpression->Evaluate(lg->GetMakefile(), + config, false, 0, 0, 0, lang); std::map<std::string, std::string>::iterator it @@ -81,11 +82,11 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, e << "Evaluation file to be written multiple times for different " "configurations or languages with different content:\n " << outputFileName; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - this->Makefile->AddCMakeOutputFile(outputFileName.c_str()); + lg->GetMakefile()->AddCMakeOutputFile(outputFileName.c_str()); this->Files.push_back(outputFileName); outputFiles[outputFileName] = outputContent; @@ -100,18 +101,19 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, //---------------------------------------------------------------------------- void cmGeneratorExpressionEvaluationFile::CreateOutputFile( - std::string const& config) + cmLocalGenerator *lg, std::string const& config) { std::vector<std::string> enabledLanguages; - cmGlobalGenerator *gg = this->Makefile->GetGlobalGenerator(); + cmGlobalGenerator *gg = lg->GetGlobalGenerator(); gg->GetEnabledLanguages(enabledLanguages); for(std::vector<std::string>::const_iterator le = enabledLanguages.begin(); le != enabledLanguages.end(); ++le) { - std::string name = this->OutputFileExpr->Evaluate(this->Makefile, config, + std::string name = this->OutputFileExpr->Evaluate(lg->GetMakefile(), + config, false, 0, 0, 0, *le); - cmSourceFile* sf = this->Makefile->GetOrCreateSource(name); + cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(name); sf->SetProperty("GENERATED", "1"); gg->SetFilenameTargetDepends(sf, @@ -120,7 +122,7 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile( } //---------------------------------------------------------------------------- -void cmGeneratorExpressionEvaluationFile::Generate() +void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator *lg) { mode_t perm = 0; std::string inputContent; @@ -130,14 +132,14 @@ void cmGeneratorExpressionEvaluationFile::Generate() } else { - this->Makefile->AddCMakeDependFile(this->Input.c_str()); + lg->GetMakefile()->AddCMakeDependFile(this->Input.c_str()); cmSystemTools::GetPermissions(this->Input.c_str(), perm); cmsys::ifstream fin(this->Input.c_str()); if(!fin) { std::ostringstream e; e << "Evaluation file \"" << this->Input << "\" cannot be read."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -159,7 +161,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() std::map<std::string, std::string> outputFiles; std::vector<std::string> allConfigs; - this->Makefile->GetConfigurations(allConfigs); + lg->GetMakefile()->GetConfigurations(allConfigs); if (allConfigs.empty()) { @@ -167,7 +169,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() } std::vector<std::string> enabledLanguages; - cmGlobalGenerator *gg = this->Makefile->GetGlobalGenerator(); + cmGlobalGenerator *gg = lg->GetGlobalGenerator(); gg->GetEnabledLanguages(enabledLanguages); for(std::vector<std::string>::const_iterator le = enabledLanguages.begin(); @@ -176,7 +178,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() for(std::vector<std::string>::const_iterator li = allConfigs.begin(); li != allConfigs.end(); ++li) { - this->Generate(*li, *le, inputExpression.get(), outputFiles, perm); + this->Generate(lg, *li, *le, inputExpression.get(), outputFiles, perm); if(cmSystemTools::GetFatalErrorOccured()) { return; diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index 5d8b54c..ad41274 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -18,31 +18,32 @@ #include "cmGeneratorExpression.h" +class cmLocalGenerator; + //---------------------------------------------------------------------------- class cmGeneratorExpressionEvaluationFile { public: cmGeneratorExpressionEvaluationFile(const std::string &input, cmsys::auto_ptr<cmCompiledGeneratorExpression> outputFileExpr, - cmMakefile *makefile, cmsys::auto_ptr<cmCompiledGeneratorExpression> condition, bool inputIsContent); - void Generate(); + void Generate(cmLocalGenerator* lg); std::vector<std::string> GetFiles() const { return this->Files; } - void CreateOutputFile(std::string const& config); + void CreateOutputFile(cmLocalGenerator* lg, std::string const& config); private: - void Generate(const std::string& config, const std::string& lang, - cmCompiledGeneratorExpression* inputExpression, - std::map<std::string, std::string> &outputFiles, mode_t perm); + void Generate(cmLocalGenerator* lg, const std::string& config, + const std::string& lang, + cmCompiledGeneratorExpression* inputExpression, + std::map<std::string, std::string> &outputFiles, mode_t perm); private: const std::string Input; const cmsys::auto_ptr<cmCompiledGeneratorExpression> OutputFileExpr; - cmMakefile *Makefile; const cmsys::auto_ptr<cmCompiledGeneratorExpression> Condition; std::vector<std::string> Files; const bool InputIsContent; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b437942..3c818ff 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -44,7 +44,6 @@ typedef struct { #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGeneratorExpression.h" -#include "cmGeneratorExpressionEvaluationFile.h" #include "cmExportBuildFileGenerator.h" #include "cmCPackPropertiesGenerator.h" #include "cmAlgorithms.h" @@ -1597,9 +1596,6 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmDeleteAll(this->GeneratorTargets); this->GeneratorTargets.clear(); - cmDeleteAll(this->EvaluationFiles); - this->EvaluationFiles.clear(); - cmDeleteAll(this->BuildExportSets); this->BuildExportSets.clear(); @@ -3068,61 +3064,21 @@ cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const { void cmGlobalGenerator::CreateEvaluationSourceFiles( std::string const& config) const { - for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator - li = this->EvaluationFiles.begin(); - li != this->EvaluationFiles.end(); - ++li) + unsigned int i; + for (i = 0; i < this->LocalGenerators.size(); ++i) { - (*li)->CreateOutputFile(config); + this->LocalGenerators[i]->CreateEvaluationFileOutputs(config); } } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddEvaluationFile(const std::string &inputFile, - cmsys::auto_ptr<cmCompiledGeneratorExpression> outputExpr, - cmMakefile *makefile, - cmsys::auto_ptr<cmCompiledGeneratorExpression> condition, - bool inputIsContent) -{ - this->EvaluationFiles.push_back( - new cmGeneratorExpressionEvaluationFile(inputFile, outputExpr, - makefile, condition, - inputIsContent)); -} - -//---------------------------------------------------------------------------- void cmGlobalGenerator::ProcessEvaluationFiles() { std::vector<std::string> generatedFiles; - for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator - li = this->EvaluationFiles.begin(); - li != this->EvaluationFiles.end(); - ++li) + unsigned int i; + for (i = 0; i < this->LocalGenerators.size(); ++i) { - (*li)->Generate(); - if (cmSystemTools::GetFatalErrorOccured()) - { - return; - } - std::vector<std::string> files = (*li)->GetFiles(); - std::sort(files.begin(), files.end()); - - std::vector<std::string> intersection; - std::set_intersection(files.begin(), files.end(), - generatedFiles.begin(), generatedFiles.end(), - std::back_inserter(intersection)); - if (!intersection.empty()) - { - cmSystemTools::Error("Files to be generated by multiple different " - "commands: ", cmWrap('"', intersection, '"', " ").c_str()); - return; - } - - generatedFiles.insert(generatedFiles.end(), - files.begin(), files.end()); - std::vector<std::string>::iterator newIt = - generatedFiles.end() - files.size(); - std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end()); + this->LocalGenerators[i]->ProcessEvaluationFiles(generatedFiles); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9492372..3402fbc 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -34,7 +34,6 @@ class cmake; class cmGeneratorTarget; -class cmGeneratorExpressionEvaluationFile; class cmMakefile; class cmLocalGenerator; class cmExternalMakefileProjectGenerator; @@ -334,12 +333,6 @@ public: static std::string EscapeJSON(const std::string& s); - void AddEvaluationFile(const std::string &inputFile, - cmsys::auto_ptr<cmCompiledGeneratorExpression> outputName, - cmMakefile *makefile, - cmsys::auto_ptr<cmCompiledGeneratorExpression> condition, - bool inputIsContent); - void ProcessEvaluationFiles(); std::map<std::string, cmExportBuildFileGenerator*>& GetBuildExportSets() @@ -436,7 +429,6 @@ protected: TargetMap TotalTargets; TargetMap AliasTargets; TargetMap ImportedTargets; - std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles; const char* GetPredefinedTargetsFolder(); virtual bool UseFolderProperty(); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 5bdd35f..088f0e1 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1053,23 +1053,21 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) { knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); } - } - knownDependencies.insert( "CMakeCache.txt" ); - - for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator - li = this->EvaluationFiles.begin(); - li != this->EvaluationFiles.end(); - ++li) - { - //get all the files created by generator expressions and convert them - //to ninja paths - std::vector<std::string> files = (*li)->GetFiles(); - typedef std::vector<std::string>::const_iterator vect_it; - for(vect_it j = files.begin(); j != files.end(); ++j) + std::vector<cmGeneratorExpressionEvaluationFile*> const& ef = + (*i)->GetMakefile()->GetEvaluationFiles(); + for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator + li = ef.begin(); li != ef.end(); ++li) { - knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + //get all the files created by generator expressions and convert them + //to ninja paths + std::vector<std::string> evaluationFiles = (*li)->GetFiles(); + for(vect_it j = evaluationFiles.begin(); j != evaluationFiles.end(); ++j) + { + knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + } } } + knownDependencies.insert( "CMakeCache.txt" ); for(TargetAliasMap::const_iterator i= this->TargetAliases.begin(); i != this->TargetAliases.end(); diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index df00b30..3bcb940 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -155,6 +155,12 @@ public: return iterator(this, 1); } + void Clear() + { + this->UpPositions.clear(); + this->Data.clear(); + } + private: T& GetReference(PositionType pos) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4ec77a1..a831d88 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -16,6 +16,7 @@ #include "cmGlobalGenerator.h" #include "cmInstallGenerator.h" #include "cmInstallFilesGenerator.h" +#include "cmGeneratorExpressionEvaluationFile.h" #include "cmInstallScriptGenerator.h" #include "cmInstallTargetGenerator.h" #include "cmMakefile.h" @@ -212,6 +213,53 @@ void cmLocalGenerator::GenerateTestFiles() } } +void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config) +{ + std::vector<cmGeneratorExpressionEvaluationFile*> ef = + this->Makefile->GetEvaluationFiles(); + for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator + li = ef.begin(); li != ef.end(); ++li) + { + (*li)->CreateOutputFile(this, config); + } +} + +void cmLocalGenerator::ProcessEvaluationFiles( + std::vector<std::string>& generatedFiles) +{ + std::vector<cmGeneratorExpressionEvaluationFile*> ef = + this->Makefile->GetEvaluationFiles(); + for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator + li = ef.begin(); + li != ef.end(); + ++li) + { + (*li)->Generate(this); + if (cmSystemTools::GetFatalErrorOccured()) + { + return; + } + std::vector<std::string> files = (*li)->GetFiles(); + std::sort(files.begin(), files.end()); + + std::vector<std::string> intersection; + std::set_intersection(files.begin(), files.end(), + generatedFiles.begin(), generatedFiles.end(), + std::back_inserter(intersection)); + if (!intersection.empty()) + { + cmSystemTools::Error("Files to be generated by multiple different " + "commands: ", cmWrap('"', intersection, '"', " ").c_str()); + return; + } + + generatedFiles.insert(generatedFiles.end(), files.begin(), files.end()); + std::vector<std::string>::iterator newIt = + generatedFiles.end() - files.size(); + std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end()); + } +} + //---------------------------------------------------------------------------- void cmLocalGenerator::GenerateInstallRules() { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 2971574..1c18788 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -305,6 +305,8 @@ public: void IssueMessage(cmake::MessageType t, std::string const& text) const; + void CreateEvaluationFileOutputs(const std::string& config); + void ProcessEvaluationFiles(std::vector<std::string>& generatedFiles); void ComputeObjectMaxPath(); protected: diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4bdc9d5..60a11e1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -21,6 +21,7 @@ #include "cmState.h" #include "cmOutputConverter.h" #include "cmFunctionBlocker.h" +#include "cmGeneratorExpressionEvaluationFile.h" #include "cmListFileCache.h" #include "cmCommandArgumentParserHelper.h" #include "cmGeneratorExpression.h" @@ -189,12 +190,12 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)"); this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{"); + this->StateSnapshot = this->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->StateSnapshot); + // Enter a policy level for this directory. this->PushPolicy(); - // Protect the directory-level policies. - this->PushPolicyBarrier(); - // push empty loop block this->PushLoopBlockBarrier(); @@ -235,12 +236,10 @@ cmMakefile::~cmMakefile() cmDeleteAll(this->ImportedTargetsOwned); cmDeleteAll(this->FinalPassCommands); cmDeleteAll(this->FunctionBlockers); + cmDeleteAll(this->EvaluationFiles); + this->EvaluationFiles.clear(); + this->FunctionBlockers.clear(); - if (this->PolicyStack.size() != 1) - { - cmSystemTools::Error("Internal CMake Error, Policy Stack has not been" - " popped properly"); - } } //---------------------------------------------------------------------------- @@ -468,6 +467,14 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, Makefile(mf), NoPolicyScope(noPolicyScope), CheckCMP0011(false), ReportError(true) { + this->Makefile->PushFunctionBlockerBarrier(); + + this->Makefile->StateSnapshot = + this->Makefile->GetState()->CreateCallStackSnapshot( + this->Makefile->StateSnapshot, + this->Makefile->ContextStack.back()->Name, + this->Makefile->ContextStack.back()->Line, + filenametoread); if(!this->NoPolicyScope) { // Check CMP0011 to determine the policy scope type. @@ -496,37 +503,19 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, break; } } - - // The included file cannot pop our policy scope. - this->Makefile->PushPolicyBarrier(); - this->Makefile->PushFunctionBlockerBarrier(); - - this->Makefile->StateSnapshot = - this->Makefile->GetState()->CreateCallStackSnapshot( - this->Makefile->StateSnapshot, - this->Makefile->ContextStack.back()->Name, - this->Makefile->ContextStack.back()->Line, - filenametoread); } //---------------------------------------------------------------------------- cmMakefile::IncludeScope::~IncludeScope() { - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); - - this->Makefile->PopFunctionBlockerBarrier(this->ReportError); - // Enforce matching policy scopes inside the included file. - this->Makefile->PopPolicyBarrier(this->ReportError); - if(!this->NoPolicyScope) { // If we need to enforce policy CMP0011 then the top entry is the // one we pushed above. If the entry is empty, then the included // script did not set any policies that might affect the includer so // we do not need to enforce the policy. - if(this->CheckCMP0011 && this->Makefile->PolicyStack.back().IsEmpty()) + if(this->CheckCMP0011 + && !this->Makefile->StateSnapshot.HasDefinedPolicyCMP0011()) { this->CheckCMP0011 = false; } @@ -541,6 +530,9 @@ cmMakefile::IncludeScope::~IncludeScope() this->EnforceCMP0011(); } } + this->Makefile->PopPolicyBarrier(this->ReportError); + + this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } //---------------------------------------------------------------------------- @@ -635,8 +627,6 @@ public: ListFileScope(cmMakefile* mf, std::string const& filenametoread) : Makefile(mf), ReportError(true) { - this->Makefile->PushPolicyBarrier(); - long line = 0; std::string name; if (!this->Makefile->ContextStack.empty()) @@ -648,17 +638,14 @@ public: this->Makefile->GetState()->CreateInlineListFileSnapshot( this->Makefile->StateSnapshot, name, line, filenametoread); assert(this->Makefile->StateSnapshot.IsValid()); + this->Makefile->PushFunctionBlockerBarrier(); } ~ListFileScope() { - this->Makefile->StateSnapshot = - this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); - assert(this->Makefile->StateSnapshot.IsValid()); - - this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopPolicyBarrier(this->ReportError); + this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } void Quiet() { this->ReportError = false; } @@ -777,6 +764,23 @@ void cmMakefile::EnforceDirectoryLevelRules() const } } +void cmMakefile::AddEvaluationFile(const std::string& inputFile, + cmsys::auto_ptr<cmCompiledGeneratorExpression> outputName, + cmsys::auto_ptr<cmCompiledGeneratorExpression> condition, + bool inputIsContent) +{ + this->EvaluationFiles.push_back( + new cmGeneratorExpressionEvaluationFile(inputFile, outputName, + condition, + inputIsContent)); +} + +std::vector<cmGeneratorExpressionEvaluationFile*> +cmMakefile::GetEvaluationFiles() const +{ + return this->EvaluationFiles; +} + namespace { struct file_not_persistent @@ -1641,16 +1645,13 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->PushFunctionBlockerBarrier(); this->PushPolicy(true, pm); - this->PushPolicyBarrier(); } void cmMakefile::PopFunctionScope(bool reportError) { - this->PopPolicyBarrier(reportError); this->PopPolicy(); - this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); - assert(this->StateSnapshot.IsValid()); + this->PopPolicyBarrier(reportError); this->PopFunctionBlockerBarrier(reportError); @@ -1678,16 +1679,12 @@ void cmMakefile::PushMacroScope(std::string const& fileName, this->PushFunctionBlockerBarrier(); this->PushPolicy(true, pm); - this->PushPolicyBarrier(); } void cmMakefile::PopMacroScope(bool reportError) { - this->PopPolicyBarrier(reportError); this->PopPolicy(); - - this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); - assert(this->StateSnapshot.IsValid()); + this->PopPolicyBarrier(reportError); this->PopFunctionBlockerBarrier(reportError); } @@ -1707,7 +1704,8 @@ public: this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource(); currentStart += "/CMakeLists.txt"; this->Makefile->StateSnapshot.SetListFile(currentStart); - this->Makefile->PushPolicyBarrier(); + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); this->Makefile->PushFunctionBlockerBarrier(); this->GG = mf->GetGlobalGenerator(); @@ -1796,8 +1794,8 @@ void cmMakefile::ConfigureSubDirectory(cmMakefile *mf) cmSystemTools::Message(msg.c_str()); } - currentStart += "/CMakeLists.txt"; - if(!cmSystemTools::FileExists(currentStart.c_str(), true)) + std::string const currentStartFile = currentStart + "/CMakeLists.txt"; + if (!cmSystemTools::FileExists(currentStartFile, true)) { // The file is missing. Check policy CMP0014. std::ostringstream e; @@ -4754,30 +4752,7 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const { - cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); - - if(status == cmPolicies::REQUIRED_ALWAYS || - status == cmPolicies::REQUIRED_IF_USED) - { - return status; - } - - cmLocalGenerator* lg = this->LocalGenerator; - while(lg) - { - cmMakefile const* mf = lg->GetMakefile(); - for(PolicyStackType::const_reverse_iterator psi = - mf->PolicyStack.rbegin(); psi != mf->PolicyStack.rend(); ++psi) - { - if(psi->IsDefined(id)) - { - status = psi->Get(id); - return status; - } - } - lg = lg->GetParent(); - } - return status; + return this->StateSnapshot.GetPolicy(id); } //---------------------------------------------------------------------------- @@ -4826,15 +4801,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, return false; } - // Update the policy stack from the top to the top-most strong entry. - bool previous_was_weak = true; - for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin(); - previous_was_weak && psi != this->PolicyStack.rend(); ++psi) - { - psi->Set(id, status); - previous_was_weak = psi->Weak; - } - + this->StateSnapshot.SetPolicy(id, status); return true; } @@ -4843,32 +4810,28 @@ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak, cmPolicies::PolicyMap const& pm): Makefile(m), ReportError(true) { + this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState() + ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot); this->Makefile->PushPolicy(weak, pm); - this->Makefile->PushPolicyBarrier(); } //---------------------------------------------------------------------------- cmMakefile::PolicyPushPop::~PolicyPushPop() { - this->Makefile->PopPolicyBarrier(this->ReportError); this->Makefile->PopPolicy(); + this->Makefile->PopPolicyBarrier(this->ReportError); } //---------------------------------------------------------------------------- void cmMakefile::PushPolicy(bool weak, cmPolicies::PolicyMap const& pm) { - // Allocate a new stack entry. - this->PolicyStack.push_back(PolicyStackEntry(pm, weak)); + this->StateSnapshot.PushPolicy(pm, weak); } //---------------------------------------------------------------------------- void cmMakefile::PopPolicy() { - if(this->PolicyStack.size() > this->PolicyBarriers.back()) - { - this->PolicyStack.pop_back(); - } - else + if (!this->StateSnapshot.PopPolicy()) { this->IssueMessage(cmake::FATAL_ERROR, "cmake_policy POP without matching PUSH"); @@ -4876,17 +4839,9 @@ void cmMakefile::PopPolicy() } //---------------------------------------------------------------------------- -void cmMakefile::PushPolicyBarrier() -{ - this->PolicyBarriers.push_back(this->PolicyStack.size()); -} - -//---------------------------------------------------------------------------- void cmMakefile::PopPolicyBarrier(bool reportError) { - // Remove any extra entries pushed on the barrier. - PolicyStackType::size_type barrier = this->PolicyBarriers.back(); - while(this->PolicyStack.size() > barrier) + while (!this->StateSnapshot.CanPopPolicyScope()) { if(reportError) { @@ -4897,8 +4852,8 @@ void cmMakefile::PopPolicyBarrier(bool reportError) this->PopPolicy(); } - // Remove the barrier. - this->PolicyBarriers.pop_back(); + this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); + assert(this->StateSnapshot.IsValid()); } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1e5c301..27e5bce 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -52,6 +52,7 @@ class cmVariableWatch; class cmake; class cmMakefileCall; class cmCMakePolicyCommand; +class cmGeneratorExpressionEvaluationFile; /** \class cmMakefile * \brief Process the input CMakeLists.txt file. @@ -799,6 +800,12 @@ public: void EnforceDirectoryLevelRules() const; + void AddEvaluationFile(const std::string &inputFile, + cmsys::auto_ptr<cmCompiledGeneratorExpression> outputName, + cmsys::auto_ptr<cmCompiledGeneratorExpression> condition, + bool inputIsContent); + std::vector<cmGeneratorExpressionEvaluationFile*> GetEvaluationFiles() const; + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const std::string& name, cmTarget& target); @@ -895,6 +902,8 @@ private: std::vector<cmMakefile*> UnConfiguredDirectories; + std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles; + cmPropertyMap Properties; std::vector<cmCommandContext const*> ContextStack; @@ -909,7 +918,6 @@ private: void PushPolicy(bool weak = false, cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap()); void PopPolicy(); - void PushPolicyBarrier(); void PopPolicyBarrier(bool reportError = true); friend class cmCMakePolicyCommand; class IncludeScope; @@ -919,18 +927,6 @@ private: class BuildsystemFileScope; friend class BuildsystemFileScope; - // stack of policy settings - struct PolicyStackEntry: public cmPolicies::PolicyMap - { - typedef cmPolicies::PolicyMap derived; - PolicyStackEntry(bool w = false): derived(), Weak(w) {} - PolicyStackEntry(derived const& d, bool w = false): derived(d), Weak(w) {} - PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {} - bool Weak; - }; - typedef std::vector<PolicyStackEntry> PolicyStackType; - PolicyStackType PolicyStack; - std::vector<PolicyStackType::size_type> PolicyBarriers; // CMP0053 == old cmake::MessageType ExpandVariablesInStringOld( diff --git a/Source/cmState.cxx b/Source/cmState.cxx index d8f8306..f425861 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -20,8 +20,10 @@ struct cmState::SnapshotDataType { - cmState::PositionType CallStackParent; cmState::PositionType DirectoryParent; + cmLinkedTree<cmState::PolicyStackEntry>::iterator Policies; + cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyRoot; + cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyScope; cmState::SnapshotType SnapshotType; cmLinkedTree<std::string>::iterator ExecutionListFile; cmLinkedTree<cmState::BuildsystemDirectoryStateType>::iterator @@ -33,8 +35,19 @@ struct cmState::SnapshotDataType std::vector<std::string>::size_type CompileOptionsPosition; }; +struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap +{ + typedef cmPolicies::PolicyMap derived; + PolicyStackEntry(bool w = false): derived(), Weak(w) {} + PolicyStackEntry(derived const& d, bool w): derived(d), Weak(w) {} + PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {} + bool Weak; +}; + struct cmState::BuildsystemDirectoryStateType { + cmState::PositionType DirectoryEnd; + std::string Location; std::string OutputLocation; @@ -240,6 +253,9 @@ cmState::Snapshot cmState::Reset() this->GlobalProperties.clear(); this->PropertyDefinitions.clear(); + PositionType pos = this->SnapshotData.Truncate(); + this->ExecutionListFiles.Truncate(); + { cmLinkedTree<BuildsystemDirectoryStateType>::iterator it = this->BuildsystemDirectory.Truncate(); @@ -249,9 +265,15 @@ cmState::Snapshot cmState::Reset() it->CompileDefinitionsBacktraces.clear(); it->CompileOptions.clear(); it->CompileOptionsBacktraces.clear(); + it->DirectoryEnd = pos; } - PositionType pos = this->SnapshotData.Truncate(); - this->ExecutionListFiles.Truncate(); + + this->PolicyStack.Clear(); + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -722,6 +744,12 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->IncludeDirectoryPosition = 0; pos->CompileDefinitionsPosition = 0; pos->CompileOptionsPosition = 0; + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = this->PolicyStack.Root(); + pos->PolicyRoot = this->PolicyStack.Root(); + pos->PolicyScope = this->PolicyStack.Root(); + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -732,7 +760,6 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, { assert(originSnapshot.IsValid()); PositionType pos = this->SnapshotData.Extend(originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->DirectoryParent = originSnapshot.Position; @@ -743,6 +770,12 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile); + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->Policies = originSnapshot.Position->Policies; + pos->PolicyRoot = originSnapshot.Position->Policies; + pos->PolicyScope = originSnapshot.Position->Policies; + assert(pos->Policies.IsValid()); + assert(pos->PolicyRoot.IsValid()); return cmState::Snapshot(this, pos); } @@ -754,12 +787,13 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = FunctionCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -772,12 +806,13 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = MacroCallType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -789,12 +824,13 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = CallStackType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -806,12 +842,24 @@ cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); - pos->CallStackParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = InlineListFileType; pos->ExecutionListFile = this->ExecutionListFiles.Extend( originSnapshot.Position->ExecutionListFile, fileName); + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; + return cmState::Snapshot(this, pos); +} + +cmState::Snapshot +cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->SnapshotType = PolicyScopeType; + pos->BuildSystemDirectory->DirectoryEnd = pos; + pos->PolicyScope = originSnapshot.Position->Policies; return cmState::Snapshot(this, pos); } @@ -826,12 +874,9 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) prevPos->BuildSystemDirectory->CompileDefinitions.size(); prevPos->CompileOptionsPosition = prevPos->BuildSystemDirectory->CompileOptions.size(); + prevPos->BuildSystemDirectory->DirectoryEnd = prevPos; - if (prevPos == this->SnapshotData.Root()) - { - return Snapshot(this, prevPos); - } - return Snapshot(this, originSnapshot.Position->CallStackParent); + return Snapshot(this, prevPos); } cmState::Snapshot::Snapshot(cmState* state) @@ -847,6 +892,11 @@ cmState::Snapshot::Snapshot(cmState* state, PositionType position) } +cmState::SnapshotType cmState::Snapshot::GetType() const +{ + return this->Position->SnapshotType; +} + const char* cmState::Directory::GetCurrentSource() const { return this->DirectoryState->Location.c_str(); @@ -964,13 +1014,22 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const assert(this->Position != this->State->SnapshotData.Root()); Snapshot snapshot; - if (this->Position->SnapshotType == cmState::BuildsystemDirectoryType) + PositionType parentPos = this->Position; + while(parentPos->SnapshotType == cmState::PolicyScopeType) + { + ++parentPos; + } + if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType) { return snapshot; } - PositionType parentPos = this->Position; ++parentPos; + while(parentPos->SnapshotType == cmState::PolicyScopeType) + { + ++parentPos; + } + if (parentPos == this->State->SnapshotData.Root()) { return snapshot; @@ -980,6 +1039,88 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const return snapshot; } +void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak) +{ + PositionType pos = this->Position; + pos->Policies = + this->State->PolicyStack.Extend(pos->Policies, + PolicyStackEntry(entry, weak)); +} + +bool cmState::Snapshot::PopPolicy() +{ + PositionType pos = this->Position; + if (pos->Policies == pos->PolicyScope) + { + return false; + } + ++pos->Policies; + return true; +} + +bool cmState::Snapshot::CanPopPolicyScope() +{ + return this->Position->Policies == this->Position->PolicyScope; +} + +void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id, + cmPolicies::PolicyStatus status) +{ + // Update the policy stack from the top to the top-most strong entry. + bool previous_was_weak = true; + for(cmLinkedTree<PolicyStackEntry>::iterator psi = this->Position->Policies; + previous_was_weak && psi != this->Position->PolicyRoot; ++psi) + { + psi->Set(id, status); + previous_was_weak = psi->Weak; + } +} + +cmPolicies::PolicyStatus +cmState::Snapshot::GetPolicy(cmPolicies::PolicyID id) const +{ + cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); + + if(status == cmPolicies::REQUIRED_ALWAYS || + status == cmPolicies::REQUIRED_IF_USED) + { + return status; + } + + cmLinkedTree<BuildsystemDirectoryStateType>::iterator dir = + this->Position->BuildSystemDirectory; + + while (true) + { + assert(dir.IsValid()); + cmLinkedTree<PolicyStackEntry>::iterator leaf = + dir->DirectoryEnd->Policies; + cmLinkedTree<PolicyStackEntry>::iterator root = + dir->DirectoryEnd->PolicyRoot; + for( ; leaf != root; ++leaf) + { + if(leaf->IsDefined(id)) + { + status = leaf->Get(id); + return status; + } + } + cmState::PositionType e = dir->DirectoryEnd; + cmState::PositionType p = e->DirectoryParent; + if (p == this->State->SnapshotData.Root()) + { + break; + } + dir = p->BuildSystemDirectory; + } + return status; +} + +bool cmState::Snapshot::HasDefinedPolicyCMP0011() +{ + return !this->Position->Policies->IsEmpty(); +} + static const std::string cmPropertySentinal = std::string(); template<typename T, typename U, typename V> diff --git a/Source/cmState.h b/Source/cmState.h index 0d5300f..07aa2a5 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -17,6 +17,7 @@ #include "cmPropertyMap.h" #include "cmLinkedTree.h" #include "cmAlgorithms.h" +#include "cmPolicies.h" class cmake; class cmCommand; @@ -24,6 +25,7 @@ class cmCommand; class cmState { struct SnapshotDataType; + struct PolicyStackEntry; struct BuildsystemDirectoryStateType; typedef cmLinkedTree<SnapshotDataType>::iterator PositionType; friend class Snapshot; @@ -37,7 +39,8 @@ public: FunctionCallType, MacroCallType, CallStackType, - InlineListFileType + InlineListFileType, + PolicyScopeType }; class Directory; @@ -56,9 +59,17 @@ public: bool IsValid() const; Snapshot GetBuildsystemDirectoryParent() const; Snapshot GetCallStackParent() const; + SnapshotType GetType() const; void InitializeFromParent(); + void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); + cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const; + bool HasDefinedPolicyCMP0011(); + void PushPolicy(cmPolicies::PolicyMap entry, bool weak); + bool PopPolicy(); + bool CanPopPolicyScope(); + cmState* GetState() const; Directory GetDirectory() const; @@ -147,6 +158,7 @@ public: const std::string& entryPointCommand, long entryPointLine, std::string const& fileName); + Snapshot CreatePolicyScopeSnapshot(Snapshot originSnapshot); Snapshot Pop(Snapshot originSnapshot); enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC, @@ -254,6 +266,7 @@ private: cmLinkedTree<std::string> ExecutionListFiles; + cmLinkedTree<PolicyStackEntry> PolicyStack; cmLinkedTree<SnapshotDataType> SnapshotData; std::vector<std::string> SourceDirectoryComponents; diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index ba6e395..c59c360 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -243,7 +243,11 @@ void cmXCodeObject::PrintString(std::ostream& os,std::string String) bool needQuote = (String.empty() || String.find("//") != String.npos || - String.find_first_of(" <>+-*=@[](){},~") != String.npos); + String.find_first_not_of( + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "$_./") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. |