aboutsummaryrefslogtreecommitdiff
path: root/src/functionplugger.cpp
blob: a1674d6f7b6a21dd84dc233fbf1c68cf9d5b97bb (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * Copyright (C) 2007-2014 Xagasoft, All rights reserved.
 *
 * This file is part of the Xagasoft Build and is released under the
 * terms of the license contained in the file LICENSE.
 */

#include "functionplugger.h"

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

extern Bu::PluginInfo pluginFunctionDirName;
extern Bu::PluginInfo pluginFunctionDirs;
extern Bu::PluginInfo pluginFunctionExecute;
extern Bu::PluginInfo pluginFunctionExists;
extern Bu::PluginInfo pluginFunctionFileName;
extern Bu::PluginInfo pluginFunctionFiles;
extern Bu::PluginInfo pluginFunctionGetMakeDeps;
extern Bu::PluginInfo pluginFunctionMatches;
extern Bu::PluginInfo pluginFunctionReplace;
extern Bu::PluginInfo pluginFunctionTargets;
extern Bu::PluginInfo pluginFunctionToString;
extern Bu::PluginInfo pluginFunctionUnlink;
extern Bu::PluginInfo pluginFunctionRegEx;
extern Bu::PluginInfo pluginFunctionRange;
extern Bu::PluginInfo pluginFunctionOpen;
extern Bu::PluginInfo pluginFunctionClose;
extern Bu::PluginInfo pluginFunctionRead;
extern Bu::PluginInfo pluginFunctionWrite;
extern Bu::PluginInfo pluginFunctionUnique;

FunctionPlugger::FunctionPlugger()
{
    registerBuiltinPlugin( &pluginFunctionDirName );
    registerBuiltinPlugin( &pluginFunctionDirs );
    registerBuiltinPlugin( &pluginFunctionExecute );
    registerBuiltinPlugin( &pluginFunctionExists );
    registerBuiltinPlugin( &pluginFunctionFileName );
    registerBuiltinPlugin( &pluginFunctionFiles );
    registerBuiltinPlugin( &pluginFunctionGetMakeDeps );
    registerBuiltinPlugin( &pluginFunctionMatches );
    registerBuiltinPlugin( &pluginFunctionReplace );
    registerBuiltinPlugin( &pluginFunctionTargets );
    registerBuiltinPlugin( &pluginFunctionToString );
    registerBuiltinPlugin( &pluginFunctionUnlink );
    registerBuiltinPlugin( &pluginFunctionRegEx );
    registerBuiltinPlugin( &pluginFunctionRange );
    registerBuiltinPlugin( &pluginFunctionOpen );
    registerBuiltinPlugin( &pluginFunctionClose );
    registerBuiltinPlugin( &pluginFunctionRead );
    registerBuiltinPlugin( &pluginFunctionWrite );
    registerBuiltinPlugin( &pluginFunctionUnique );

    DIR *dir = opendir("/usr/lib/build");
    if( !dir )
        return;
    struct dirent *de;
    while( (de = readdir( dir )) )
    {
        if( strncmp("pluginFunction", 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 );
}

FunctionPlugger::~FunctionPlugger()
{
}