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
|
#include "functiongetmakedeps.h"
#include "context.h"
#include "view.h"
#include <bu/process.h>
#include <bu/sio.h>
using namespace Bu;
#include <bu/plugger.h>
PluginInterface3( pluginFunctionGetMakeDeps, getMakeDeps, FunctionGetMakeDeps,
Function, "Mike Buland", 0, 1 );
FunctionGetMakeDeps::FunctionGetMakeDeps()
{
}
FunctionGetMakeDeps::~FunctionGetMakeDeps()
{
}
Bu::FString FunctionGetMakeDeps::getName() const
{
return "getMakeDeps";
}
Variable FunctionGetMakeDeps::call( Variable &/*input*/, VarList lParams )
{
pContext->getView()->cmdStarted( lParams.first().getString().getStr() );
Process p( Process::StdOut, "/bin/bash", "/bin/bash", "-c",
lParams.first().getString().getStr(), NULL );
// Gather all data from the command.
Bu::FString sBuf;
while( !p.isEos() )
{
char buf[4096];
int iRead = p.read( buf, 4096 );
sBuf.append( buf, iRead );
}
pContext->getView()->cmdFinished( "", "", p.childExitStatus() );
Variable vRet( Variable::typeList );
Bu::FString::iterator i, j;
i = sBuf.find(':')+2;
while( i )
{
// Find whitespace at the end of the word, this one is easy, there's
// always a space after a word
for( j = i; j && *j != ' ' && *j != '\n' && *j != '\r'; j++ ) { }
Bu::FString sTmp( i, j );
vRet.append( sTmp );
// Find the begining of the next word, trickier, we don't want to go
// off the end, and we need to skip \ chars at the ends of lines, right
// now this is too stupid to do that, so it may not work on windows.
// TODO: perhaps make this only skip \ chars at the ends of lines,
// we'll see if it matters.
for( i = j+1;
i && (*i == ' ' || *i == '\\' || *i == '\n' || *i == '\r'); i++ )
{ }
}
return vRet;
}
|