From b87c8d2eb4f0c7fb25cee10e8fdb2c8331343f8c Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 21 Dec 2009 23:52:22 +0000 Subject: Wow, that was aweful. There was a horrible problem with rule generated targets not getting the variables from the parent target. --- share/autoinclude/general-rules.bld | 1 - src/context.cpp | 13 ++++++++++--- src/functiongetmakedeps.cpp | 5 +++++ src/rule.cpp | 5 +++-- src/rule.h | 3 ++- src/target.cpp | 1 + 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/share/autoinclude/general-rules.bld b/share/autoinclude/general-rules.bld index 30a4376..95a5e0c 100644 --- a/share/autoinclude/general-rules.bld +++ b/share/autoinclude/general-rules.bld @@ -79,7 +79,6 @@ rule "cpp" { input "*.cpp"; output INPUT.cppToObj(); -// output replace(".cpp", ".o"); requires getMakeDeps("${CXX} ${CXXFLAGS} -M ${INPUT}"); profile "build" { diff --git a/src/context.cpp b/src/context.cpp index e9330e5..efe8098 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -144,13 +144,20 @@ void Context::pushScope() void Context::pushScope( const VarHash &hNewVars ) { +// sio << "Pushing scope, merging contexts." << sio.nl << sio.nl; VarHash h = hNewVars; if( !sVars.isEmpty() ) { +// sio << "hNewVars = " << h << sio.nl << sio.nl +// << "sVars = " << sVars.peek() << sio.nl; for( VarHash::iterator i = sVars.peek().begin(); i; i++ ) { +// sio << "Checking '" << i.getKey() << "' (" << i.getValue() << ")." << sio.nl; if( !h.has( i.getKey() ) ) + { +// sio << " Context doesn't have '" << i.getKey() << "' adding... '" << i.getValue() << "'." << sio.nl; h.insert( i.getKey(), i.getValue() ); + } } } sVars.push( h ); @@ -158,7 +165,7 @@ void Context::pushScope( const VarHash &hNewVars ) VarHash &Context::getScope() { - return sVars.first(); + return sVars.peek(); } void Context::popScope() @@ -344,14 +351,14 @@ void Context::buildTargetTree( Runner &r ) } } -void Context::buildTargetTree( class Runner &r, class Target * /*pTarget*/, const Bu::FString &sInput, Rule *pMaster, StrList &lNewIns ) +void Context::buildTargetTree( class Runner &r, class Target *pTarget, const Bu::FString &sInput, Rule *pMaster, StrList &lNewIns ) { Target *pNewTarget = NULL; for( RuleHash::iterator i = hRule.begin(); i; i++ ) { if( (*i)->hasOutputs() && (*i)->ruleMatches( r, sInput ) ) { - pNewTarget = (*i)->createTarget( r, sInput ); + pNewTarget = (*i)->createTarget( r, sInput, pTarget ); Bu::Hash hDone; for( StrList::const_iterator oi = diff --git a/src/functiongetmakedeps.cpp b/src/functiongetmakedeps.cpp index 1aded15..008a509 100644 --- a/src/functiongetmakedeps.cpp +++ b/src/functiongetmakedeps.cpp @@ -1,4 +1,6 @@ #include "functiongetmakedeps.h" +#include "context.h" +#include "view.h" #include #include @@ -19,6 +21,7 @@ Bu::FString FunctionGetMakeDeps::getName() const Variable FunctionGetMakeDeps::call( Variable &/*input*/, VarList lParams ) { + pContext->getView()->cmdStarted( lParams.first().getString().getStr() ); Process p( Process::StdOut, "/bin/bash", "/bin/bash", "-c", lParams.first().getString().getStr(), NULL ); @@ -31,6 +34,8 @@ Variable FunctionGetMakeDeps::call( Variable &/*input*/, VarList lParams ) sBuf.append( buf, iRead ); } + pContext->getView()->cmdFinished( "", "", p.childExitStatus() ); + Variable vRet( Variable::typeList ); Bu::FString::iterator i, j; diff --git a/src/rule.cpp b/src/rule.cpp index 4c42346..7578707 100644 --- a/src/rule.cpp +++ b/src/rule.cpp @@ -73,9 +73,10 @@ void Rule::prepTarget( class Target *pTarget ) } } -Target *Rule::createTarget( class Runner &r, const Bu::FString &sInput ) +Target *Rule::createTarget( class Runner &r, const Bu::FString &sInput, + Target *pParent ) { - r.getContext().pushScope(); + r.getContext().pushScope( pParent->getVars() ); r.getContext().addVariable("INPUT", sInput ); Target *pTrg = new Target( false ); for( AstBranchList::iterator i = lOutput.begin(); i; i++ ) diff --git a/src/rule.h b/src/rule.h index a3c9344..5344d02 100644 --- a/src/rule.h +++ b/src/rule.h @@ -22,7 +22,8 @@ public: void addProfile( const AstBranch *pProfile ); void prepTarget( class Target *pTarget ); - class Target *createTarget( class Runner &r, const Bu::FString &sInput ); + class Target *createTarget( class Runner &r, const Bu::FString &sInput, + class Target *pParent ); bool ruleMatches( class Runner &r, const Bu::FString &sInput ); void addTag( const Bu::FString &sTag ); diff --git a/src/target.cpp b/src/target.cpp index f3e54b7..8eec07a 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -191,6 +191,7 @@ const Profile *Target::getProfile( const Bu::FString &sName ) const void Target::setVars( const VarHash &hNewVars ) { + hVars = hNewVars; } -- cgit v1.2.3