aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/build.h5
-rw-r--r--src/buildparser.cpp35
-rw-r--r--src/buildparser.h5
-rw-r--r--src/functiondirectoriesin.cpp22
-rw-r--r--src/functionfactory.cpp2
-rw-r--r--src/functiontargets.cpp35
-rw-r--r--src/functiontargets.h21
7 files changed, 119 insertions, 6 deletions
diff --git a/src/build.h b/src/build.h
index 31c8bde..a35b8e2 100644
--- a/src/build.h
+++ b/src/build.h
@@ -61,6 +61,11 @@ public:
61 return pView; 61 return pView;
62 } 62 }
63 63
64 TargetMap &getTargetMap()
65 {
66 return mTarget;
67 }
68
64private: 69private:
65 TargetMap mTarget; 70 TargetMap mTarget;
66 ReqMap mRequires; 71 ReqMap mRequires;
diff --git a/src/buildparser.cpp b/src/buildparser.cpp
index 6c3337f..04147d8 100644
--- a/src/buildparser.cpp
+++ b/src/buildparser.cpp
@@ -129,7 +129,7 @@ void BuildParser::filterList()
129 } 129 }
130} 130}
131 131
132StringList BuildParser::buildToStringList( const BuildList &lSrc, const StringList &lIn ) 132StringList BuildParser::buildToStringList( const BuildList &lSrc, const StringList &lIn, Build *pPass )
133{ 133{
134 StringList lOut; 134 StringList lOut;
135 135
@@ -137,7 +137,28 @@ StringList BuildParser::buildToStringList( const BuildList &lSrc, const StringLi
137 { 137 {
138 if( (*i).second ) 138 if( (*i).second )
139 { 139 {
140 (*i).second->execute( NULL, lIn, lOut ); 140 (*i).second->execute( pPass, lIn, lOut );
141 }
142 else
143 {
144 lOut.push_back( (*i).first );
145 }
146 }
147
148 return lOut;
149}
150
151StringList BuildParser::buildToStringListDup( const BuildList &lSrc, const StringList &lIn, Build &bld, const std::string &sCont, VarMap *mExtra, Build *pPass )
152{
153 StringList lOut;
154
155 for( BuildList::const_iterator i = lSrc.begin(); i != lSrc.end(); i++ )
156 {
157 if( (*i).second )
158 {
159 Function *pTmp = (*i).second->duplicate( bld, sCont, mExtra );
160 pTmp->execute( pPass, lIn, lOut );
161 delete pTmp;
141 } 162 }
142 else 163 else
143 { 164 {
@@ -384,8 +405,12 @@ Build *BuildParser::genBuild()
384 pTarget->setName( *j ); 405 pTarget->setName( *j );
385 pTarget->setRule( (*i).second.sRule ); 406 pTarget->setRule( (*i).second.sRule );
386 407
387 StringList lInputs = buildToStringList( 408 VarMap mExtra;
388 (*i).second.lInput, StringList() 409 mExtra["target"] = (*j);
410
411 StringList lInputs = buildToStringListDup(
412 (*i).second.lInput, StringList(),
413 *bld, *j, &mExtra
389 ); 414 );
390 pTarget->getInput().insert( 415 pTarget->getInput().insert(
391 pTarget->getInput().end(), 416 pTarget->getInput().end(),
@@ -480,7 +505,7 @@ Build *BuildParser::genBuild()
480 j != (*i).second.end(); j++ ) 505 j != (*i).second.end(); j++ )
481 { 506 {
482 StringList lWhat = buildToStringList( 507 StringList lWhat = buildToStringList(
483 (*j).second, StringList() 508 (*j).second, StringList(), bld
484 ); 509 );
485 510
486 for( StringList::iterator k = lWhat.begin(); 511 for( StringList::iterator k = lWhat.begin();
diff --git a/src/buildparser.h b/src/buildparser.h
index dda2d80..3c79a5b 100644
--- a/src/buildparser.h
+++ b/src/buildparser.h
@@ -5,6 +5,7 @@
5#include <string> 5#include <string>
6#include <list> 6#include <list>
7#include <utility> 7#include <utility>
8#include <map>
8#include "build.tab.h" 9#include "build.tab.h"
9#include "parser.h" 10#include "parser.h"
10 11
@@ -23,6 +24,7 @@ YY_DECL;
23typedef std::list<std::string> StringList; 24typedef std::list<std::string> StringList;
24typedef std::list<Function *> FunctionList; 25typedef std::list<Function *> FunctionList;
25typedef std::list<Perform *> PerformList; 26typedef std::list<Perform *> PerformList;
27typedef std::map<std::string,std::string> VarMap;
26 28
27template<class tx, class ty, class tz> 29template<class tx, class ty, class tz>
28class Triplet 30class Triplet
@@ -115,7 +117,8 @@ public: // List functions
115 void addListFunc(); 117 void addListFunc();
116 void filterList(); 118 void filterList();
117 119
118 StringList buildToStringList( const BuildList &lSrc, const StringList &lIn ); 120 StringList buildToStringList( const BuildList &lSrc, const StringList &lIn, Build *pPass=NULL );
121 StringList buildToStringListDup( const BuildList &lSrc, const StringList &lIn, Build &bld, const std::string &sCont, VarMap *mExtra, Build *pPass=NULL );
119 122
120private: // List variables 123private: // List variables
121 BuildList lTmp; 124 BuildList lTmp;
diff --git a/src/functiondirectoriesin.cpp b/src/functiondirectoriesin.cpp
index 0e90dbc..105e98d 100644
--- a/src/functiondirectoriesin.cpp
+++ b/src/functiondirectoriesin.cpp
@@ -1,3 +1,5 @@
1#include <dirent.h>
2
1#include "functiondirectoriesin.h" 3#include "functiondirectoriesin.h"
2#include "plugger.h" 4#include "plugger.h"
3 5
@@ -13,6 +15,26 @@ FunctionDirectoriesIn::~FunctionDirectoriesIn()
13 15
14void FunctionDirectoriesIn::execute( Build *bld, const StringList &lInput, StringList &lOutput ) 16void FunctionDirectoriesIn::execute( Build *bld, const StringList &lInput, StringList &lOutput )
15{ 17{
18 DIR *d = opendir( lParams.front().c_str() );
19 if( d == NULL )
20 throw BuildException(
21 "Can't open directory %s.",
22 lParams.front().c_str()
23 );
24
25 struct dirent *e;
26
27 //std::string prefix = lParams.front() + "/";
28
29 while( (e = readdir( d )) )
30 {
31 if( e->d_type == DT_DIR )
32 {
33 lOutput.push_back( e->d_name );
34 }
35 }
36
37 closedir( d );
16} 38}
17 39
18Function *FunctionDirectoriesIn::duplicate( Build &bld, const std::string &cont, VarMap *mExtra ) 40Function *FunctionDirectoriesIn::duplicate( Build &bld, const std::string &cont, VarMap *mExtra )
diff --git a/src/functionfactory.cpp b/src/functionfactory.cpp
index b78cfcb..4a2cd15 100644
--- a/src/functionfactory.cpp
+++ b/src/functionfactory.cpp
@@ -5,6 +5,7 @@ extern struct PluginInfo filesIn;
5extern struct PluginInfo regexp; 5extern struct PluginInfo regexp;
6extern struct PluginInfo toString; 6extern struct PluginInfo toString;
7extern struct PluginInfo commandToList; 7extern struct PluginInfo commandToList;
8extern struct PluginInfo targets;
8 9
9FunctionFactory::FunctionFactory() 10FunctionFactory::FunctionFactory()
10{ 11{
@@ -13,6 +14,7 @@ FunctionFactory::FunctionFactory()
13 registerBuiltinPlugin( &regexp ); 14 registerBuiltinPlugin( &regexp );
14 registerBuiltinPlugin( &toString ); 15 registerBuiltinPlugin( &toString );
15 registerBuiltinPlugin( &commandToList ); 16 registerBuiltinPlugin( &commandToList );
17 registerBuiltinPlugin( &targets );
16} 18}
17 19
18FunctionFactory::~FunctionFactory() 20FunctionFactory::~FunctionFactory()
diff --git a/src/functiontargets.cpp b/src/functiontargets.cpp
new file mode 100644
index 0000000..253b585
--- /dev/null
+++ b/src/functiontargets.cpp
@@ -0,0 +1,35 @@
1#include "functiontargets.h"
2#include "plugger.h"
3#include "build.h"
4
5PluginInterface2(targets, FunctionTargets, Function, "Mike Buland", 0, 1 );
6
7FunctionTargets::FunctionTargets()
8{
9}
10
11FunctionTargets::~FunctionTargets()
12{
13}
14
15void FunctionTargets::execute( Build *bld, const StringList &lInput, StringList &lOutput )
16{
17 if( bld == NULL )
18 {
19 throw BuildException("You cannot call targets() from anywhere, see the manual.");
20 }
21
22 for( TargetMap::iterator i = bld->getTargetMap().begin();
23 i != bld->getTargetMap().end(); i++ )
24 {
25 lOutput.push_back( (*i).first );
26 }
27}
28
29Function *FunctionTargets::duplicate( Build &bld, const std::string &cont, VarMap *mExtra )
30{
31 Function *pRet = new FunctionTargets();
32 pRet->copyData( this, bld, cont, mExtra );
33 return pRet;
34}
35
diff --git a/src/functiontargets.h b/src/functiontargets.h
new file mode 100644
index 0000000..8d3a0ed
--- /dev/null
+++ b/src/functiontargets.h
@@ -0,0 +1,21 @@
1#ifndef FUNCTION_TARGETS_H
2#define FUNCTION_TARGETS_H
3
4#include <stdint.h>
5
6#include "function.h"
7
8class FunctionTargets : public Function
9{
10public:
11 FunctionTargets();
12 virtual ~FunctionTargets();
13
14 virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput );
15 virtual Function *duplicate( Build &bld, const std::string &cont, VarMap *mExtra );
16
17private:
18
19};
20
21#endif