aboutsummaryrefslogtreecommitdiff
path: root/src/conditionplugger.cpp
blob: 53f613a1604521d8785d877636b8ea525b434bb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "conditionplugger.h"

#include <sys/types.h>
#include <dirent.h>

extern Bu::PluginInfo pluginConditionAlways;
extern Bu::PluginInfo pluginConditionNever;
extern Bu::PluginInfo pluginConditionFileTime;
extern Bu::PluginInfo pluginConditionFileExists;

ConditionPlugger::ConditionPlugger()
{
	registerBuiltinPlugin( &pluginConditionAlways );
	registerBuiltinPlugin( &pluginConditionNever );
	registerBuiltinPlugin( &pluginConditionFileTime );
	registerBuiltinPlugin( &pluginConditionFileExists );

	DIR *dir = opendir("/usr/lib/build");
	if( !dir )
		return;
	struct dirent *de;
	while( (de = readdir( dir )) )
	{
		if( strncmp("pluginCondition", de->d_name, 15 ) )
			continue;

		Bu::String sFile("/usr/lib/build/");
		sFile += de->d_name;
		char *s = de->d_name;
		for(; *s && *s != '.'; s++ ) { }
		registerExternalPlugin(
			sFile,
			Bu::String( de->d_name, (ptrdiff_t)s-(ptrdiff_t)de->d_name )
			);
	}

	closedir( dir );
}

ConditionPlugger::~ConditionPlugger()
{
}