aboutsummaryrefslogtreecommitdiff
path: root/src/context.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-01-06 17:05:45 +0000
committerMike Buland <eichlan@xagasoft.com>2010-01-06 17:05:45 +0000
commit3c7e81d3baba06cb1bf37de84aeaa6cad277652a (patch)
tree166e9309a0be01e6b4e8591434372e4817a65d76 /src/context.cpp
parente809677b1d5a02b93a0be7a9fce8a6b67d0d91be (diff)
downloadbuild-3c7e81d3baba06cb1bf37de84aeaa6cad277652a.tar.gz
build-3c7e81d3baba06cb1bf37de84aeaa6cad277652a.tar.bz2
build-3c7e81d3baba06cb1bf37de84aeaa6cad277652a.tar.xz
build-3c7e81d3baba06cb1bf37de84aeaa6cad277652a.zip
Wow, ok, well, I added some more error handling, that's positive, also switched
conditions and functions to a plugger system like views, and all of them now load builtin and external plugins flawlessly. It's actually a lot of fun. I also added the example/test plugin condition "random" it randomly builds targets...it's not really useful...
Diffstat (limited to '')
-rw-r--r--src/context.cpp48
1 files changed, 21 insertions, 27 deletions
diff --git a/src/context.cpp b/src/context.cpp
index efe8098..64b3bd0 100644
--- a/src/context.cpp
+++ b/src/context.cpp
@@ -7,18 +7,7 @@
7#include "profile.h" 7#include "profile.h"
8#include "view.h" 8#include "view.h"
9 9
10#include "functionreplace.h" 10#include "functionplugger.h"
11#include "functionexists.h"
12#include "functionfiles.h"
13#include "functionexecute.h"
14#include "functionmatches.h"
15#include "functiontostring.h"
16#include "functionunlink.h"
17#include "functiontargets.h"
18#include "functiondirs.h"
19#include "functiongetmakedeps.h"
20#include "functionfilename.h"
21#include "functiondirname.h"
22 11
23#include <bu/process.h> 12#include <bu/process.h>
24#include <bu/sio.h> 13#include <bu/sio.h>
@@ -27,18 +16,6 @@ using namespace Bu;
27Context::Context() : 16Context::Context() :
28 pView( NULL ) 17 pView( NULL )
29{ 18{
30 addFunction( new FunctionReplace() );
31 addFunction( new FunctionExists() );
32 addFunction( new FunctionFiles() );
33 addFunction( new FunctionExecute() );
34 addFunction( new FunctionMatches() );
35 addFunction( new FunctionToString() );
36 addFunction( new FunctionUnlink() );
37 addFunction( new FunctionTargets() );
38 addFunction( new FunctionDirs() );
39 addFunction( new FunctionGetMakeDeps() );
40 addFunction( new FunctionFileName() );
41 addFunction( new FunctionDirName() );
42 pushScope(); 19 pushScope();
43} 20}
44 21
@@ -178,7 +155,16 @@ Variable Context::call( const Bu::FString &sName, Variable &input,
178{ 155{
179 if( !hFunction.has( sName ) ) 156 if( !hFunction.has( sName ) )
180 { 157 {
181 throw Bu::ExceptionBase("Unknown function called: %s", sName.getStr() ); 158 // Try to load the function...
159 try
160 {
161 addFunction( FunctionPlugger::getInstance().instantiate( sName ) );
162 }
163 catch(...)
164 {
165 throw Bu::ExceptionBase("Unknown function called: %s",
166 sName.getStr() );
167 }
182 } 168 }
183 return hFunction.get( sName )->call( input, lParams ); 169 return hFunction.get( sName )->call( input, lParams );
184} 170}
@@ -290,8 +276,16 @@ void Context::buildTargetTree( Runner &r )
290 continue; 276 continue;
291 277
292 StrList lNewIns; // The new "changed" inputs for this target 278 StrList lNewIns; // The new "changed" inputs for this target
293 279
294 Rule *pMaster = hRule.get( (*i)->getRule() ); 280 Rule *pMaster;
281 try
282 {
283 pMaster = hRule.get( (*i)->getRule() );
284 }
285 catch( Bu::HashException &e )
286 {
287 throw Bu::ExceptionBase("Unknown rule: %s", (*i)->getRule().getStr() );
288 }
295 289
296 for( StrList::const_iterator j = (*i)->getInputList().begin(); j; j++ ) 290 for( StrList::const_iterator j = (*i)->getInputList().begin(); j; j++ )
297 { 291 {