From b320c441ab5ad04ea4a6766d0a178fc7c0ea4105 Mon Sep 17 00:00:00 2001 From: marha Date: Sun, 31 Oct 2010 19:30:18 +0000 Subject: Make sure implicit rule searching is taking the extra dependencies into account --- tools/mhmake/src/rule.cpp | 65 +++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 28 deletions(-) (limited to 'tools/mhmake/src/rule.cpp') diff --git a/tools/mhmake/src/rule.cpp b/tools/mhmake/src/rule.cpp index cee38ddb9..0beb29c39 100644 --- a/tools/mhmake/src/rule.cpp +++ b/tools/mhmake/src/rule.cpp @@ -28,19 +28,19 @@ refptr NullRule; set IMPLICITRULE::m_ImplicitRuleRecurseDetStack; -vector > > > > IMPLICITRULE::m_ImplicitRules; +vector IMPLICITRULE::m_ImplicitRules; makecommand g_MakeCommand; // Order is important since sm_Statics is using g_MakeCommand const string g_QuoteString("\""); // Order is important since sm_Statics is using g_QuoteString loadedmakefile::loadedmakefile_statics loadedmakefile::sm_Statics; /////////////////////////////////////////////////////////////////////////////// -static bool FindDep(fileinfo *pDep, vector > >*pImplicitRule,refptr &Rule) +static bool FindDep(fileinfo *pTarget, implicitruledep_t *pImplicitRule,refptr &Rule) { - vector > >::iterator SecIt=pImplicitRule->begin(); + implicitruledep_t::iterator SecIt=pImplicitRule->begin(); while (SecIt!=pImplicitRule->end()) { - if (SecIt->first==pDep) + if (SecIt->first.empty()) { #ifdef _DEBUG // Check if the rule has the same commands @@ -52,9 +52,9 @@ static bool FindDep(fileinfo *pDep, vector > >*pImpl { string ErrorMessage; if (bCommandsDifferent) - ErrorMessage += "Implicit Rule '"+ pDep->GetFullFileName() + "' defined twice with different commands\n"; + ErrorMessage += "Implicit Rule '"+ pTarget->GetFullFileName() + "' defined twice with different commands\n"; else - ErrorMessage += "Implicit Rule '"+ pDep->GetFullFileName() + "' defined twice with same commands\n"; + ErrorMessage += "Implicit Rule '"+ pTarget->GetFullFileName() + "' defined twice with same commands\n"; ErrorMessage += "Command 1: makedir = " + SecIt->second->GetMakefile()->GetMakeDir()->GetQuotedFullFileName()+ "\n"; vector::const_iterator It; @@ -87,7 +87,7 @@ static bool FindDep(fileinfo *pDep, vector > >*pImpl { if (pOldMakefile->ExpandExpression(*OldIt)!=pNewMakefile->ExpandExpression(*NewIt)) { - string ErrorMessage = string("Implicit Rule '") + pDep->GetFullFileName() + "' defined twice with different commands\n"; + string ErrorMessage = string("Implicit Rule '") + pTarget->GetFullFileName() + "' defined twice with different commands\n"; ErrorMessage += "Command 1: makedir = " + pOldMakefile->GetMakeDir()->GetQuotedFullFileName()+ "\n"; ErrorMessage += " " + pOldMakefile->ExpandExpression(*OldIt) + "\n"; ErrorMessage += "Command 2: makedir = " + pNewMakefile->GetMakeDir()->GetQuotedFullFileName()+ "\n"; @@ -117,8 +117,8 @@ void IMPLICITRULE::AddImplicitRule(fileinfo *pTarget,const vector &De return; } // first search if there is already the same target in the current list of implicit rules - vector > >* pImplicitRule=NULL; - vector > > > >::iterator RuleIt=m_ImplicitRules.begin(); + implicitruledep_t* pImplicitRule=NULL; + vector::iterator RuleIt=m_ImplicitRules.begin(); while (RuleIt!=m_ImplicitRules.end()) { if (pTarget==RuleIt->first) @@ -128,46 +128,45 @@ void IMPLICITRULE::AddImplicitRule(fileinfo *pTarget,const vector &De RuleIt++; } if (!pImplicitRule) -{ + { // Add a new entry - m_ImplicitRules.push_back(pair > > >(pTarget,vector > >())); + m_ImplicitRules.push_back(implicitrule_t(pTarget,implicitruledep_t())); pImplicitRule=&((m_ImplicitRules.end()-1)->second); } if (Deps.size()) { + #ifdef _DEBUG vector::const_iterator DepIt=Deps.begin(); while (DepIt!=Deps.end()) { - #ifdef _DEBUG if (*DepIt==pTarget) throw(string("Implicit rule : ")+pTarget->GetFullFileName()+" is directly dependent on itself. This is not allowed."); - #endif - if (!FindDep(*DepIt,pImplicitRule,Rule)) - pImplicitRule->push_back(pair >(*DepIt,Rule)); DepIt++; } + #endif + pImplicitRule->push_back(pair,refptr >(Deps,Rule)); } else { - if (!FindDep(NULL,pImplicitRule,Rule)) - pImplicitRule->push_back(pair >((fileinfo*)NULL,Rule)); + if (!FindDep(pTarget,pImplicitRule,Rule)) + pImplicitRule->push_back(pair, refptr >(vector(), Rule)); } } /////////////////////////////////////////////////////////////////////////////// -void IMPLICITRULE::SearchImplicitRule(const fileinfo *pTarget,vector< pair > >&Result) +void IMPLICITRULE::SearchImplicitRule(const fileinfo *pTarget, implicitruledep_t &Result) { string TargetFileName=pTarget->GetFullFileName(); - vector > > > >::iterator ImpRegExIt=m_ImplicitRules.begin(); + vector::iterator ImpRegExIt=m_ImplicitRules.begin(); while (ImpRegExIt!=m_ImplicitRules.end()) { matchres Res; if (PercentMatch(TargetFileName,ImpRegExIt->first->GetFullFileName(),&Res)) { - vector > >::iterator ResIt=ImpRegExIt->second.begin(); + implicitruledep_t::iterator ResIt=ImpRegExIt->second.begin(); while (ResIt!=ImpRegExIt->second.end()) { #ifdef _DEBUG @@ -177,9 +176,12 @@ void IMPLICITRULE::SearchImplicitRule(const fileinfo *pTarget,vector< pairsecond->SetStem(Res.m_Stem); - if (ResIt->first!=NULL) + vector Deps; + const fileinfo *pMakeDir=ResIt->second->GetMakefile()->GetMakeDir(); + vector::iterator It=ResIt->first.begin(); + while (It!=ResIt->first.end()) { - string Dependent=ReplaceWithStem(ResIt->first->GetFullFileName(),Res.m_Stem); + string Dependent=ReplaceWithStem((*It)->GetFullFileName(),Res.m_Stem); #ifdef _DEBUG if (Dependent.length()>MAX_PATH) { @@ -187,10 +189,10 @@ void IMPLICITRULE::SearchImplicitRule(const fileinfo *pTarget,vector< pair >(GetFileInfo(Dependent,ResIt->second->GetMakefile()->GetMakeDir()),ResIt->second)); + Deps.push_back(GetFileInfo(Dependent,pMakeDir)); + It++; } - else - Result.push_back(pair >((fileinfo*)NULL,ResIt->second)); + Result.push_back(pair,refptr >(Deps, ResIt->second)); ResIt++; } } @@ -246,14 +248,21 @@ void rule::SetTargetsIsBuilding(const fileinfo *pSrc) /////////////////////////////////////////////////////////////////////////////// void IMPLICITRULE::PrintImplicitRules() { - vector > > > >::iterator ImpRegExIt=m_ImplicitRules.begin(); + vector::iterator ImpRegExIt=m_ImplicitRules.begin(); while (ImpRegExIt!=m_ImplicitRules.end()) { - vector > >::iterator SecIt=ImpRegExIt->second.begin(); + implicitruledep_t::iterator SecIt=ImpRegExIt->second.begin(); cout << ImpRegExIt->first->GetFullFileName() << " :\n"; while (SecIt!=ImpRegExIt->second.end()) { - cout << " : " << SecIt->first <::iterator DepIt=SecIt->first.begin(); + while (DepIt!=SecIt->first.end()) + { + cout << " " << (*DepIt)->GetQuotedFullFileName() <second) { SecIt->second->PrintCommands(); -- cgit v1.2.3