aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-12-21 23:52:22 +0000
committerMike Buland <eichlan@xagasoft.com>2009-12-21 23:52:22 +0000
commitb87c8d2eb4f0c7fb25cee10e8fdb2c8331343f8c (patch)
treedfd82e31b0da2e48482f00fb3061dfdcd61e7c9d
parent97c0fcbbef19012f825cba0fc3f16037322ce84c (diff)
downloadbuild-b87c8d2eb4f0c7fb25cee10e8fdb2c8331343f8c.tar.gz
build-b87c8d2eb4f0c7fb25cee10e8fdb2c8331343f8c.tar.bz2
build-b87c8d2eb4f0c7fb25cee10e8fdb2c8331343f8c.tar.xz
build-b87c8d2eb4f0c7fb25cee10e8fdb2c8331343f8c.zip
Wow, that was aweful. There was a horrible problem with rule generated targets
not getting the variables from the parent target.
Diffstat (limited to '')
-rw-r--r--share/autoinclude/general-rules.bld1
-rw-r--r--src/context.cpp13
-rw-r--r--src/functiongetmakedeps.cpp5
-rw-r--r--src/rule.cpp5
-rw-r--r--src/rule.h3
-rw-r--r--src/target.cpp1
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"
79{ 79{
80 input "*.cpp"; 80 input "*.cpp";
81 output INPUT.cppToObj(); 81 output INPUT.cppToObj();
82// output replace(".cpp", ".o");
83 requires getMakeDeps("${CXX} ${CXXFLAGS} -M ${INPUT}"); 82 requires getMakeDeps("${CXX} ${CXXFLAGS} -M ${INPUT}");
84 profile "build" 83 profile "build"
85 { 84 {
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()
144 144
145void Context::pushScope( const VarHash &hNewVars ) 145void Context::pushScope( const VarHash &hNewVars )
146{ 146{
147// sio << "Pushing scope, merging contexts." << sio.nl << sio.nl;
147 VarHash h = hNewVars; 148 VarHash h = hNewVars;
148 if( !sVars.isEmpty() ) 149 if( !sVars.isEmpty() )
149 { 150 {
151// sio << "hNewVars = " << h << sio.nl << sio.nl
152// << "sVars = " << sVars.peek() << sio.nl;
150 for( VarHash::iterator i = sVars.peek().begin(); i; i++ ) 153 for( VarHash::iterator i = sVars.peek().begin(); i; i++ )
151 { 154 {
155// sio << "Checking '" << i.getKey() << "' (" << i.getValue() << ")." << sio.nl;
152 if( !h.has( i.getKey() ) ) 156 if( !h.has( i.getKey() ) )
157 {
158// sio << " Context doesn't have '" << i.getKey() << "' adding... '" << i.getValue() << "'." << sio.nl;
153 h.insert( i.getKey(), i.getValue() ); 159 h.insert( i.getKey(), i.getValue() );
160 }
154 } 161 }
155 } 162 }
156 sVars.push( h ); 163 sVars.push( h );
@@ -158,7 +165,7 @@ void Context::pushScope( const VarHash &hNewVars )
158 165
159VarHash &Context::getScope() 166VarHash &Context::getScope()
160{ 167{
161 return sVars.first(); 168 return sVars.peek();
162} 169}
163 170
164void Context::popScope() 171void Context::popScope()
@@ -344,14 +351,14 @@ void Context::buildTargetTree( Runner &r )
344 } 351 }
345} 352}
346 353
347void Context::buildTargetTree( class Runner &r, class Target * /*pTarget*/, const Bu::FString &sInput, Rule *pMaster, StrList &lNewIns ) 354void Context::buildTargetTree( class Runner &r, class Target *pTarget, const Bu::FString &sInput, Rule *pMaster, StrList &lNewIns )
348{ 355{
349 Target *pNewTarget = NULL; 356 Target *pNewTarget = NULL;
350 for( RuleHash::iterator i = hRule.begin(); i; i++ ) 357 for( RuleHash::iterator i = hRule.begin(); i; i++ )
351 { 358 {
352 if( (*i)->hasOutputs() && (*i)->ruleMatches( r, sInput ) ) 359 if( (*i)->hasOutputs() && (*i)->ruleMatches( r, sInput ) )
353 { 360 {
354 pNewTarget = (*i)->createTarget( r, sInput ); 361 pNewTarget = (*i)->createTarget( r, sInput, pTarget );
355 362
356 Bu::Hash<ptrdiff_t, bool> hDone; 363 Bu::Hash<ptrdiff_t, bool> hDone;
357 for( StrList::const_iterator oi = 364 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 @@
1#include "functiongetmakedeps.h" 1#include "functiongetmakedeps.h"
2#include "context.h"
3#include "view.h"
2 4
3#include <bu/process.h> 5#include <bu/process.h>
4#include <bu/sio.h> 6#include <bu/sio.h>
@@ -19,6 +21,7 @@ Bu::FString FunctionGetMakeDeps::getName() const
19 21
20Variable FunctionGetMakeDeps::call( Variable &/*input*/, VarList lParams ) 22Variable FunctionGetMakeDeps::call( Variable &/*input*/, VarList lParams )
21{ 23{
24 pContext->getView()->cmdStarted( lParams.first().getString().getStr() );
22 Process p( Process::StdOut, "/bin/bash", "/bin/bash", "-c", 25 Process p( Process::StdOut, "/bin/bash", "/bin/bash", "-c",
23 lParams.first().getString().getStr(), NULL ); 26 lParams.first().getString().getStr(), NULL );
24 27
@@ -31,6 +34,8 @@ Variable FunctionGetMakeDeps::call( Variable &/*input*/, VarList lParams )
31 sBuf.append( buf, iRead ); 34 sBuf.append( buf, iRead );
32 } 35 }
33 36
37 pContext->getView()->cmdFinished( "", "", p.childExitStatus() );
38
34 Variable vRet( Variable::typeList ); 39 Variable vRet( Variable::typeList );
35 40
36 Bu::FString::iterator i, j; 41 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 )
73 } 73 }
74} 74}
75 75
76Target *Rule::createTarget( class Runner &r, const Bu::FString &sInput ) 76Target *Rule::createTarget( class Runner &r, const Bu::FString &sInput,
77 Target *pParent )
77{ 78{
78 r.getContext().pushScope(); 79 r.getContext().pushScope( pParent->getVars() );
79 r.getContext().addVariable("INPUT", sInput ); 80 r.getContext().addVariable("INPUT", sInput );
80 Target *pTrg = new Target( false ); 81 Target *pTrg = new Target( false );
81 for( AstBranchList::iterator i = lOutput.begin(); i; i++ ) 82 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:
22 void addProfile( const AstBranch *pProfile ); 22 void addProfile( const AstBranch *pProfile );
23 23
24 void prepTarget( class Target *pTarget ); 24 void prepTarget( class Target *pTarget );
25 class Target *createTarget( class Runner &r, const Bu::FString &sInput ); 25 class Target *createTarget( class Runner &r, const Bu::FString &sInput,
26 class Target *pParent );
26 bool ruleMatches( class Runner &r, const Bu::FString &sInput ); 27 bool ruleMatches( class Runner &r, const Bu::FString &sInput );
27 28
28 void addTag( const Bu::FString &sTag ); 29 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
191 191
192void Target::setVars( const VarHash &hNewVars ) 192void Target::setVars( const VarHash &hNewVars )
193{ 193{
194
194 hVars = hNewVars; 195 hVars = hNewVars;
195} 196}
196 197