diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-01-06 17:05:45 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-01-06 17:05:45 +0000 |
commit | 3c7e81d3baba06cb1bf37de84aeaa6cad277652a (patch) | |
tree | 166e9309a0be01e6b4e8591434372e4817a65d76 /src/conditionplugger.cpp | |
parent | e809677b1d5a02b93a0be7a9fce8a6b67d0d91be (diff) | |
download | build-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/conditionplugger.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/conditionplugger.cpp b/src/conditionplugger.cpp new file mode 100644 index 0000000..3edfa00 --- /dev/null +++ b/src/conditionplugger.cpp | |||
@@ -0,0 +1,43 @@ | |||
1 | #include "conditionplugger.h" | ||
2 | |||
3 | #include <sys/types.h> | ||
4 | #include <dirent.h> | ||
5 | |||
6 | extern Bu::PluginInfo pluginConditionAlways; | ||
7 | extern Bu::PluginInfo pluginConditionNever; | ||
8 | extern Bu::PluginInfo pluginConditionFileTime; | ||
9 | extern Bu::PluginInfo pluginConditionFileExists; | ||
10 | |||
11 | ConditionPlugger::ConditionPlugger() | ||
12 | { | ||
13 | registerBuiltinPlugin( &pluginConditionAlways ); | ||
14 | registerBuiltinPlugin( &pluginConditionNever ); | ||
15 | registerBuiltinPlugin( &pluginConditionFileTime ); | ||
16 | registerBuiltinPlugin( &pluginConditionFileExists ); | ||
17 | |||
18 | DIR *dir = opendir("/usr/lib/build"); | ||
19 | if( !dir ) | ||
20 | return; | ||
21 | struct dirent *de; | ||
22 | while( (de = readdir( dir )) ) | ||
23 | { | ||
24 | if( strncmp("pluginCondition", de->d_name, 15 ) ) | ||
25 | continue; | ||
26 | |||
27 | Bu::FString sFile("/usr/lib/build/"); | ||
28 | sFile += de->d_name; | ||
29 | char *s = de->d_name; | ||
30 | for(; *s && *s != '.'; s++ ) { } | ||
31 | registerExternalPlugin( | ||
32 | sFile, | ||
33 | Bu::FString( de->d_name, (ptrdiff_t)s-(ptrdiff_t)de->d_name ) | ||
34 | ); | ||
35 | } | ||
36 | |||
37 | closedir( dir ); | ||
38 | } | ||
39 | |||
40 | ConditionPlugger::~ConditionPlugger() | ||
41 | { | ||
42 | } | ||
43 | |||