aboutsummaryrefslogtreecommitdiff
path: root/src/filetarget.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/filetarget.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/filetarget.cpp b/src/filetarget.cpp
index b9d7946..65f9d70 100644
--- a/src/filetarget.cpp
+++ b/src/filetarget.cpp
@@ -1,4 +1,9 @@
1#include <errno.h>
2#include <dirent.h>
3
4#include "rule.h"
1#include "filetarget.h" 5#include "filetarget.h"
6#include "builder.h" // for BuildException
2 7
3FileTarget::FileTarget( const char *sName ) : 8FileTarget::FileTarget( const char *sName ) :
4 Target( sName ) 9 Target( sName )
@@ -15,3 +20,63 @@ void FileTarget::debug()
15 printf(" type: FileTarget\n"); 20 printf(" type: FileTarget\n");
16} 21}
17 22
23char *gnu_getcwd()
24{
25 size_t size = 1024;
26
27 while (1)
28 {
29 char *buffer = new char[size];
30 if (getcwd (buffer, size) == buffer)
31 return buffer;
32 delete[] buffer;
33 if (errno != ERANGE)
34 return 0;
35 size *= 2;
36 }
37}
38
39void FileTarget::addInputDir( const char *sDir )
40{
41 DIR *dir = opendir( sDir );
42 if( dir == NULL )
43 {
44 throw BuildException( strerror( errno ) );
45 }
46
47 char *cwd = gnu_getcwd();
48 std::string base( cwd );
49 base += "/";
50 base += sDir;
51 delete[] cwd;
52
53 struct dirent *de;
54
55 while( (de = readdir( dir )) )
56 {
57 if( de->d_name[0] == '.' || de->d_name[0] == '\0' )
58 continue;
59
60 std::string s( base );
61 s += "/";
62 s += de->d_name;
63 addInput( s.c_str() );
64 }
65
66 closedir( dir );
67}
68
69void FileTarget::check( Builder &bld )
70{
71 Rule *pRule = bld.getRule( sRule );
72
73 std::list<std::string> tmp = pRule->execute( bld, lInput );
74 lOutput.insert( lOutput.end(), tmp.begin(), tmp.end() );
75
76 bld.processRequires( lInput );
77}
78
79void FileTarget::clean( Builder &bld )
80{
81}
82