diff options
Diffstat (limited to '')
| -rw-r--r-- | default.bld | 31 | ||||
| -rw-r--r-- | share/autoinclude/general-rules.bld | 9 | ||||
| -rw-r--r-- | src/conditionalways.cpp | 4 | ||||
| -rw-r--r-- | src/conditionfileexists.cpp | 41 | ||||
| -rw-r--r-- | src/conditionfileexists.h | 16 | ||||
| -rw-r--r-- | src/conditionfiletime.cpp | 4 | ||||
| -rw-r--r-- | src/conditionnever.cpp | 4 | ||||
| -rw-r--r-- | src/conditionplugger.cpp | 43 | ||||
| -rw-r--r-- | src/conditionplugger.h | 17 | ||||
| -rw-r--r-- | src/context.cpp | 48 | ||||
| -rw-r--r-- | src/functiondirname.cpp | 4 | ||||
| -rw-r--r-- | src/functiondirs.cpp | 4 | ||||
| -rw-r--r-- | src/functionexecute.cpp | 4 | ||||
| -rw-r--r-- | src/functionexists.cpp | 4 | ||||
| -rw-r--r-- | src/functionfilename.cpp | 4 | ||||
| -rw-r--r-- | src/functionfiles.cpp | 4 | ||||
| -rw-r--r-- | src/functiongetmakedeps.cpp | 4 | ||||
| -rw-r--r-- | src/functionmatches.cpp | 4 | ||||
| -rw-r--r-- | src/functionplugger.cpp | 59 | ||||
| -rw-r--r-- | src/functionplugger.h | 17 | ||||
| -rw-r--r-- | src/functionreplace.cpp | 4 | ||||
| -rw-r--r-- | src/functiontargets.cpp | 4 | ||||
| -rw-r--r-- | src/functiontostring.cpp | 4 | ||||
| -rw-r--r-- | src/functionunlink.cpp | 4 | ||||
| -rw-r--r-- | src/main.cpp | 40 | ||||
| -rw-r--r-- | src/plugins/pluginConditionRandom.cpp | 31 | ||||
| -rw-r--r-- | src/profile.cpp | 25 | ||||
| -rw-r--r-- | src/viewplugger.cpp | 24 |
28 files changed, 412 insertions, 49 deletions
diff --git a/default.bld b/default.bld index 8fc8fb4..784fdda 100644 --- a/default.bld +++ b/default.bld | |||
| @@ -3,13 +3,16 @@ | |||
| 3 | # :) | 3 | # :) |
| 4 | # | 4 | # |
| 5 | 5 | ||
| 6 | CXXFLAGS += "-fPIC -rdynamic"; | ||
| 7 | LDFLAGS += "-fPIC -rdynamic -Wl,-export-dynamic"; | ||
| 6 | CXXFLAGS += "-ggdb -W -Wall"; | 8 | CXXFLAGS += "-ggdb -W -Wall"; |
| 7 | 9 | ||
| 8 | CC = CXX; // We actually want to use c++ to compile our c files. | 10 | CC = CXX; // We actually want to use c++ to compile our c files. |
| 9 | 11 | ||
| 10 | action "default" | 12 | action "default" |
| 11 | { | 13 | { |
| 12 | build: "build"; | 14 | // build: "build"; |
| 15 | build: ["build", targets("plugins")]; | ||
| 13 | } | 16 | } |
| 14 | 17 | ||
| 15 | action "man" | 18 | action "man" |
| @@ -55,6 +58,18 @@ target "build" | |||
| 55 | tag "tools"; | 58 | tag "tools"; |
| 56 | } | 59 | } |
| 57 | 60 | ||
| 61 | for IN in files("src/plugins/*.cpp") do | ||
| 62 | { | ||
| 63 | target IN.replace("src/","").replace(".cpp", ".so") | ||
| 64 | { | ||
| 65 | input IN; | ||
| 66 | rule "so"; | ||
| 67 | LDFLAGS += "-Llibbu++ -lbu++ -ldl"; | ||
| 68 | CXXFLAGS += "-Ilibbu++ -Isrc"; | ||
| 69 | tag "plugins"; | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 58 | target "build-r$(svnversion "-n").tar.bz2" | 73 | target "build-r$(svnversion "-n").tar.bz2" |
| 59 | { | 74 | { |
| 60 | input [ | 75 | input [ |
| @@ -93,9 +108,21 @@ target "/usr/share/build" | |||
| 93 | { | 108 | { |
| 94 | input "$(echo -n $PWD)/share"; | 109 | input "$(echo -n $PWD)/share"; |
| 95 | tag "devinstall"; | 110 | tag "devinstall"; |
| 111 | display "symlink"; | ||
| 112 | profile "install" | ||
| 113 | { | ||
| 114 | execute("ln -fsv \"${INPUT}\" \"${OUTPUT}\""); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | target "/usr/lib/build" | ||
| 119 | { | ||
| 120 | input "$(echo -n $PWD)/plugins"; | ||
| 121 | tag "devinstall"; | ||
| 122 | display "symlink"; | ||
| 96 | profile "install" | 123 | profile "install" |
| 97 | { | 124 | { |
| 98 | execute("ln -fsv ${INPUT} \"${OUTPUT}\""); | 125 | execute("ln -fsv \"${INPUT}\" \"${OUTPUT\""); |
| 99 | } | 126 | } |
| 100 | } | 127 | } |
| 101 | 128 | ||
diff --git a/share/autoinclude/general-rules.bld b/share/autoinclude/general-rules.bld index 95a5e0c..9f905a6 100644 --- a/share/autoinclude/general-rules.bld +++ b/share/autoinclude/general-rules.bld | |||
| @@ -66,6 +66,15 @@ rule "exe" | |||
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | rule "so" | ||
| 70 | { | ||
| 71 | input "*.o"; | ||
| 72 | profile "build" | ||
| 73 | { | ||
| 74 | execute("${CXX} -shared -o ${OUTPUT} ${INPUT} ${LDFLAGS}"); | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 69 | rule "lib" | 78 | rule "lib" |
| 70 | { | 79 | { |
| 71 | input "*.o"; | 80 | input "*.o"; |
diff --git a/src/conditionalways.cpp b/src/conditionalways.cpp index 077b5b5..8c245f4 100644 --- a/src/conditionalways.cpp +++ b/src/conditionalways.cpp | |||
| @@ -1,6 +1,10 @@ | |||
| 1 | #include "conditionalways.h" | 1 | #include "conditionalways.h" |
| 2 | #include "target.h" | 2 | #include "target.h" |
| 3 | 3 | ||
| 4 | #include <bu/plugger.h> | ||
| 5 | PluginInterface3( pluginConditionAlways, always, ConditionAlways, Condition, | ||
| 6 | "Mike Buland", 0, 1 ); | ||
| 7 | |||
| 4 | ConditionAlways::ConditionAlways() | 8 | ConditionAlways::ConditionAlways() |
| 5 | { | 9 | { |
| 6 | } | 10 | } |
diff --git a/src/conditionfileexists.cpp b/src/conditionfileexists.cpp new file mode 100644 index 0000000..0585351 --- /dev/null +++ b/src/conditionfileexists.cpp | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | #include "conditionfileexists.h" | ||
| 2 | #include "target.h" | ||
| 3 | |||
| 4 | #include <sys/types.h> | ||
| 5 | #include <sys/stat.h> | ||
| 6 | #include <unistd.h> | ||
| 7 | |||
| 8 | #include <bu/sio.h> | ||
| 9 | using namespace Bu; | ||
| 10 | |||
| 11 | #include <bu/plugger.h> | ||
| 12 | PluginInterface3( pluginConditionFileExists, fileExists, ConditionFileExists, | ||
| 13 | Condition, "Mike Buland", 0, 1 ); | ||
| 14 | |||
| 15 | ConditionFileExists::ConditionFileExists() | ||
| 16 | { | ||
| 17 | } | ||
| 18 | |||
| 19 | ConditionFileExists::~ConditionFileExists() | ||
| 20 | { | ||
| 21 | } | ||
| 22 | |||
| 23 | bool ConditionFileExists::shouldExec( class Runner &r, Target &rTarget ) | ||
| 24 | { | ||
| 25 | for( StrList::const_iterator j = rTarget.getOutputList().begin(); j; j++ ) | ||
| 26 | { | ||
| 27 | // If any input exists, then return true, we should exec. | ||
| 28 | if( !access( (*j).getStr(), F_OK ) ) | ||
| 29 | { | ||
| 30 | return true; | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | return false; | ||
| 35 | } | ||
| 36 | |||
| 37 | Condition *ConditionFileExists::clone() | ||
| 38 | { | ||
| 39 | return new ConditionFileExists(); | ||
| 40 | } | ||
| 41 | |||
diff --git a/src/conditionfileexists.h b/src/conditionfileexists.h new file mode 100644 index 0000000..6f30297 --- /dev/null +++ b/src/conditionfileexists.h | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #ifndef CONDITION_FILE_EXISTS_H | ||
| 2 | #define CONDITION_FILE_EXISTS_H | ||
| 3 | |||
| 4 | #include "condition.h" | ||
| 5 | |||
| 6 | class ConditionFileExists : public Condition | ||
| 7 | { | ||
| 8 | public: | ||
| 9 | ConditionFileExists(); | ||
| 10 | virtual ~ConditionFileExists(); | ||
| 11 | |||
| 12 | virtual bool shouldExec( class Runner &r, class Target &rTarget ); | ||
| 13 | virtual Condition *clone(); | ||
| 14 | }; | ||
| 15 | |||
| 16 | #endif | ||
diff --git a/src/conditionfiletime.cpp b/src/conditionfiletime.cpp index 148ffac..43df53b 100644 --- a/src/conditionfiletime.cpp +++ b/src/conditionfiletime.cpp | |||
| @@ -8,6 +8,10 @@ | |||
| 8 | #include <bu/sio.h> | 8 | #include <bu/sio.h> |
| 9 | using namespace Bu; | 9 | using namespace Bu; |
| 10 | 10 | ||
| 11 | #include <bu/plugger.h> | ||
| 12 | PluginInterface3( pluginConditionFileTime, fileTime, ConditionFileTime, | ||
| 13 | Condition, "Mike Buland", 0, 1 ); | ||
| 14 | |||
| 11 | ConditionFileTime::ConditionFileTime() | 15 | ConditionFileTime::ConditionFileTime() |
| 12 | { | 16 | { |
| 13 | } | 17 | } |
diff --git a/src/conditionnever.cpp b/src/conditionnever.cpp index 1ab4375..f99feb6 100644 --- a/src/conditionnever.cpp +++ b/src/conditionnever.cpp | |||
| @@ -1,6 +1,10 @@ | |||
| 1 | #include "conditionnever.h" | 1 | #include "conditionnever.h" |
| 2 | #include "target.h" | 2 | #include "target.h" |
| 3 | 3 | ||
| 4 | #include <bu/plugger.h> | ||
| 5 | PluginInterface3( pluginConditionNever, never, ConditionNever, Condition, | ||
| 6 | "Mike Buland", 0, 1 ); | ||
| 7 | |||
| 4 | ConditionNever::ConditionNever() | 8 | ConditionNever::ConditionNever() |
| 5 | { | 9 | { |
| 6 | } | 10 | } |
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 | |||
diff --git a/src/conditionplugger.h b/src/conditionplugger.h new file mode 100644 index 0000000..71fa7e3 --- /dev/null +++ b/src/conditionplugger.h | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | #ifndef CONDITION_PLUGGER_H | ||
| 2 | #define CONDITION_PLUGGER_H | ||
| 3 | |||
| 4 | #include "condition.h" | ||
| 5 | #include <bu/plugger.h> | ||
| 6 | #include <bu/singleton.h> | ||
| 7 | |||
| 8 | class ConditionPlugger : public Bu::Plugger<Condition>, | ||
| 9 | public Bu::Singleton<ConditionPlugger> | ||
| 10 | { | ||
| 11 | friend class Bu::Singleton<ConditionPlugger>; | ||
| 12 | private: | ||
| 13 | ConditionPlugger(); | ||
| 14 | virtual ~ConditionPlugger(); | ||
| 15 | }; | ||
| 16 | |||
| 17 | #endif | ||
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; | |||
| 27 | Context::Context() : | 16 | Context::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 | { |
diff --git a/src/functiondirname.cpp b/src/functiondirname.cpp index e8b728b..f72d181 100644 --- a/src/functiondirname.cpp +++ b/src/functiondirname.cpp | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | #include "functiondirname.h" | 1 | #include "functiondirname.h" |
| 2 | 2 | ||
| 3 | #include <bu/plugger.h> | ||
| 4 | PluginInterface3( pluginFunctionDirName, dirName, FunctionDirName, Function, | ||
| 5 | "Mike Buland", 0, 1 ); | ||
| 6 | |||
| 3 | FunctionDirName::FunctionDirName() | 7 | FunctionDirName::FunctionDirName() |
| 4 | { | 8 | { |
| 5 | } | 9 | } |
diff --git a/src/functiondirs.cpp b/src/functiondirs.cpp index fb64ef3..dee3c4c 100644 --- a/src/functiondirs.cpp +++ b/src/functiondirs.cpp | |||
| @@ -5,6 +5,10 @@ | |||
| 5 | #include <glob.h> | 5 | #include <glob.h> |
| 6 | #include <unistd.h> | 6 | #include <unistd.h> |
| 7 | 7 | ||
| 8 | #include <bu/plugger.h> | ||
| 9 | PluginInterface3( pluginFunctionDirs, dirs, FunctionDirs, Function, | ||
| 10 | "Mike Buland", 0, 1 ); | ||
| 11 | |||
| 8 | FunctionDirs::FunctionDirs() | 12 | FunctionDirs::FunctionDirs() |
| 9 | { | 13 | { |
| 10 | } | 14 | } |
diff --git a/src/functionexecute.cpp b/src/functionexecute.cpp index 619d2c2..f692036 100644 --- a/src/functionexecute.cpp +++ b/src/functionexecute.cpp | |||
| @@ -6,6 +6,10 @@ | |||
| 6 | #include <bu/process.h> | 6 | #include <bu/process.h> |
| 7 | using namespace Bu; | 7 | using namespace Bu; |
| 8 | 8 | ||
| 9 | #include <bu/plugger.h> | ||
| 10 | PluginInterface3( pluginFunctionExecute, execute, FunctionExecute, Function, | ||
| 11 | "Mike Buland", 0, 1 ); | ||
| 12 | |||
| 9 | FunctionExecute::FunctionExecute() | 13 | FunctionExecute::FunctionExecute() |
| 10 | { | 14 | { |
| 11 | } | 15 | } |
diff --git a/src/functionexists.cpp b/src/functionexists.cpp index d2aa9e9..2207f84 100644 --- a/src/functionexists.cpp +++ b/src/functionexists.cpp | |||
| @@ -2,6 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | #include <unistd.h> | 3 | #include <unistd.h> |
| 4 | 4 | ||
| 5 | #include <bu/plugger.h> | ||
| 6 | PluginInterface3( pluginFunctionExists, exists, FunctionExists, Function, | ||
| 7 | "Mike Buland", 0, 1 ); | ||
| 8 | |||
| 5 | FunctionExists::FunctionExists() | 9 | FunctionExists::FunctionExists() |
| 6 | { | 10 | { |
| 7 | } | 11 | } |
diff --git a/src/functionfilename.cpp b/src/functionfilename.cpp index 21a4655..57aada9 100644 --- a/src/functionfilename.cpp +++ b/src/functionfilename.cpp | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | #include "functionfilename.h" | 1 | #include "functionfilename.h" |
| 2 | 2 | ||
| 3 | #include <bu/plugger.h> | ||
| 4 | PluginInterface3( pluginFunctionFileName, fileName, FunctionFileName, Function, | ||
| 5 | "Mike Buland", 0, 1 ); | ||
| 6 | |||
| 3 | FunctionFileName::FunctionFileName() | 7 | FunctionFileName::FunctionFileName() |
| 4 | { | 8 | { |
| 5 | } | 9 | } |
diff --git a/src/functionfiles.cpp b/src/functionfiles.cpp index e708d45..e0f8268 100644 --- a/src/functionfiles.cpp +++ b/src/functionfiles.cpp | |||
| @@ -5,6 +5,10 @@ | |||
| 5 | #include <glob.h> | 5 | #include <glob.h> |
| 6 | #include <unistd.h> | 6 | #include <unistd.h> |
| 7 | 7 | ||
| 8 | #include <bu/plugger.h> | ||
| 9 | PluginInterface3( pluginFunctionFiles, files, FunctionFiles, Function, | ||
| 10 | "Mike Buland", 0, 1 ); | ||
| 11 | |||
| 8 | FunctionFiles::FunctionFiles() | 12 | FunctionFiles::FunctionFiles() |
| 9 | { | 13 | { |
| 10 | } | 14 | } |
diff --git a/src/functiongetmakedeps.cpp b/src/functiongetmakedeps.cpp index 008a509..cc6cbbb 100644 --- a/src/functiongetmakedeps.cpp +++ b/src/functiongetmakedeps.cpp | |||
| @@ -6,6 +6,10 @@ | |||
| 6 | #include <bu/sio.h> | 6 | #include <bu/sio.h> |
| 7 | using namespace Bu; | 7 | using namespace Bu; |
| 8 | 8 | ||
| 9 | #include <bu/plugger.h> | ||
| 10 | PluginInterface3( pluginFunctionGetMakeDeps, getMakeDeps, FunctionGetMakeDeps, | ||
| 11 | Function, "Mike Buland", 0, 1 ); | ||
| 12 | |||
| 9 | FunctionGetMakeDeps::FunctionGetMakeDeps() | 13 | FunctionGetMakeDeps::FunctionGetMakeDeps() |
| 10 | { | 14 | { |
| 11 | } | 15 | } |
diff --git a/src/functionmatches.cpp b/src/functionmatches.cpp index 4e4b7ff..5b96fa8 100644 --- a/src/functionmatches.cpp +++ b/src/functionmatches.cpp | |||
| @@ -2,6 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | #include <unistd.h> | 3 | #include <unistd.h> |
| 4 | 4 | ||
| 5 | #include <bu/plugger.h> | ||
| 6 | PluginInterface3( pluginFunctionMatches, matches, FunctionMatches, Function, | ||
| 7 | "Mike Buland", 0, 1 ); | ||
| 8 | |||
| 5 | FunctionMatches::FunctionMatches() | 9 | FunctionMatches::FunctionMatches() |
| 6 | { | 10 | { |
| 7 | } | 11 | } |
diff --git a/src/functionplugger.cpp b/src/functionplugger.cpp new file mode 100644 index 0000000..83435ae --- /dev/null +++ b/src/functionplugger.cpp | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | #include "functionplugger.h" | ||
| 2 | |||
| 3 | #include <sys/types.h> | ||
| 4 | #include <dirent.h> | ||
| 5 | |||
| 6 | extern Bu::PluginInfo pluginFunctionDirName; | ||
| 7 | extern Bu::PluginInfo pluginFunctionDirs; | ||
| 8 | extern Bu::PluginInfo pluginFunctionExecute; | ||
| 9 | extern Bu::PluginInfo pluginFunctionExists; | ||
| 10 | extern Bu::PluginInfo pluginFunctionFileName; | ||
| 11 | extern Bu::PluginInfo pluginFunctionFiles; | ||
| 12 | extern Bu::PluginInfo pluginFunctionGetMakeDeps; | ||
| 13 | extern Bu::PluginInfo pluginFunctionMatches; | ||
| 14 | extern Bu::PluginInfo pluginFunctionReplace; | ||
| 15 | extern Bu::PluginInfo pluginFunctionTargets; | ||
| 16 | extern Bu::PluginInfo pluginFunctionToString; | ||
| 17 | extern Bu::PluginInfo pluginFunctionUnlink; | ||
| 18 | |||
| 19 | FunctionPlugger::FunctionPlugger() | ||
| 20 | { | ||
| 21 | registerBuiltinPlugin( &pluginFunctionDirName ); | ||
| 22 | registerBuiltinPlugin( &pluginFunctionDirs ); | ||
| 23 | registerBuiltinPlugin( &pluginFunctionExecute ); | ||
| 24 | registerBuiltinPlugin( &pluginFunctionExists ); | ||
| 25 | registerBuiltinPlugin( &pluginFunctionFileName ); | ||
| 26 | registerBuiltinPlugin( &pluginFunctionFiles ); | ||
| 27 | registerBuiltinPlugin( &pluginFunctionGetMakeDeps ); | ||
| 28 | registerBuiltinPlugin( &pluginFunctionMatches ); | ||
| 29 | registerBuiltinPlugin( &pluginFunctionReplace ); | ||
| 30 | registerBuiltinPlugin( &pluginFunctionTargets ); | ||
| 31 | registerBuiltinPlugin( &pluginFunctionToString ); | ||
| 32 | registerBuiltinPlugin( &pluginFunctionUnlink ); | ||
| 33 | |||
| 34 | DIR *dir = opendir("/usr/lib/build"); | ||
| 35 | if( !dir ) | ||
| 36 | return; | ||
| 37 | struct dirent *de; | ||
| 38 | while( (de = readdir( dir )) ) | ||
| 39 | { | ||
| 40 | if( strncmp("pluginFunction", de->d_name, 15 ) ) | ||
| 41 | continue; | ||
| 42 | |||
| 43 | Bu::FString sFile("/usr/lib/build/"); | ||
| 44 | sFile += de->d_name; | ||
| 45 | char *s = de->d_name; | ||
| 46 | for(; *s && *s != '.'; s++ ) { } | ||
| 47 | registerExternalPlugin( | ||
| 48 | sFile, | ||
| 49 | Bu::FString( de->d_name, (ptrdiff_t)s-(ptrdiff_t)de->d_name ) | ||
| 50 | ); | ||
| 51 | } | ||
| 52 | |||
| 53 | closedir( dir ); | ||
| 54 | } | ||
| 55 | |||
| 56 | FunctionPlugger::~FunctionPlugger() | ||
| 57 | { | ||
| 58 | } | ||
| 59 | |||
diff --git a/src/functionplugger.h b/src/functionplugger.h new file mode 100644 index 0000000..30022f6 --- /dev/null +++ b/src/functionplugger.h | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | #ifndef FUNCTION_PLUGGER_H | ||
| 2 | #define FUNCTION_PLUGGER_H | ||
| 3 | |||
| 4 | #include "function.h" | ||
| 5 | #include <bu/plugger.h> | ||
| 6 | #include <bu/singleton.h> | ||
| 7 | |||
| 8 | class FunctionPlugger : public Bu::Plugger<Function>, | ||
| 9 | public Bu::Singleton<FunctionPlugger> | ||
| 10 | { | ||
| 11 | friend class Bu::Singleton<FunctionPlugger>; | ||
| 12 | private: | ||
| 13 | FunctionPlugger(); | ||
| 14 | virtual ~FunctionPlugger(); | ||
| 15 | }; | ||
| 16 | |||
| 17 | #endif | ||
diff --git a/src/functionreplace.cpp b/src/functionreplace.cpp index d269083..b341e44 100644 --- a/src/functionreplace.cpp +++ b/src/functionreplace.cpp | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | #include "functionreplace.h" | 1 | #include "functionreplace.h" |
| 2 | 2 | ||
| 3 | #include <bu/plugger.h> | ||
| 4 | PluginInterface3( pluginFunctionReplace, replace, FunctionReplace, Function, | ||
| 5 | "Mike Buland", 0, 1 ); | ||
| 6 | |||
| 3 | FunctionReplace::FunctionReplace() | 7 | FunctionReplace::FunctionReplace() |
| 4 | { | 8 | { |
| 5 | } | 9 | } |
diff --git a/src/functiontargets.cpp b/src/functiontargets.cpp index 93fbb96..adafdfb 100644 --- a/src/functiontargets.cpp +++ b/src/functiontargets.cpp | |||
| @@ -2,6 +2,10 @@ | |||
| 2 | #include "context.h" | 2 | #include "context.h" |
| 3 | #include "target.h" | 3 | #include "target.h" |
| 4 | 4 | ||
| 5 | #include <bu/plugger.h> | ||
| 6 | PluginInterface3( pluginFunctionTargets, targets, FunctionTargets, Function, | ||
| 7 | "Mike Buland", 0, 1 ); | ||
| 8 | |||
| 5 | FunctionTargets::FunctionTargets() | 9 | FunctionTargets::FunctionTargets() |
| 6 | { | 10 | { |
| 7 | } | 11 | } |
diff --git a/src/functiontostring.cpp b/src/functiontostring.cpp index 0c04091..1d614ce 100644 --- a/src/functiontostring.cpp +++ b/src/functiontostring.cpp | |||
| @@ -4,6 +4,10 @@ | |||
| 4 | #include <bu/sio.h> | 4 | #include <bu/sio.h> |
| 5 | using namespace Bu; | 5 | using namespace Bu; |
| 6 | 6 | ||
| 7 | #include <bu/plugger.h> | ||
| 8 | PluginInterface3( pluginFunctionToString, toString, FunctionToString, Function, | ||
| 9 | "Mike Buland", 0, 1 ); | ||
| 10 | |||
| 7 | FunctionToString::FunctionToString() | 11 | FunctionToString::FunctionToString() |
| 8 | { | 12 | { |
| 9 | } | 13 | } |
diff --git a/src/functionunlink.cpp b/src/functionunlink.cpp index addcfd9..d8ad899 100644 --- a/src/functionunlink.cpp +++ b/src/functionunlink.cpp | |||
| @@ -5,6 +5,10 @@ | |||
| 5 | #include <bu/sio.h> | 5 | #include <bu/sio.h> |
| 6 | using namespace Bu; | 6 | using namespace Bu; |
| 7 | 7 | ||
| 8 | #include <bu/plugger.h> | ||
| 9 | PluginInterface3( pluginFunctionUnlink, unlink, FunctionUnlink, Function, | ||
| 10 | "Mike Buland", 0, 1 ); | ||
| 11 | |||
| 8 | FunctionUnlink::FunctionUnlink() | 12 | FunctionUnlink::FunctionUnlink() |
| 9 | { | 13 | { |
| 10 | } | 14 | } |
diff --git a/src/main.cpp b/src/main.cpp index 1bed895..c0b8dd3 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | #include "target.h" | 5 | #include "target.h" |
| 6 | 6 | ||
| 7 | #include "viewplugger.h" | 7 | #include "viewplugger.h" |
| 8 | #include "functionplugger.h" | ||
| 9 | #include "conditionplugger.h" | ||
| 8 | 10 | ||
| 9 | #include "cache.h" | 11 | #include "cache.h" |
| 10 | 12 | ||
| @@ -50,6 +52,8 @@ public: | |||
| 50 | addHelpBanner("The following options do things other than build:"); | 52 | addHelpBanner("The following options do things other than build:"); |
| 51 | addOption( iInfoLevel, 'i', "info", "Display some basic info about the " | 53 | addOption( iInfoLevel, 'i', "info", "Display some basic info about the " |
| 52 | "loaded build config, including available targets."); | 54 | "loaded build config, including available targets."); |
| 55 | addOption( slot( this, &Options::onListPlugins), "list-plugins", | ||
| 56 | "List all available plugins."); | ||
| 53 | 57 | ||
| 54 | addHelpBanner("The following options control general execution:"); | 58 | addHelpBanner("The following options control general execution:"); |
| 55 | addOption( sView, 'v', "view", sViews ); | 59 | addOption( sView, 'v', "view", sViews ); |
| @@ -115,6 +119,42 @@ public: | |||
| 115 | return 0; | 119 | return 0; |
| 116 | } | 120 | } |
| 117 | 121 | ||
| 122 | int onListPlugins( StrArray /*sParams*/ ) | ||
| 123 | { | ||
| 124 | StrList lViews = ViewPlugger::getInstance().getPluginList(); | ||
| 125 | sio << "Available view plugins:" << sio.nl << "\t"; | ||
| 126 | for( StrList::iterator i = lViews.begin(); i; i++ ) | ||
| 127 | { | ||
| 128 | if( i != lViews.begin() ) | ||
| 129 | sio << ", "; | ||
| 130 | sio << *i; | ||
| 131 | } | ||
| 132 | |||
| 133 | StrList lFuncs = FunctionPlugger::getInstance().getPluginList(); | ||
| 134 | sio << sio.nl << sio.nl << "Available function plugins:" | ||
| 135 | << sio.nl << "\t"; | ||
| 136 | for( StrList::iterator i = lFuncs.begin(); i; i++ ) | ||
| 137 | { | ||
| 138 | if( i != lFuncs.begin() ) | ||
| 139 | sio << ", "; | ||
| 140 | sio << *i; | ||
| 141 | } | ||
| 142 | |||
| 143 | StrList lConds = ConditionPlugger::getInstance().getPluginList(); | ||
| 144 | sio << sio.nl << sio.nl << "Available condition plugins:" | ||
| 145 | << sio.nl << "\t"; | ||
| 146 | for( StrList::iterator i = lConds.begin(); i; i++ ) | ||
| 147 | { | ||
| 148 | if( i != lConds.begin() ) | ||
| 149 | sio << ", "; | ||
| 150 | sio << *i; | ||
| 151 | } | ||
| 152 | |||
| 153 | sio << sio.nl << sio.nl; | ||
| 154 | |||
| 155 | return 0; | ||
| 156 | } | ||
| 157 | |||
| 118 | Bu::FString sView; | 158 | Bu::FString sView; |
| 119 | Bu::FString sAction; | 159 | Bu::FString sAction; |
| 120 | Bu::FString sConfig; | 160 | Bu::FString sConfig; |
diff --git a/src/plugins/pluginConditionRandom.cpp b/src/plugins/pluginConditionRandom.cpp new file mode 100644 index 0000000..42a4e00 --- /dev/null +++ b/src/plugins/pluginConditionRandom.cpp | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | #include "condition.h" | ||
| 2 | #include <stdlib.h> | ||
| 3 | |||
| 4 | class ConditionRandom : public Condition | ||
| 5 | { | ||
| 6 | public: | ||
| 7 | ConditionRandom() | ||
| 8 | { | ||
| 9 | } | ||
| 10 | |||
| 11 | virtual ~ConditionRandom() | ||
| 12 | { | ||
| 13 | } | ||
| 14 | |||
| 15 | virtual bool shouldExec( class Runner &, class Target & ) | ||
| 16 | { | ||
| 17 | if( (random()/(double)RAND_MAX) >= .5 ) | ||
| 18 | return true; | ||
| 19 | return false; | ||
| 20 | } | ||
| 21 | |||
| 22 | virtual Condition *clone() | ||
| 23 | { | ||
| 24 | return new ConditionRandom(); | ||
| 25 | } | ||
| 26 | }; | ||
| 27 | |||
| 28 | #include <bu/plugger.h> | ||
| 29 | PluginInterface3( pluginConditionRandom, random, ConditionRandom, Condition, | ||
| 30 | "Mike Buland", 0, 1 ); | ||
| 31 | |||
diff --git a/src/profile.cpp b/src/profile.cpp index 878a6e9..fd21097 100644 --- a/src/profile.cpp +++ b/src/profile.cpp | |||
| @@ -4,9 +4,7 @@ | |||
| 4 | #include "astleaf.h" | 4 | #include "astleaf.h" |
| 5 | #include "condition.h" | 5 | #include "condition.h" |
| 6 | 6 | ||
| 7 | #include "conditionfiletime.h" | 7 | #include "conditionplugger.h" |
| 8 | #include "conditionalways.h" | ||
| 9 | #include "conditionnever.h" | ||
| 10 | 8 | ||
| 11 | #include <bu/sio.h> | 9 | #include <bu/sio.h> |
| 12 | using namespace Bu; | 10 | using namespace Bu; |
| @@ -64,7 +62,7 @@ Profile *Profile::genDefaultClean() | |||
| 64 | pAst->openBranch(); | 62 | pAst->openBranch(); |
| 65 | pAst->addNode( AstNode::typeString, "clean" ); | 63 | pAst->addNode( AstNode::typeString, "clean" ); |
| 66 | pAst->openBranch(); | 64 | pAst->openBranch(); |
| 67 | pAst->addNode( AstNode::typeCondition, "always" ); | 65 | pAst->addNode( AstNode::typeCondition, "fileExists" ); |
| 68 | pAst->addNode( AstNode::typeFunction ); | 66 | pAst->addNode( AstNode::typeFunction ); |
| 69 | pAst->openBranch(); | 67 | pAst->openBranch(); |
| 70 | pAst->addNode( AstNode::typeString, "unlink" ); | 68 | pAst->addNode( AstNode::typeString, "unlink" ); |
| @@ -89,28 +87,15 @@ void Profile::setCondition() | |||
| 89 | if( (*i)->getType() == AstNode::typeCondition ) | 87 | if( (*i)->getType() == AstNode::typeCondition ) |
| 90 | { | 88 | { |
| 91 | Bu::FString sCond = dynamic_cast<const AstLeaf *>(*i)->getStrValue(); | 89 | Bu::FString sCond = dynamic_cast<const AstLeaf *>(*i)->getStrValue(); |
| 92 | if( sCond == "filetime" ) | 90 | delete pCond; |
| 93 | { | 91 | pCond = ConditionPlugger::getInstance().instantiate( sCond ); |
| 94 | delete pCond; | ||
| 95 | pCond = new ConditionFileTime(); | ||
| 96 | } | ||
| 97 | else if( sCond == "always" ) | ||
| 98 | { | ||
| 99 | delete pCond; | ||
| 100 | pCond = new ConditionAlways(); | ||
| 101 | } | ||
| 102 | else if( sCond == "never" ) | ||
| 103 | { | ||
| 104 | delete pCond; | ||
| 105 | pCond = new ConditionNever(); | ||
| 106 | } | ||
| 107 | } | 92 | } |
| 108 | } | 93 | } |
| 109 | 94 | ||
| 110 | if( pCond == NULL ) | 95 | if( pCond == NULL ) |
| 111 | { | 96 | { |
| 112 | // The default condition | 97 | // The default condition |
| 113 | pCond = new ConditionFileTime(); | 98 | pCond = ConditionPlugger::getInstance().instantiate("fileTime"); |
| 114 | } | 99 | } |
| 115 | } | 100 | } |
| 116 | 101 | ||
diff --git a/src/viewplugger.cpp b/src/viewplugger.cpp index 6046f82..58f3605 100644 --- a/src/viewplugger.cpp +++ b/src/viewplugger.cpp | |||
| @@ -1,11 +1,35 @@ | |||
| 1 | #include "viewplugger.h" | 1 | #include "viewplugger.h" |
| 2 | 2 | ||
| 3 | #include <sys/types.h> | ||
| 4 | #include <dirent.h> | ||
| 5 | |||
| 3 | extern Bu::PluginInfo pluginViewDefault; | 6 | extern Bu::PluginInfo pluginViewDefault; |
| 4 | extern Bu::PluginInfo pluginViewMake; | 7 | extern Bu::PluginInfo pluginViewMake; |
| 5 | ViewPlugger::ViewPlugger() | 8 | ViewPlugger::ViewPlugger() |
| 6 | { | 9 | { |
| 7 | registerBuiltinPlugin( &pluginViewDefault ); | 10 | registerBuiltinPlugin( &pluginViewDefault ); |
| 8 | registerBuiltinPlugin( &pluginViewMake ); | 11 | registerBuiltinPlugin( &pluginViewMake ); |
| 12 | |||
| 13 | DIR *dir = opendir("/usr/lib/build"); | ||
| 14 | if( !dir ) | ||
| 15 | return; | ||
| 16 | struct dirent *de; | ||
| 17 | while( (de = readdir( dir )) ) | ||
| 18 | { | ||
| 19 | if( strncmp("pluginView", de->d_name, 15 ) ) | ||
| 20 | continue; | ||
| 21 | |||
| 22 | Bu::FString sFile("/usr/lib/build/"); | ||
| 23 | sFile += de->d_name; | ||
| 24 | char *s = de->d_name; | ||
| 25 | for(; *s && *s != '.'; s++ ) { } | ||
| 26 | registerExternalPlugin( | ||
| 27 | sFile, | ||
| 28 | Bu::FString( de->d_name, (ptrdiff_t)s-(ptrdiff_t)de->d_name ) | ||
| 29 | ); | ||
| 30 | } | ||
| 31 | |||
| 32 | closedir( dir ); | ||
| 9 | } | 33 | } |
| 10 | 34 | ||
| 11 | ViewPlugger::~ViewPlugger() | 35 | ViewPlugger::~ViewPlugger() |
