diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-04-24 14:09:50 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-24 14:09:50 +0000 |
commit | ff938b977db21378a1f016f65e7345c50e71ef8f (patch) | |
tree | 0f05b9b5b5ea13ce234cdd27e1eb8ccbccb2dc51 /src | |
parent | be41caa5ca6756c7809cabaf6d8bee321928c45a (diff) | |
download | build-ff938b977db21378a1f016f65e7345c50e71ef8f.tar.gz build-ff938b977db21378a1f016f65e7345c50e71ef8f.tar.bz2 build-ff938b977db21378a1f016f65e7345c50e71ef8f.tar.xz build-ff938b977db21378a1f016f65e7345c50e71ef8f.zip |
Half way there on the road to implementing basic group functionality. You can
create groups, you can't do anything with them yet (although the syntax is
supported already.)
Diffstat (limited to '')
-rw-r--r-- | src/build.cpp | 23 | ||||
-rw-r--r-- | src/build.h | 4 | ||||
-rw-r--r-- | src/build.l | 1 | ||||
-rw-r--r-- | src/build.y | 7 | ||||
-rw-r--r-- | src/buildparser.cpp | 11 | ||||
-rw-r--r-- | src/buildparser.h | 2 |
6 files changed, 48 insertions, 0 deletions
diff --git a/src/build.cpp b/src/build.cpp index 889efa4..db14750 100644 --- a/src/build.cpp +++ b/src/build.cpp | |||
@@ -289,6 +289,19 @@ void Build::debugDump() | |||
289 | } | 289 | } |
290 | printf("\n"); | 290 | printf("\n"); |
291 | } | 291 | } |
292 | |||
293 | printf("Groups:\n"); | ||
294 | for( GroupMap::iterator i = mGroup.begin(); i != mGroup.end(); i++ ) | ||
295 | { | ||
296 | printf(" %s: ", (*i).first.c_str() ); | ||
297 | for( TargetList::iterator j = (*i).second.begin(); | ||
298 | j != (*i).second.end(); j++ ) | ||
299 | { | ||
300 | if( j != (*i).second.begin() ) printf(", "); | ||
301 | printf("%s", (*j)->getName().c_str() ); | ||
302 | } | ||
303 | printf("\n"); | ||
304 | } | ||
292 | } | 305 | } |
293 | 306 | ||
294 | RuleList Build::findChainRules( Rule *pHead ) | 307 | RuleList Build::findChainRules( Rule *pHead ) |
@@ -387,3 +400,13 @@ void Build::setMode( Action::eAction nAct ) | |||
387 | } | 400 | } |
388 | } | 401 | } |
389 | 402 | ||
403 | void Build::addToGroup( const std::string &sGroup, Target *pTarget ) | ||
404 | { | ||
405 | if( mGroup.find( sGroup ) == mGroup.end() ) | ||
406 | { | ||
407 | mGroup[sGroup] = TargetList(); | ||
408 | } | ||
409 | |||
410 | mGroup[sGroup].push_back( pTarget ); | ||
411 | } | ||
412 | |||
diff --git a/src/build.h b/src/build.h index dd8c11b..768d211 100644 --- a/src/build.h +++ b/src/build.h | |||
@@ -22,6 +22,8 @@ typedef std::map<std::string, VarMap> ContextMap; | |||
22 | typedef std::map<std::string, Rule *> RuleMap; | 22 | typedef std::map<std::string, Rule *> RuleMap; |
23 | typedef std::list<Rule *> RuleList; | 23 | typedef std::list<Rule *> RuleList; |
24 | typedef std::map<std::string, Action *> ActionMap; | 24 | typedef std::map<std::string, Action *> ActionMap; |
25 | typedef std::list<Target *> TargetList; | ||
26 | typedef std::map<std::string, TargetList> GroupMap; | ||
25 | 27 | ||
26 | class Viewer; | 28 | class Viewer; |
27 | 29 | ||
@@ -43,6 +45,7 @@ public: | |||
43 | void addRequires( const std::string &who, const std::string &what ); | 45 | void addRequires( const std::string &who, const std::string &what ); |
44 | void addRule( Rule *pRule ); | 46 | void addRule( Rule *pRule ); |
45 | void addAction( Action *pAction ); | 47 | void addAction( Action *pAction ); |
48 | void addToGroup( const std::string &sGroup, Target *pTarget ); | ||
46 | 49 | ||
47 | void set( const std::string &cont, const std::string &var, const std::string &val ); | 50 | void set( const std::string &cont, const std::string &var, const std::string &val ); |
48 | void setAdd( const std::string &cont, const std::string &var, const std::string &val ); | 51 | void setAdd( const std::string &cont, const std::string &var, const std::string &val ); |
@@ -92,6 +95,7 @@ private: | |||
92 | Cache cRequires; | 95 | Cache cRequires; |
93 | bool bCacheUpdated; | 96 | bool bCacheUpdated; |
94 | std::string sCacheName; | 97 | std::string sCacheName; |
98 | GroupMap mGroup; | ||
95 | 99 | ||
96 | //std::map<std::string, Rule *> mRule; | 100 | //std::map<std::string, Rule *> mRule; |
97 | //Action *pActDefault; | 101 | //Action *pActDefault; |
diff --git a/src/build.l b/src/build.l index 15c4003..5b69177 100644 --- a/src/build.l +++ b/src/build.l | |||
@@ -36,6 +36,7 @@ std::string strbuf; | |||
36 | "filter" return TOK_FILTER; | 36 | "filter" return TOK_FILTER; |
37 | "prefix" return TOK_PREFIX; | 37 | "prefix" return TOK_PREFIX; |
38 | "aggregate" return TOK_AGGREGATE; | 38 | "aggregate" return TOK_AGGREGATE; |
39 | "group" return TOK_GROUP; | ||
39 | 40 | ||
40 | \n+ { | 41 | \n+ { |
41 | yylloc->last_line += yyleng; | 42 | yylloc->last_line += yyleng; |
diff --git a/src/build.y b/src/build.y index 0853bd9..bfda4b4 100644 --- a/src/build.y +++ b/src/build.y | |||
@@ -40,6 +40,7 @@ void yyerror( YYLTYPE *locp, BuildParser &bld, char const *msg ); | |||
40 | %token TOK_PERFORM "perform" | 40 | %token TOK_PERFORM "perform" |
41 | %token TOK_PRODUCES "produces" | 41 | %token TOK_PRODUCES "produces" |
42 | %token TOK_AGGREGATE "aggregate" | 42 | %token TOK_AGGREGATE "aggregate" |
43 | %token TOK_GROUP "group" | ||
43 | 44 | ||
44 | %token ',' ':' '=' '(' ')' | 45 | %token ',' ':' '=' '(' ')' |
45 | 46 | ||
@@ -123,6 +124,8 @@ actioncmd: TOK_CHECK list | |||
123 | { | 124 | { |
124 | bld.addCommand( Action::actClean ); | 125 | bld.addCommand( Action::actClean ); |
125 | } | 126 | } |
127 | | TOK_CHECK TOK_GROUP STRING | ||
128 | | TOK_CLEAN TOK_GROUP STRING | ||
126 | ; | 129 | ; |
127 | 130 | ||
128 | // Target interpretation | 131 | // Target interpretation |
@@ -158,6 +161,10 @@ targetcmd: TOK_RULE STRING | |||
158 | bld.addTargetRequires(); | 161 | bld.addTargetRequires(); |
159 | } | 162 | } |
160 | | TOK_SET targetset | 163 | | TOK_SET targetset |
164 | | TOK_GROUP STRING | ||
165 | { | ||
166 | bld.addTargetGroup( $2 ); | ||
167 | } | ||
161 | ; | 168 | ; |
162 | 169 | ||
163 | targetset: STRING '=' STRING | 170 | targetset: STRING '=' STRING |
diff --git a/src/buildparser.cpp b/src/buildparser.cpp index 1c4f041..364aaa5 100644 --- a/src/buildparser.cpp +++ b/src/buildparser.cpp | |||
@@ -83,6 +83,11 @@ void BuildParser::addTargetSet( const char *sVar, const char *sVal, int nHow ) | |||
83 | lTargetTmp.back().second.lVar.push_back( SetVar( sVar, sVal, nHow ) ); | 83 | lTargetTmp.back().second.lVar.push_back( SetVar( sVar, sVal, nHow ) ); |
84 | } | 84 | } |
85 | 85 | ||
86 | void BuildParser::addTargetGroup( const char *sGroup ) | ||
87 | { | ||
88 | lTargetTmp.back().second.lGroups.push_back( sGroup ); | ||
89 | } | ||
90 | |||
86 | // | 91 | // |
87 | // Function functions | 92 | // Function functions |
88 | // | 93 | // |
@@ -458,6 +463,12 @@ Build *BuildParser::genBuild() | |||
458 | ); | 463 | ); |
459 | 464 | ||
460 | bld->addTarget( pTarget ); | 465 | bld->addTarget( pTarget ); |
466 | |||
467 | for( StringList::iterator c = (*i).second.lGroups.begin(); | ||
468 | c != (*i).second.lGroups.end(); c++ ) | ||
469 | { | ||
470 | bld->addToGroup( *c, pTarget ); | ||
471 | } | ||
461 | } | 472 | } |
462 | StringList lReqs = buildToStringList( | 473 | StringList lReqs = buildToStringList( |
463 | (*i).second.lRequires, StringList() | 474 | (*i).second.lRequires, StringList() |
diff --git a/src/buildparser.h b/src/buildparser.h index 13c523c..fd988c6 100644 --- a/src/buildparser.h +++ b/src/buildparser.h | |||
@@ -77,6 +77,7 @@ public: // Target functions | |||
77 | void addTargetInput(); | 77 | void addTargetInput(); |
78 | void addTargetRequires(); | 78 | void addTargetRequires(); |
79 | void addTargetSet( const char *sVar, const char *sVal, int nHow ); | 79 | void addTargetSet( const char *sVar, const char *sVal, int nHow ); |
80 | void addTargetGroup( const char *sGroup ); | ||
80 | 81 | ||
81 | private: // Target variables | 82 | private: // Target variables |
82 | TargetFactory &fTarget; | 83 | TargetFactory &fTarget; |
@@ -88,6 +89,7 @@ private: // Target variables | |||
88 | std::string sType; | 89 | std::string sType; |
89 | BuildList lInput; | 90 | BuildList lInput; |
90 | BuildList lRequires; | 91 | BuildList lRequires; |
92 | StringList lGroups; | ||
91 | SetVarList lVar; | 93 | SetVarList lVar; |
92 | }; | 94 | }; |
93 | typedef std::pair<BuildList,TargetInfo> TargetTmp; | 95 | typedef std::pair<BuildList,TargetInfo> TargetTmp; |