aboutsummaryrefslogtreecommitdiff
path: root/src/functiongetmakedeps.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/functiongetmakedeps.cpp')
-rw-r--r--src/functiongetmakedeps.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/functiongetmakedeps.cpp b/src/functiongetmakedeps.cpp
new file mode 100644
index 0000000..1aded15
--- /dev/null
+++ b/src/functiongetmakedeps.cpp
@@ -0,0 +1,59 @@
1#include "functiongetmakedeps.h"
2
3#include <bu/process.h>
4#include <bu/sio.h>
5using namespace Bu;
6
7FunctionGetMakeDeps::FunctionGetMakeDeps()
8{
9}
10
11FunctionGetMakeDeps::~FunctionGetMakeDeps()
12{
13}
14
15Bu::FString FunctionGetMakeDeps::getName() const
16{
17 return "getMakeDeps";
18}
19
20Variable FunctionGetMakeDeps::call( Variable &/*input*/, VarList lParams )
21{
22 Process p( Process::StdOut, "/bin/bash", "/bin/bash", "-c",
23 lParams.first().getString().getStr(), NULL );
24
25 // Gather all data from the command.
26 Bu::FString sBuf;
27 while( !p.isEos() )
28 {
29 char buf[4096];
30 int iRead = p.read( buf, 4096 );
31 sBuf.append( buf, iRead );
32 }
33
34 Variable vRet( Variable::typeList );
35
36 Bu::FString::iterator i, j;
37 i = sBuf.find(':')+2;
38 while( i )
39 {
40 // Find whitespace at the end of the word, this one is easy, there's
41 // always a space after a word
42 for( j = i; j && *j != ' ' && *j != '\n' && *j != '\r'; j++ ) { }
43
44 Bu::FString sTmp( i, j );
45 vRet.append( sTmp );
46
47 // Find the begining of the next word, trickier, we don't want to go
48 // off the end, and we need to skip \ chars at the ends of lines, right
49 // now this is too stupid to do that, so it may not work on windows.
50 // TODO: perhaps make this only skip \ chars at the ends of lines,
51 // we'll see if it matters.
52 for( i = j+1;
53 i && (*i == ' ' || *i == '\\' || *i == '\n' || *i == '\r'); i++ )
54 { }
55 }
56
57 return vRet;
58}
59