From ff938b977db21378a1f016f65e7345c50e71ef8f Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 24 Apr 2007 14:09:50 +0000 Subject: 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.) --- build.conf | 1 + src/build.cpp | 23 +++++++++++++++++++++++ src/build.h | 4 ++++ src/build.l | 1 + src/build.y | 7 +++++++ src/buildparser.cpp | 11 +++++++++++ src/buildparser.h | 2 ++ 7 files changed, 49 insertions(+) diff --git a/build.conf b/build.conf index 6da97e2..01ef6b6 100644 --- a/build.conf +++ b/build.conf @@ -10,6 +10,7 @@ set "LDFLAGS" += "-Llibbu++ -lbu++ -ldl" "build": rule "exe", target file, + group "program", requires "libbu++/libbu++.a", set "CXXFLAGS" += "-Ilibbu++/src", input filesIn("src") filter regexp(".*\\.(cpp|y|l)$") 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() } printf("\n"); } + + printf("Groups:\n"); + for( GroupMap::iterator i = mGroup.begin(); i != mGroup.end(); i++ ) + { + printf(" %s: ", (*i).first.c_str() ); + for( TargetList::iterator j = (*i).second.begin(); + j != (*i).second.end(); j++ ) + { + if( j != (*i).second.begin() ) printf(", "); + printf("%s", (*j)->getName().c_str() ); + } + printf("\n"); + } } RuleList Build::findChainRules( Rule *pHead ) @@ -387,3 +400,13 @@ void Build::setMode( Action::eAction nAct ) } } +void Build::addToGroup( const std::string &sGroup, Target *pTarget ) +{ + if( mGroup.find( sGroup ) == mGroup.end() ) + { + mGroup[sGroup] = TargetList(); + } + + mGroup[sGroup].push_back( pTarget ); +} + 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 ContextMap; typedef std::map RuleMap; typedef std::list RuleList; typedef std::map ActionMap; +typedef std::list TargetList; +typedef std::map GroupMap; class Viewer; @@ -43,6 +45,7 @@ public: void addRequires( const std::string &who, const std::string &what ); void addRule( Rule *pRule ); void addAction( Action *pAction ); + void addToGroup( const std::string &sGroup, Target *pTarget ); void set( const std::string &cont, const std::string &var, const std::string &val ); void setAdd( const std::string &cont, const std::string &var, const std::string &val ); @@ -92,6 +95,7 @@ private: Cache cRequires; bool bCacheUpdated; std::string sCacheName; + GroupMap mGroup; //std::map mRule; //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; "filter" return TOK_FILTER; "prefix" return TOK_PREFIX; "aggregate" return TOK_AGGREGATE; +"group" return TOK_GROUP; \n+ { 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 ); %token TOK_PERFORM "perform" %token TOK_PRODUCES "produces" %token TOK_AGGREGATE "aggregate" +%token TOK_GROUP "group" %token ',' ':' '=' '(' ')' @@ -123,6 +124,8 @@ actioncmd: TOK_CHECK list { bld.addCommand( Action::actClean ); } + | TOK_CHECK TOK_GROUP STRING + | TOK_CLEAN TOK_GROUP STRING ; // Target interpretation @@ -158,6 +161,10 @@ targetcmd: TOK_RULE STRING bld.addTargetRequires(); } | TOK_SET targetset + | TOK_GROUP STRING + { + bld.addTargetGroup( $2 ); + } ; 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 ) lTargetTmp.back().second.lVar.push_back( SetVar( sVar, sVal, nHow ) ); } +void BuildParser::addTargetGroup( const char *sGroup ) +{ + lTargetTmp.back().second.lGroups.push_back( sGroup ); +} + // // Function functions // @@ -458,6 +463,12 @@ Build *BuildParser::genBuild() ); bld->addTarget( pTarget ); + + for( StringList::iterator c = (*i).second.lGroups.begin(); + c != (*i).second.lGroups.end(); c++ ) + { + bld->addToGroup( *c, pTarget ); + } } StringList lReqs = buildToStringList( (*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 void addTargetInput(); void addTargetRequires(); void addTargetSet( const char *sVar, const char *sVal, int nHow ); + void addTargetGroup( const char *sGroup ); private: // Target variables TargetFactory &fTarget; @@ -88,6 +89,7 @@ private: // Target variables std::string sType; BuildList lInput; BuildList lRequires; + StringList lGroups; SetVarList lVar; }; typedef std::pair TargetTmp; -- cgit v1.2.3