diff options
-rw-r--r-- | build.conf | 2 | ||||
-rw-r--r-- | src/action.cpp | 9 | ||||
-rw-r--r-- | src/action.h | 8 | ||||
-rw-r--r-- | src/build.cpp | 41 | ||||
-rw-r--r-- | src/build.y | 6 | ||||
-rw-r--r-- | src/buildparser.cpp | 41 | ||||
-rw-r--r-- | src/buildparser.h | 16 |
7 files changed, 95 insertions, 28 deletions
@@ -1,6 +1,6 @@ | |||
1 | # build.conf for build, kind of whacky, eh? | 1 | # build.conf for build, kind of whacky, eh? |
2 | 2 | ||
3 | default action: check targets() | 3 | default action: check group "program" |
4 | "clean" action: clean targets() | 4 | "clean" action: clean targets() |
5 | "rebuild" action: clean "build", check "build" | 5 | "rebuild" action: clean "build", check "build" |
6 | 6 | ||
diff --git a/src/action.cpp b/src/action.cpp index cae4f01..2588caa 100644 --- a/src/action.cpp +++ b/src/action.cpp | |||
@@ -8,9 +8,9 @@ Action::~Action() | |||
8 | { | 8 | { |
9 | } | 9 | } |
10 | 10 | ||
11 | void Action::addCommand( eAction act, const std::string &sWhat ) | 11 | void Action::addCommand( eAction act, const std::string &sWhat, bool bIsGroup ) |
12 | { | 12 | { |
13 | lCmds.push_back( Cmd( act, sWhat ) ); | 13 | lCmds.push_back( Cmd( act, sWhat, bIsGroup ) ); |
14 | } | 14 | } |
15 | 15 | ||
16 | void Action::begin() | 16 | void Action::begin() |
@@ -38,6 +38,11 @@ std::string Action::getWhat() | |||
38 | return (*i).sWhat; | 38 | return (*i).sWhat; |
39 | } | 39 | } |
40 | 40 | ||
41 | bool Action::isGroup() | ||
42 | { | ||
43 | return (*i).bIsGroup; | ||
44 | } | ||
45 | |||
41 | void Action::setMode( eAction nAct ) | 46 | void Action::setMode( eAction nAct ) |
42 | { | 47 | { |
43 | for( CmdList::iterator j = lCmds.begin(); j != lCmds.end(); j++ ) | 48 | for( CmdList::iterator j = lCmds.begin(); j != lCmds.end(); j++ ) |
diff --git a/src/action.h b/src/action.h index 25badad..929c1c5 100644 --- a/src/action.h +++ b/src/action.h | |||
@@ -20,14 +20,15 @@ public: | |||
20 | 20 | ||
21 | typedef struct Cmd | 21 | typedef struct Cmd |
22 | { | 22 | { |
23 | Cmd( eAction act, const std::string &sWhat ) : | 23 | Cmd( eAction act, const std::string &sWhat, bool bIsGroup ) : |
24 | act( act ), sWhat( sWhat ) | 24 | act( act ), sWhat( sWhat ), bIsGroup( bIsGroup ) |
25 | {} | 25 | {} |
26 | eAction act; | 26 | eAction act; |
27 | std::string sWhat; | 27 | std::string sWhat; |
28 | bool bIsGroup; | ||
28 | } Cmd; | 29 | } Cmd; |
29 | 30 | ||
30 | void addCommand( eAction act, const std::string &sWhat ); | 31 | void addCommand( eAction act, const std::string &sWhat, bool bIsGroup ); |
31 | 32 | ||
32 | void begin(); | 33 | void begin(); |
33 | bool isEnded(); | 34 | bool isEnded(); |
@@ -40,6 +41,7 @@ public: | |||
40 | 41 | ||
41 | eAction getAct(); | 42 | eAction getAct(); |
42 | std::string getWhat(); | 43 | std::string getWhat(); |
44 | bool isGroup(); | ||
43 | 45 | ||
44 | void setName( const std::string &sName ) | 46 | void setName( const std::string &sName ) |
45 | { | 47 | { |
diff --git a/src/build.cpp b/src/build.cpp index db14750..a7421de 100644 --- a/src/build.cpp +++ b/src/build.cpp | |||
@@ -78,17 +78,36 @@ void Build::execAction( const std::string &sWhat ) | |||
78 | 78 | ||
79 | for( pAct->begin(); !pAct->isEnded(); pAct->next() ) | 79 | for( pAct->begin(); !pAct->isEnded(); pAct->next() ) |
80 | { | 80 | { |
81 | if( mTarget.find( pAct->getWhat() ) == mTarget.end() ) | 81 | if( pAct->isGroup() ) |
82 | throw BuildException( | 82 | { |
83 | "No target matches %s in action %s.", | 83 | if( mGroup.find( pAct->getWhat() ) == mGroup.end() ) |
84 | pAct->getWhat().c_str(), | 84 | throw BuildException( |
85 | sWhat.c_str() | 85 | "No group matches %s in action %s.", |
86 | ); | 86 | pAct->getWhat().c_str(), |
87 | Target *pTarget = mTarget[pAct->getWhat()]; | 87 | sWhat.c_str() |
88 | //pView->beginCommand( pAct->getAct(), pAct->getWhat() ); | 88 | ); |
89 | if( !pTarget->wasRun() ) | 89 | TargetList &sl = mGroup[pAct->getWhat()]; |
90 | pTarget->run( pAct->getAct(), *this ); | 90 | for( TargetList::iterator i = sl.begin(); i != sl.end(); i++ ) |
91 | //pView->endCommand(); | 91 | { |
92 | Target *pTarget = *i; | ||
93 | if( !pTarget->wasRun() ) | ||
94 | pTarget->run( pAct->getAct(), *this ); | ||
95 | } | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | if( mTarget.find( pAct->getWhat() ) == mTarget.end() ) | ||
100 | throw BuildException( | ||
101 | "No target matches %s in action %s.", | ||
102 | pAct->getWhat().c_str(), | ||
103 | sWhat.c_str() | ||
104 | ); | ||
105 | Target *pTarget = mTarget[pAct->getWhat()]; | ||
106 | //pView->beginCommand( pAct->getAct(), pAct->getWhat() ); | ||
107 | if( !pTarget->wasRun() ) | ||
108 | pTarget->run( pAct->getAct(), *this ); | ||
109 | //pView->endCommand(); | ||
110 | } | ||
92 | } | 111 | } |
93 | 112 | ||
94 | pView->endAction(); | 113 | pView->endAction(); |
diff --git a/src/build.y b/src/build.y index bfda4b4..55940e8 100644 --- a/src/build.y +++ b/src/build.y | |||
@@ -125,7 +125,13 @@ actioncmd: TOK_CHECK list | |||
125 | bld.addCommand( Action::actClean ); | 125 | bld.addCommand( Action::actClean ); |
126 | } | 126 | } |
127 | | TOK_CHECK TOK_GROUP STRING | 127 | | TOK_CHECK TOK_GROUP STRING |
128 | { | ||
129 | bld.addGrpCommand( $3, Action::actCheck ); | ||
130 | } | ||
128 | | TOK_CLEAN TOK_GROUP STRING | 131 | | TOK_CLEAN TOK_GROUP STRING |
132 | { | ||
133 | bld.addGrpCommand( $3, Action::actClean ); | ||
134 | } | ||
129 | ; | 135 | ; |
130 | 136 | ||
131 | // Target interpretation | 137 | // Target interpretation |
diff --git a/src/buildparser.cpp b/src/buildparser.cpp index 364aaa5..50fc0fc 100644 --- a/src/buildparser.cpp +++ b/src/buildparser.cpp | |||
@@ -283,7 +283,7 @@ void BuildParser::addPerformParam( const char *sParam ) | |||
283 | // | 283 | // |
284 | void BuildParser::addAction() | 284 | void BuildParser::addAction() |
285 | { | 285 | { |
286 | lActions.push_back( ActionTmp("", ActionTmpCmdList()) ); | 286 | lActions.push_back( ActionTmp("", ActionTmpCmdList() ) ); |
287 | } | 287 | } |
288 | 288 | ||
289 | void BuildParser::addAction( const char *sName ) | 289 | void BuildParser::addAction( const char *sName ) |
@@ -296,6 +296,11 @@ void BuildParser::addCommand( int nType ) | |||
296 | lActions.back().second.push_back( ActionTmpCmd( nType, lTmp ) ); | 296 | lActions.back().second.push_back( ActionTmpCmd( nType, lTmp ) ); |
297 | } | 297 | } |
298 | 298 | ||
299 | void BuildParser::addGrpCommand( const char *sGroup, int nType ) | ||
300 | { | ||
301 | lActions.back().second.push_back( ActionTmpCmd( nType, sGroup ) ); | ||
302 | } | ||
303 | |||
299 | // | 304 | // |
300 | // Global variable functions | 305 | // Global variable functions |
301 | // | 306 | // |
@@ -324,8 +329,15 @@ void BuildParser::debugDump() | |||
324 | for( ActionTmpCmdList::iterator j = (*i).second.begin(); | 329 | for( ActionTmpCmdList::iterator j = (*i).second.begin(); |
325 | j != (*i).second.end(); j++ ) | 330 | j != (*i).second.end(); j++ ) |
326 | { | 331 | { |
327 | printf(" %d ", (*j).first ); | 332 | printf(" %d ", (*j).nAct ); |
328 | printBuildList( (*j).second ); | 333 | if( (*j).bGroup ) |
334 | { | ||
335 | printf("!%s", (*j).sGroup.c_str() ); | ||
336 | } | ||
337 | else | ||
338 | { | ||
339 | printBuildList( (*j).lCmds ); | ||
340 | } | ||
329 | printf("\n"); | 341 | printf("\n"); |
330 | } | 342 | } |
331 | } | 343 | } |
@@ -555,14 +567,23 @@ Build *BuildParser::genBuild() | |||
555 | for( ActionTmpCmdList::iterator j = (*i).second.begin(); | 567 | for( ActionTmpCmdList::iterator j = (*i).second.begin(); |
556 | j != (*i).second.end(); j++ ) | 568 | j != (*i).second.end(); j++ ) |
557 | { | 569 | { |
558 | StringList lWhat = buildToStringList( | 570 | if( (*j).bGroup ) |
559 | (*j).second, StringList(), bld | 571 | { |
560 | ); | 572 | pAct->addCommand( |
561 | 573 | (Action::eAction)((*j).nAct), (*j).sGroup, true | |
562 | for( StringList::iterator k = lWhat.begin(); | 574 | ); |
563 | k != lWhat.end(); k++ ) | 575 | } |
576 | else | ||
564 | { | 577 | { |
565 | pAct->addCommand( (Action::eAction)((*j).first), *k ); | 578 | StringList lWhat = buildToStringList( |
579 | (*j).lCmds, StringList(), bld | ||
580 | ); | ||
581 | |||
582 | for( StringList::iterator k = lWhat.begin(); | ||
583 | k != lWhat.end(); k++ ) | ||
584 | { | ||
585 | pAct->addCommand( (Action::eAction)((*j).nAct), *k, false ); | ||
586 | } | ||
566 | } | 587 | } |
567 | } | 588 | } |
568 | 589 | ||
diff --git a/src/buildparser.h b/src/buildparser.h index fd988c6..516760c 100644 --- a/src/buildparser.h +++ b/src/buildparser.h | |||
@@ -156,10 +156,24 @@ public: // Action functions | |||
156 | void addAction(); | 156 | void addAction(); |
157 | void addAction( const char *sName ); | 157 | void addAction( const char *sName ); |
158 | void addCommand( int nType ); | 158 | void addCommand( int nType ); |
159 | void addGrpCommand( const char *sGroup, int nType ); | ||
159 | 160 | ||
160 | private: // Action variables | 161 | private: // Action variables |
161 | typedef std::pair<int, BuildList> ActionTmpCmd; | 162 | typedef struct ActionTmpCmd |
163 | { | ||
164 | ActionTmpCmd( int nAct, BuildList &l ) : | ||
165 | nAct( nAct ), bGroup( false ), lCmds( l ) { }; | ||
166 | ActionTmpCmd( int nAct, const char *s ) : | ||
167 | nAct( nAct ), bGroup( true ), sGroup( s ) { }; | ||
168 | int nAct; | ||
169 | bool bGroup; | ||
170 | BuildList lCmds; | ||
171 | std::string sGroup; | ||
172 | } ActionTmpCmd; | ||
173 | //typedef std::pair<int, BuildList> ActionTmpCmd; | ||
174 | //typedef std::pair<int, std::string> ActionTmpGrpCmd | ||
162 | typedef std::list<ActionTmpCmd> ActionTmpCmdList; | 175 | typedef std::list<ActionTmpCmd> ActionTmpCmdList; |
176 | //typedef std::list<ActionTmpGrpCmd> ActionTmpGrpCmdList; | ||
163 | typedef std::pair<std::string, ActionTmpCmdList> ActionTmp; | 177 | typedef std::pair<std::string, ActionTmpCmdList> ActionTmp; |
164 | typedef std::list<ActionTmp> ActionTmpList; | 178 | typedef std::list<ActionTmp> ActionTmpList; |
165 | ActionTmpList lActions; | 179 | ActionTmpList lActions; |