From 51e21a316be6e052251b3dfc7d671061ebd67cee Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 21 Dec 2009 18:03:28 +0000 Subject: Removed the old trunk contents. About to load up m3 --- src/action.cpp | 53 ---- src/action.h | 66 ----- src/bfilt/c++/bfilt-c++.l | 64 ----- src/build.cpp | 442 ------------------------------ src/build.h | 107 -------- src/build.l | 173 ------------ src/build.y | 278 ------------------- src/buildparser.cpp | 613 ------------------------------------------ src/buildparser.h | 192 ------------- src/cache.cpp | 149 ---------- src/cache.h | 33 --- src/function.cpp | 25 -- src/function.h | 23 -- src/functioncommandtolist.cpp | 68 ----- src/functioncommandtolist.h | 21 -- src/functiondirectoriesin.cpp | 69 ----- src/functiondirectoriesin.h | 21 -- src/functionfactory.cpp | 22 -- src/functionfactory.h | 20 -- src/functionfilesin.cpp | 58 ---- src/functionfilesin.h | 21 -- src/functionregexp.cpp | 86 ------ src/functionregexp.h | 21 -- src/functiontargets.cpp | 35 --- src/functiontargets.h | 21 -- src/functiontostring.cpp | 33 --- src/functiontostring.h | 21 -- src/main.cpp | 172 ------------ src/parser.cpp | 27 -- src/parser.h | 40 --- src/perform.cpp | 26 -- src/perform.h | 55 ---- src/performcommand.cpp | 35 --- src/performcommand.h | 21 -- src/performfactory.cpp | 12 - src/performfactory.h | 20 -- src/regexp.cpp | 78 ------ src/regexp.h | 36 --- src/rule.cpp | 159 ----------- src/rule.h | 86 ------ src/stringproc.cpp | 12 - src/stringproc.h | 33 --- src/stringprocbuild.cpp | 54 ---- src/stringprocbuild.h | 20 -- src/target.cpp | 31 --- src/target.h | 63 ----- src/targetfactory.cpp | 12 - src/targetfactory.h | 20 -- src/targetfile.cpp | 158 ----------- src/targetfile.h | 28 -- src/viewer.cpp | 70 ----- src/viewer.h | 38 --- src/viewercolorpct.cpp | 129 --------- src/viewercolorpct.h | 49 ---- src/viewerfactory.cpp | 20 -- src/viewerfactory.h | 20 -- src/viewermake.cpp | 19 -- src/viewermake.h | 20 -- src/viewerpercent.cpp | 129 --------- src/viewerpercent.h | 39 --- src/viewerplain.cpp | 87 ------ src/viewerplain.h | 39 --- src/viewerplainpct.cpp | 128 --------- src/viewerplainpct.h | 49 ---- 64 files changed, 4769 deletions(-) delete mode 100644 src/action.cpp delete mode 100644 src/action.h delete mode 100644 src/bfilt/c++/bfilt-c++.l delete mode 100644 src/build.cpp delete mode 100644 src/build.h delete mode 100644 src/build.l delete mode 100644 src/build.y delete mode 100644 src/buildparser.cpp delete mode 100644 src/buildparser.h delete mode 100644 src/cache.cpp delete mode 100644 src/cache.h delete mode 100644 src/function.cpp delete mode 100644 src/function.h delete mode 100644 src/functioncommandtolist.cpp delete mode 100644 src/functioncommandtolist.h delete mode 100644 src/functiondirectoriesin.cpp delete mode 100644 src/functiondirectoriesin.h delete mode 100644 src/functionfactory.cpp delete mode 100644 src/functionfactory.h delete mode 100644 src/functionfilesin.cpp delete mode 100644 src/functionfilesin.h delete mode 100644 src/functionregexp.cpp delete mode 100644 src/functionregexp.h delete mode 100644 src/functiontargets.cpp delete mode 100644 src/functiontargets.h delete mode 100644 src/functiontostring.cpp delete mode 100644 src/functiontostring.h delete mode 100644 src/main.cpp delete mode 100644 src/parser.cpp delete mode 100644 src/parser.h delete mode 100644 src/perform.cpp delete mode 100644 src/perform.h delete mode 100644 src/performcommand.cpp delete mode 100644 src/performcommand.h delete mode 100644 src/performfactory.cpp delete mode 100644 src/performfactory.h delete mode 100644 src/regexp.cpp delete mode 100644 src/regexp.h delete mode 100644 src/rule.cpp delete mode 100644 src/rule.h delete mode 100644 src/stringproc.cpp delete mode 100644 src/stringproc.h delete mode 100644 src/stringprocbuild.cpp delete mode 100644 src/stringprocbuild.h delete mode 100644 src/target.cpp delete mode 100644 src/target.h delete mode 100644 src/targetfactory.cpp delete mode 100644 src/targetfactory.h delete mode 100644 src/targetfile.cpp delete mode 100644 src/targetfile.h delete mode 100644 src/viewer.cpp delete mode 100644 src/viewer.h delete mode 100644 src/viewercolorpct.cpp delete mode 100644 src/viewercolorpct.h delete mode 100644 src/viewerfactory.cpp delete mode 100644 src/viewerfactory.h delete mode 100644 src/viewermake.cpp delete mode 100644 src/viewermake.h delete mode 100644 src/viewerpercent.cpp delete mode 100644 src/viewerpercent.h delete mode 100644 src/viewerplain.cpp delete mode 100644 src/viewerplain.h delete mode 100644 src/viewerplainpct.cpp delete mode 100644 src/viewerplainpct.h (limited to 'src') diff --git a/src/action.cpp b/src/action.cpp deleted file mode 100644 index 2588caa..0000000 --- a/src/action.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "action.h" - -Action::Action() -{ -} - -Action::~Action() -{ -} - -void Action::addCommand( eAction act, const std::string &sWhat, bool bIsGroup ) -{ - lCmds.push_back( Cmd( act, sWhat, bIsGroup ) ); -} - -void Action::begin() -{ - i = lCmds.begin(); -} - -bool Action::isEnded() -{ - return i == lCmds.end(); -} - -void Action::next() -{ - i++; -} - -Action::eAction Action::getAct() -{ - return (*i).act; -} - -std::string Action::getWhat() -{ - return (*i).sWhat; -} - -bool Action::isGroup() -{ - return (*i).bIsGroup; -} - -void Action::setMode( eAction nAct ) -{ - for( CmdList::iterator j = lCmds.begin(); j != lCmds.end(); j++ ) - { - (*j).act = nAct; - } -} - diff --git a/src/action.h b/src/action.h deleted file mode 100644 index 929c1c5..0000000 --- a/src/action.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef ACTION_H -#define ACTION_H - -#include - -#include -#include - -class Action -{ -public: - enum eAction - { - actCheck, - actClean - }; -public: - Action(); - virtual ~Action(); - - typedef struct Cmd - { - Cmd( eAction act, const std::string &sWhat, bool bIsGroup ) : - act( act ), sWhat( sWhat ), bIsGroup( bIsGroup ) - {} - eAction act; - std::string sWhat; - bool bIsGroup; - } Cmd; - - void addCommand( eAction act, const std::string &sWhat, bool bIsGroup ); - - void begin(); - bool isEnded(); - void next(); - - int size() - { - return lCmds.size(); - } - - eAction getAct(); - std::string getWhat(); - bool isGroup(); - - void setName( const std::string &sName ) - { - this->sName = sName; - } - - std::string getName() - { - return sName; - } - - void setMode( eAction nAct ); - -private: - typedef std::list CmdList; - CmdList lCmds; - CmdList::iterator i; - std::string sName; - -}; - -#endif diff --git a/src/bfilt/c++/bfilt-c++.l b/src/bfilt/c++/bfilt-c++.l deleted file mode 100644 index 4e71649..0000000 --- a/src/bfilt/c++/bfilt-c++.l +++ /dev/null @@ -1,64 +0,0 @@ -%{ -# include - -int nBC = 0; -%} - -%s hasT -%x inWith -%x inT -%option noyywrap nounput batch - -%% - -"operator<<" { ECHO; } -"operator>>" { ECHO; } -"operator". { ECHO; } - -"<<" { ECHO; } -">>" { ECHO; } -" <<" { ECHO; } -" >>" { ECHO; } -"'<'" { ECHO; } -"'>'" { ECHO; } - -"" { ECHO; } - -\n+ { - BEGIN( INITIAL ); - nBC = false; - ECHO; -} - -" <" { ECHO; } - -"<" { - BEGIN( inT ); - printf("<...>"); - nBC++; -} - -"<" { - nBC++; - -} -[^<>]* { } -">" { - nBC--; - if( nBC == 0 ) - BEGIN( hasT ); -} - -" [with"[^\]]*"]" { } - -%% - -int main() -{ - yyin = stdin; - - yylex(); - - return 0; -} - diff --git a/src/build.cpp b/src/build.cpp deleted file mode 100644 index dd6db1e..0000000 --- a/src/build.cpp +++ /dev/null @@ -1,442 +0,0 @@ -#include "build.h" -#include "function.h" -#include "viewerfactory.h" -#include "bu/archive.h" -#include "bu/file.h" - -#include - -subExceptionDef( BuildException ); - -Build::Build() : - pStrProc( NULL ), - pView( NULL ), - bCacheUpdated( false ) -{ -} - -Build::~Build() -{ - if( sCacheName.size() > 0 && bCacheUpdated ) - { - try - { - Bu::File f( sCacheName.c_str(), - Bu::File::Write|Bu::File::Create|Bu::File::Truncate ); - Bu::Archive ar( f, Bu::Archive::save ); - - ar << cRequires; - } - catch( Bu::ExceptionBase &e ) - { - } - } -} - -void Build::setView( const std::string &sView ) -{ - pView = ViewerFactory::getInstance().instantiate( sView.c_str() ); -} - -void Build::setCache( const std::string &sFileName ) -{ - sCacheName = sFileName; - - try - { - Bu::File f( sCacheName.c_str(), Bu::File::Read ); - Bu::Archive ar( f, Bu::Archive::load ); - - ar >> cRequires; - } - catch( Bu::ExceptionBase &e ) - { - } -} - -void Build::setStringProc( StringProc *pStrProc ) -{ - delete this->pStrProc; - this->pStrProc = pStrProc; -} - -std::string Build::replVars( const std::string &sSrc, const StringList *pCont, VarMap *mExtra ) -{ - if( pStrProc == NULL ) - throw BuildException( - "No valid string processor was registered with the Build object." - ); - - return pStrProc->replVars( sSrc, pCont, mExtra ); -} - -void Build::execAction( const std::string &sWhat ) -{ - if( mAction.find( sWhat ) == mAction.end() ) - throw BuildException( - "No action matches %s, check your build.conf.", - sWhat.c_str() - ); - - Action *pAct = mAction[sWhat]; - - pView->beginAction( sWhat, pAct->size() ); - - for( pAct->begin(); !pAct->isEnded(); pAct->next() ) - { - if( pAct->isGroup() ) - { - if( mGroup.find( pAct->getWhat() ) == mGroup.end() ) - throw BuildException( - "No group matches %s in action %s.", - pAct->getWhat().c_str(), - sWhat.c_str() - ); - TargetList &sl = mGroup[pAct->getWhat()]; - for( TargetList::iterator i = sl.begin(); i != sl.end(); i++ ) - { - Target *pTarget = *i; - if( !pTarget->wasRun() ) - pTarget->run( pAct->getAct(), *this ); - } - } - else - { - if( mTarget.find( pAct->getWhat() ) == mTarget.end() ) - throw BuildException( - "No target matches %s in action %s.", - pAct->getWhat().c_str(), - sWhat.c_str() - ); - Target *pTarget = mTarget[pAct->getWhat()]; - //pView->beginCommand( pAct->getAct(), pAct->getWhat() ); - if( !pTarget->wasRun() ) - pTarget->run( pAct->getAct(), *this ); - //pView->endCommand(); - } - } - - pView->endAction(); - - return; -} - -void Build::addTarget( Target *pTarget ) -{ - TargetMap::iterator i = mTarget.find( pTarget->getName() ); - if( i == mTarget.end() ) - { - mTarget[pTarget->getName()] = pTarget; - } - else - { - throw BuildException("Merging targets isn't working yet."); - } -} - -void Build::addRequires( const std::string &who, const std::string &what ) -{ - mRequires[who].push_back( what ); -} - -void Build::addRule( Rule *pRule ) -{ - mRule[pRule->getName()] = pRule; -} - -Rule *Build::getRule( const std::string &name ) -{ - if( mRule.find( name ) == mRule.end() ) - throw BuildException("No rule named %s found.", name.c_str() ); - - return mRule[name]; -} - -void Build::addAction( Action *pAction ) -{ - mAction[pAction->getName()] = pAction; -} - -void Build::set( const std::string &cont, const std::string &var, const std::string &val ) -{ - if( cont == "" ) - { - mVars[var] = replVars( val, NULL, NULL ); - } - else - { - StringList cl; - cl.push_front( cont ); - mContVars[cont][var] = replVars( val, &cl, NULL ); - } -} - -void Build::setAdd( const std::string &cont, const std::string &var, const std::string &val ) -{ - if( cont == "" ) - { - mVars[var] = getVar( NULL, var, NULL ) + " " + replVars( val, NULL, NULL ); - } - else - { - StringList cl; - cl.push_front( cont ); - mContVars[cont][var] = getVar( &cl, var, NULL ) + " " + replVars( val, &cl, NULL ); - } -} - -void Build::copyContext( const std::string &src, const std::string &dest ) -{ - if( mContVars.find(src) == mContVars.end() ) - return; - - VarMap &d = mContVars[dest]; - VarMap &s = mContVars[src]; - for( VarMap::iterator i = s.begin(); i != s.end(); i++ ) - d[(*i).first] = (*i).second; -} - -std::string Build::getVar( const StringList *cont, const std::string &var, VarMap *mExtra ) -{ - if( mExtra != NULL ) - { - if( mExtra->find(var) == mExtra->end() ) - { - return getVar( cont, var, NULL ); - } - return (*mExtra)[var]; - } - - if( cont == NULL ) - { - if( mVars.find(var) == mVars.end() ) - { - if( getenv( var.c_str() ) == NULL ) - { - mVars[var] = ""; - } - else - { - mVars[var] = getenv( var.c_str() ); - } - } - return mVars[var]; - } - else - { - if( cont->empty() ) - { - return getVar( NULL, var, NULL ); - } - std::string sTop = cont->front(); - if( mContVars[sTop].find(var) == mContVars[sTop].end() ) - { - ((StringList *)cont)->pop_front(); - mContVars[sTop][var] = getVar( cont, var, NULL ); - ((StringList *)cont)->push_front( sTop ); - } - return mContVars[sTop][var]; - } -} - -void Build::debugDump() -{ - printf("Requires:\n"); - for( ReqMap::iterator i = mRequires.begin(); i != mRequires.end(); i++ ) - { - printf(" %s: ", (*i).first.c_str() ); - - for( StringList::iterator j = (*i).second.begin(); - j != (*i).second.end(); j++ ) - { - if( j != (*i).second.begin() ) - printf(", "); - printf("%s", (*j).c_str() ); - } - printf("\n"); - } - - printf("Targets:\n"); - for( TargetMap::iterator i = mTarget.begin(); i != mTarget.end(); i++ ) - { - printf(" %s:\n", (*i).first.c_str() ); - printf(" Rule: %s\n", (*i).second->getRule().c_str() ); - printf(" Input: "); - for( StringList::iterator j = (*i).second->getInput().begin(); - j != (*i).second->getInput().end(); j++ ) - { - if( j != (*i).second->getInput().begin() ) - printf(", "); - printf("%s", (*j).c_str() ); - } - printf("\n"); - } - - printf("Global Variables:\n"); - for( VarMap::iterator i = mVars.begin(); i != mVars.end(); i++ ) - { - printf(" \"%s\" = \"%s\"\n", (*i).first.c_str(), (*i).second.c_str() ); - } - - printf("Context Variables:\n"); - for( ContextMap::iterator i = mContVars.begin(); i != mContVars.end(); i++ ) - { - printf(" %s:\n", (*i).first.c_str() ); - - for( VarMap::iterator j = (*i).second.begin(); - j != (*i).second.end(); j++ ) - { - printf(" \"%s\" = \"%s\"\n", - (*j).first.c_str(), - (*j).second.c_str() - ); - } - } - - printf("Rules:\n"); - for( RuleMap::iterator i = mRule.begin(); i != mRule.end(); i++ ) - { - printf(" %s:\n", (*i).first.c_str() ); - printf(" Matches: func\n"); - printf(" Filters: %d\n", (*i).second->getFilterList().size() ); - printf(" Performs: %d\n", (*i).second->getPerformList().size() ); - printf(" Produces:\n"); - printf(" Requires:\n"); - } - - printf("Actions:\n"); - for( ActionMap::iterator i = mAction.begin(); i != mAction.end(); i++ ) - { - printf(" %s: ", (*i).first.c_str() ); - for( (*i).second->begin(); !(*i).second->isEnded(); (*i).second->next() ) - { - printf("%d:%s ", (*i).second->getAct(), (*i).second->getWhat().c_str() ); - } - 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 ) -{ - RuleList lOut; - FunctionList &lMatches = pHead->getMatchesList(); - - for( RuleMap::iterator i = mRule.begin(); i != mRule.end(); i++ ) - { - if( (*i).second == pHead ) - continue; - - for( FunctionList::iterator j = lMatches.begin(); - j != lMatches.end(); j++ ) - { - StringList lTmp; - (*j)->execute( NULL, (*i).second->getProducesList(), lTmp ); - if( !lTmp.empty() ) - { - lOut.push_back( (*i).second ); - break; - } - } - } - - return lOut; -} - -StringList &Build::getRequires( std::string sName ) -{ - return mRequires[sName]; -} - -bool Build::getCached( const std::string &sID, int nTime, StringList &lOut ) -{ - Cache::Entry *pEnt = cRequires.get( sID ); - if( pEnt == NULL ) - return false; - if( pEnt->tCreated < nTime ) - return false; - - lOut.insert( lOut.end(), pEnt->lData.begin(), pEnt->lData.end() ); - - return true; -} - -void Build::updateCache( const std::string &sID, FunctionList &lFunc, StringList &lOut ) -{ - Cache::Entry *pEnt = new Cache::Entry; - getView()->beginRequiresCheck( false, sID ); - for( FunctionList::iterator f = lFunc.begin(); f != lFunc.end(); f++ ) - { - StringList lTmpIn; - lTmpIn.push_back( sID ); - (*f)->execute( this, lTmpIn, pEnt->lData ); - } - getView()->endRequiresCheck(); - - lOut.insert( lOut.end(), pEnt->lData.begin(), pEnt->lData.end() ); - cRequires.put( sID, pEnt ); - - pEnt->tCreated = time( NULL ); - - bCacheUpdated = true; -} - -void Build::chainTarget( const std::string &sName ) -{ - TargetMap::iterator i = mTarget.find(sName); - if( i == mTarget.end() ) return; - - if( !(*i).second->wasRun() ) - (*i).second->run( Action::actCheck, *this ); -} - -void Build::printInfo() -{ - printf("---- Build Info ----\n"); - printf("Valid actions: "); - for( ActionMap::iterator i = mAction.begin(); i != mAction.end(); i++ ) - { - if( i != mAction.begin() ) printf(", "); - if( (*i).first == "" ) - printf("*default*"); - else - printf("%s", (*i).first.c_str() ); - } - printf("\n\n"); -} - -void Build::setMode( Action::eAction nAct ) -{ - for( ActionMap::iterator i = mAction.begin(); i != mAction.end(); i++ ) - { - (*i).second->setMode( nAct ); - } -} - -void Build::addToGroup( const std::string &sGroup, Target *pTarget ) -{ - if( mGroup.find( sGroup ) == mGroup.end() ) - { - mGroup[sGroup] = TargetList(); - } - - mGroup[sGroup].push_back( pTarget ); -} - -bool Build::hasAction( const std::string &str ) -{ - return mAction.find( str ) != mAction.end(); -} - diff --git a/src/build.h b/src/build.h deleted file mode 100644 index 1ffb547..0000000 --- a/src/build.h +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef BUILD_H -#define BUILD_H - -#include - -#include -#include - -#include "bu/exceptionbase.h" -#include "rule.h" -#include "target.h" -#include "action.h" -#include "stringproc.h" -#include "cache.h" - -subExceptionDecl( BuildException ); -typedef std::map VarMap; -typedef std::map TargetMap; -typedef std::list StringList; -typedef std::map ReqMap; -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; - -class Build -{ -public: - Build(); - virtual ~Build(); - - void execAction( const std::string &sWhat ); - - /** - * Adds a target to the build. If the target already exists, this will - * attempt to merge them as best it can. If there are any conflicts, it - * will throw an exception. - *@param pTarget A pointer to a Target object that Build takes ownership of. - */ - void addTarget( Target *pTarget ); - void addRequires( const std::string &who, const std::string &what ); - void addRule( Rule *pRule ); - void addAction( Action *pAction ); - bool hasAction( const std::string &str ); - 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 ); - void copyContext( const std::string &src, const std::string &dest ); - std::string getVar( const StringList *cont, const std::string &var, VarMap *mExtra ); - - Rule *getRule( const std::string &name ); - - void debugDump(); - - void setStringProc( StringProc *pStrProc ); - std::string replVars( const std::string &sSrc, const StringList *pCont, VarMap *mExtra ); - RuleList findChainRules( Rule *pHead ); - StringList &getRequires( std::string sName ); - - Viewer *getView() - { - return pView; - } - - TargetMap &getTargetMap() - { - return mTarget; - } - - void setView( const std::string &sView ); - - void setCache( const std::string &sFileName ); - bool getCached( const std::string &sID, int nTime, StringList &lOut ); - void updateCache( const std::string &sID, FunctionList &lFunc, StringList &lOut ); - - void chainTarget( const std::string &sName ); - - void printInfo(); - - void setMode( Action::eAction nAct ); - -private: - TargetMap mTarget; - ReqMap mRequires; - VarMap mVars; - ContextMap mContVars; - RuleMap mRule; - ActionMap mAction; - StringProc *pStrProc; - Viewer *pView; - Cache cRequires; - bool bCacheUpdated; - std::string sCacheName; - GroupMap mGroup; - - //std::map mRule; - //Action *pActDefault; - //std::map mAction; - -}; - -#endif diff --git a/src/build.l b/src/build.l deleted file mode 100644 index 9065a49..0000000 --- a/src/build.l +++ /dev/null @@ -1,173 +0,0 @@ -%{ -# include -# include -# include "buildparser.h" -# include "build.tab.h" - -char *stringdup( const char *sin ) -{ - char *n = new char[strlen(sin)+1]; - strcpy( n, sin ); - return n; -} - -std::string strbuf; -%} - -%x strsq -%x strdq -%x cmdstr -%x comment -%option noyywrap nounput batch debug - -%{ -# define YY_USER_ACTION yylloc->last_column += yyleng; -%} -%% - -[,:=[\]()] return yytext[0]; -"+=" return TOK_ADDSET; - -"default" return TOK_DEFAULT; -"action" return TOK_ACTION; -"rule" return TOK_RULE; -"requires" return TOK_REQUIRES; -"set" return TOK_SET; -"matches" return TOK_MATCHES; -"perform" return TOK_PERFORM; -"produces" return TOK_PRODUCES; -"check" return TOK_CHECK; -"clean" return TOK_CLEAN; -"target" return TOK_TARGET; -"input" return TOK_INPUT; -"filter" return TOK_FILTER; -"prefix" return TOK_PREFIX; -"aggregate" return TOK_AGGREGATE; -"group" return TOK_GROUP; - -\n+ { - yylloc->last_line += yyleng; - yylloc->first_line = yylloc->last_line; - yylloc->first_column = yylloc->last_column = 0; -} - -[ \t\r]* { - yylloc->first_line = yylloc->last_line; - yylloc->first_column = yylloc->last_column+1; -} - -"#".* /* single line comment */ - -[a-zA-Z][a-zA-Z0-9]* { - { - if( bld.isTarget( yytext ) ) - { - yylval->strval = stringdup( yytext ); - return TARGETTYPE; - } - else if( bld.isPerform( yytext ) ) - { - yylval->strval = stringdup( yytext ); - return PERFORM; - } - else if( bld.isFunction( yytext ) ) - { - yylval->strval = stringdup( yytext ); - return FUNCTION; - } - bld.error( yylloc, "Invalid token" ); - } -} - -\" { - BEGIN( strdq ); - strbuf = ""; -} -\' { - BEGIN( strsq ); - strbuf = ""; -} -\` { - BEGIN( cmdstr ); - strbuf = ""; -} - -[^\\\n\"]+ { - strbuf += yytext; -} - -[^\\\n\']+ { - strbuf += yytext; -} - -[^\\\n\`]+ { - strbuf += yytext; -} - -\\n strbuf += "\n"; -\\t strbuf += "\t"; -\\r strbuf += "\r"; -\\b strbuf += "\b"; -\\f strbuf += "\f"; -\\\\ strbuf += "\\"; -\\\" strbuf += "\""; -\\\' strbuf += "\'"; -\\\` strbuf += "`"; -\\. bld.error( yylloc, "Invalid escape sequence."); - -\" { - BEGIN( INITIAL ); - yylval->strval = stringdup( strbuf.c_str() ); - return STRING; -} - -\' { - BEGIN( INITIAL ); - yylval->strval = stringdup( strbuf.c_str() ); - return STRING; -} - -\` { - BEGIN( INITIAL ); - FILE *fpg = popen( strbuf.c_str(), "r" ); - strbuf = ""; - for(;;) - { - char buf[1024]; - int nRead = fread( buf, 1, 1024, fpg ); - if( nRead == 0 ) break; - for( int j = 0; j < nRead; j++ ) - { - if( buf[j] == '\n' || buf[j] == '\r' ) - buf[j] = ' '; - } - strbuf.append( buf, nRead ); - if( nRead < 1024 ) break; - } - yylval->strval = stringdup( strbuf.c_str() ); - pclose( fpg ); - return STRING; -} - -. { - char buf[] = {"Character x is out of place"}; - buf[10] = yytext[0]; - bld.error( yylloc, buf ); -} - -%% - -void BuildParser::scanBegin() -{ - yy_flex_debug = false; - if( !(yyin = fopen( file.c_str(), "r" )) ) - { - error( std::string("cannot open file: ") + file ); - } -} - -void BuildParser::scanEnd() -{ - fclose( yyin ); -} - diff --git a/src/build.y b/src/build.y deleted file mode 100644 index 55940e8..0000000 --- a/src/build.y +++ /dev/null @@ -1,278 +0,0 @@ -%defines -%{ -# include -# include "buildparser.h" -# include "build.tab.h" -# include "action.h" -void yyerror( YYLTYPE *locp, BuildParser &bld, char const *msg ); -%} - -%parse-param { BuildParser &bld } -%lex-param { BuildParser &bld } -%pure-parser - -%locations - -%debug -%error-verbose -%union { - char *strval; -} - -%token STRING "string literal" -%token TARGETTYPE "target type" -%token FUNCTION "function name" -%token PERFORM "perform name" - -%token TOK_ADDSET "+=" -%token TOK_DEFAULT "default" -%token TOK_ACTION "action" -%token TOK_CHECK "check" -%token TOK_CLEAN "clean" -%token TOK_RULE "rule" -%token TOK_TARGET "target" -%token TOK_SET "set" -%token TOK_INPUT "input" -%token TOK_FILTER "filter" -%token TOK_PREFIX "prefix" -%token TOK_REQUIRES "requires" -%token TOK_MATCHES "matches" -%token TOK_PERFORM "perform" -%token TOK_PRODUCES "produces" -%token TOK_AGGREGATE "aggregate" -%token TOK_GROUP "group" - -%token ',' ':' '=' '(' ')' - -%destructor { delete[] $$; } STRING FUNCTION - -%% - -// General input format -input: - | input rule - | input action - | input target - | input set - ; - -// Rule interpretation -rule: TOK_RULE STRING ':' - { - bld.addRule( $2 ); - } - rulecmds - ; - -rulecmds: rulecmd - | rulecmds ',' rulecmd - ; - -rulecmd: TOK_MATCHES func - { - bld.addRuleMatches(); - } - | TOK_PRODUCES list - { - bld.addRuleProduces(); - } - | TOK_REQUIRES list - { - bld.addRuleRequires(); - } - | TOK_INPUT TOK_FILTER func - { - bld.addRuleInputFilter(); - } - | TOK_PERFORM perf - { - bld.addRulePerform(); - } - | TOK_AGGREGATE func - { - bld.setRuleAggregate(); - } - ; - -// Action interpretation -action: TOK_DEFAULT TOK_ACTION ':' - { - bld.addAction(); - } - actioncmds - | STRING TOK_ACTION ':' - { - if( $1[0] == '\0' ) - bld.error( - &yylloc, - "You cannot use an empty string as the name of an action." - ); - bld.addAction( $1 ); - } - actioncmds - ; - -actioncmds: actioncmd - | actioncmds ',' actioncmd - ; - -actioncmd: TOK_CHECK list - { - bld.addCommand( Action::actCheck ); - } - | TOK_CLEAN list - { - bld.addCommand( Action::actClean ); - } - | TOK_CHECK TOK_GROUP STRING - { - bld.addGrpCommand( $3, Action::actCheck ); - } - | TOK_CLEAN TOK_GROUP STRING - { - bld.addGrpCommand( $3, Action::actClean ); - } - ; - -// Target interpretation -target: list ':' - { - bld.newTarget(); - } - targetcmds - ; - -targetcmds: targetcmd - | targetcmds ',' targetcmd - ; - -targetcmd: TOK_RULE STRING - { - bld.setTargetRule( $2 ); - } - | TOK_TARGET TOK_PREFIX STRING - { - bld.setTargetPrefix( $3 ); - } - | TOK_TARGET TARGETTYPE - { - bld.setTargetType( $2 ); - } - | TOK_INPUT list - { - bld.addTargetInput(); - } - | TOK_REQUIRES list - { - bld.addTargetRequires(); - } - | TOK_SET targetset - | TOK_GROUP STRING - { - bld.addTargetGroup( $2 ); - } - ; - -targetset: STRING '=' STRING - { - bld.addTargetSet( $1, $3, setSet ); - } - | STRING TOK_ADDSET STRING - { - bld.addTargetSet( $1, $3, setAdd ); - } - ; - -// global set -set: TOK_SET setwhat - ; - -setwhat: STRING '=' STRING - { - bld.addGlobalSet( $1, $3, setSet ); - } - | STRING TOK_ADDSET STRING - { - bld.addGlobalSet( $1, $3, setAdd ); - } - ; - -// list goo -list: singlelistitem listfilter - | '[' - { - bld.newList(); - } - listitems ']' listfilter - ; - -listfilter: - | TOK_FILTER func - { - bld.filterList(); - } - ; - -listitems: listitem - | listitems ',' listitem - ; - -listitem: STRING - { - bld.addListString( $1 ); - } - | func - { - bld.addListFunc(); - } - ; - -singlelistitem: STRING - { - bld.newList(); - bld.addListString( $1 ); - } - | func - { - bld.newList(); - bld.addListFunc(); - } - ; - -// Function -func: FUNCTION - { - bld.newFunctionCall( $1 ); - } - '(' funcparams ')' - ; - -funcparams: - | STRING { bld.addFunctionParam( $1 ); } - | funcparams ',' STRING { bld.addFunctionParam( $3 ); } - ; - -// Perform -perf: PERFORM - { - bld.newPerform( $1 ); - } - '(' perfparams ')' - ; - -perfparams: - | STRING - { - bld.addPerformParam( $1 ); - } - | perfparams ',' STRING - { - bld.addPerformParam( $3 ); - } - ; -%% - -void yyerror( YYLTYPE *locp, BuildParser &bld, char const *msg ) -{ - bld.error( locp, msg ); -} diff --git a/src/buildparser.cpp b/src/buildparser.cpp deleted file mode 100644 index 8f40097..0000000 --- a/src/buildparser.cpp +++ /dev/null @@ -1,613 +0,0 @@ -#include "buildparser.h" -#include "functionfactory.h" -#include "performfactory.h" -#include "targetfactory.h" -#include "action.h" -#include "build.h" -#include "rule.h" -#include "stringprocbuild.h" - -BuildParser::BuildParser() : - fFunction( FunctionFactory::getInstance() ), - fPerform( PerformFactory::getInstance() ), - fTarget( TargetFactory::getInstance() ) -{ -} - -BuildParser::~BuildParser() -{ -} - -void yyparse( BuildParser &bld ); -extern int yydebug; - -Build *BuildParser::load( const std::string &sFile ) -{ - file = sFile; - scanBegin(); - //yydebug = 1; - yyparse( *this ); - scanEnd(); - - return genBuild(); -} - -// -// Target functions -// -bool BuildParser::isTarget( const char *sType ) -{ - return fTarget.hasPlugin( sType ); -} - -void BuildParser::newTarget() -{ - lTargetTmp.push_back( TargetTmp(lTmp, TargetInfo()) ); -} - -void BuildParser::setTargetRule( const char *sRule ) -{ - lTargetTmp.back().second.sRule = sRule; -} - -void BuildParser::setTargetPrefix( const char *sPrefix ) -{ - lTargetTmp.back().second.sPrefix = sPrefix; -} - -void BuildParser::setTargetType( const char *sType ) -{ - lTargetTmp.back().second.sType = sType; -} - -void BuildParser::addTargetInput() -{ - lTargetTmp.back().second.lInput.first.insert( - lTargetTmp.back().second.lInput.first.end(), - lTmp.first.begin(), lTmp.first.end() - ); - lTargetTmp.back().second.lInput.second = lTmp.second; -} - -void BuildParser::addTargetRequires() -{ - lTargetTmp.back().second.lRequires.first.insert( - lTargetTmp.back().second.lRequires.first.end(), - lTmp.first.begin(), lTmp.first.end() - ); - lTargetTmp.back().second.lRequires.second = lTmp.second; -} - -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 -// -bool BuildParser::isFunction( const char *sFunc ) -{ - return fFunction.hasPlugin( sFunc ); -} - -void BuildParser::newFunctionCall( const char *sName ) -{ - pTmpFunc = fFunction.instantiate( sName ); -} - -void BuildParser::addFunctionParam( const char *sParam ) -{ - pTmpFunc->addParam( sParam ); -} - -// -// List functions -// -void BuildParser::newList() -{ - lTmp.first.clear(); - lTmp.second = NULL; -} - -void BuildParser::addListString( const char *str ) -{ - lTmp.first.push_back( BuildListItem(str, NULL) ); -} - -void BuildParser::addListFunc() -{ - lTmp.first.push_back( BuildListItem("", pTmpFunc ) ); -} - -void BuildParser::filterList() -{ - lTmp.second = pTmpFunc; - //StringList lTmp2; - //StringList lIn = buildToStringList( lTmp, StringList() ); - //pTmpFunc->execute( NULL, lIn, lTmp2 ); - //lTmp.clear(); - //for( StringList::iterator i = lTmp2.begin(); i != lTmp2.end(); i++ ) - //{ - // lTmp.push_back( BuildListItem( *i, NULL ) ); - //} -} - -void BuildParser::buildListFilter( BuildList &lSrc ) -{ - if( lSrc.second == NULL ) - return; - - StringList lTmp2; - StringList lIn = buildToStringList( lSrc, StringList() ); - pTmpFunc->execute( NULL, lIn, lTmp2 ); - lSrc.first.clear(); - delete lSrc.second; - for( StringList::iterator i = lTmp2.begin(); i != lTmp2.end(); i++ ) - { - lSrc.first.push_back( BuildListItem( *i, NULL ) ); - } -} - -StringList BuildParser::buildToStringList( const BuildList &lSrc, const StringList &lIn, Build *pPass ) -{ - StringList lOut; - - for( BuildListCore::const_iterator i = lSrc.first.begin(); - i != lSrc.first.end(); i++ ) - { - if( (*i).second ) - { - (*i).second->execute( pPass, lIn, lOut ); - } - else - { - lOut.push_back( (*i).first ); - } - } - - if( lSrc.second ) - { - StringList lTmp; - lSrc.second->execute( pPass, lOut, lTmp ); - lOut.swap( lTmp ); - } - - return lOut; -} - -StringList BuildParser::buildToStringListDup( const BuildList &lSrc, const StringList &lIn, Build &bld, const std::string &sCont, VarMap *mExtra, Build *pPass ) -{ - StringList lOut; - - for( BuildListCore::const_iterator i = lSrc.first.begin(); - i != lSrc.first.end(); i++ ) - { - if( (*i).second ) - { - StringList l; - l.push_back( sCont ); - Function *pTmp = (*i).second->duplicate( bld, &l, mExtra ); - pTmp->execute( pPass, lIn, lOut ); - delete pTmp; - } - else - { - StringList l; - l.push_back( sCont ); - lOut.push_back( bld.replVars( (*i).first, &l, mExtra ) ); - } - } - - if( lSrc.second ) - { - StringList lTmp; - lSrc.second->execute( pPass, lOut, lTmp ); - lOut.swap( lTmp ); - } - - return lOut; -} - -// -// Rule functions -// -void BuildParser::addRule( const char *sName ) -{ - lRuleTmp.push_back( RuleInfo() ); - lRuleTmp.back().sName = sName; - lRuleTmp.back().pAggregate = NULL; -} - -void BuildParser::addRuleMatches() -{ - lRuleTmp.back().pMatches = pTmpFunc; -} - -void BuildParser::addRuleProduces() -{ - lRuleTmp.back().lProduces.first.insert( - lRuleTmp.back().lProduces.first.end(), - lTmp.first.begin(), lTmp.first.end() - ); -} - -void BuildParser::addRuleRequires() -{ - lRuleTmp.back().lRequires.first.insert( - lRuleTmp.back().lRequires.first.end(), - lTmp.first.begin(), lTmp.first.end() - ); -} - -void BuildParser::addRuleInputFilter() -{ - lRuleTmp.back().lFilter.push_back( pTmpFunc ); -} - -void BuildParser::addRulePerform() -{ - lRuleTmp.back().lPerform.push_back( pTmpPerform ); -} - -void BuildParser::setRuleAggregate() -{ - lRuleTmp.back().pAggregate = pTmpFunc; -} - -// -// Perform functions -// -bool BuildParser::isPerform( const char *sPerf ) -{ - return fPerform.hasPlugin( sPerf ); -} - -void BuildParser::newPerform( const char *sName ) -{ - pTmpPerform = fPerform.instantiate( sName ); -} - -void BuildParser::addPerformParam( const char *sParam ) -{ - pTmpPerform->addParam( sParam ); -} - -// -// Functions for dealing with actions -// -void BuildParser::addAction() -{ - lActions.push_back( ActionTmp("", ActionTmpCmdList() ) ); -} - -void BuildParser::addAction( const char *sName ) -{ - lActions.push_back( ActionTmp(sName, ActionTmpCmdList()) ); -} - -void BuildParser::addCommand( int nType ) -{ - lActions.back().second.push_back( ActionTmpCmd( nType, lTmp ) ); -} - -void BuildParser::addGrpCommand( const char *sGroup, int nType ) -{ - lActions.back().second.push_back( ActionTmpCmd( nType, sGroup ) ); -} - -// -// Global variable functions -// -void BuildParser::addGlobalSet( const char *sVar, const char *sValue, int nHow ) -{ - lGlobalVars.push_back( SetVar( sVar, sValue, nHow ) ); -} - -// -// Debug -// -void BuildParser::debugDump() -{ - printf("Actions:\n"); - for( ActionTmpList::iterator i = lActions.begin(); - i != lActions.end(); i++ ) - { - if( (*i).first == "" ) - { - printf(" default:\n"); - } - else - { - printf(" \"%s\":\n", (*i).first.c_str() ); - } - for( ActionTmpCmdList::iterator j = (*i).second.begin(); - j != (*i).second.end(); j++ ) - { - printf(" %d ", (*j).nAct ); - if( (*j).bGroup ) - { - printf("!%s", (*j).sGroup.c_str() ); - } - else - { - printBuildList( (*j).lCmds ); - } - printf("\n"); - } - } - - printf("\nTargets:\n"); - for( TargetTmpList::iterator i = lTargetTmp.begin(); - i != lTargetTmp.end(); i++ ) - { - printf(" "); - printBuildList( (*i).first ); - printf(":\n"); - - printf(" Rule: %s\n", (*i).second.sRule.c_str() ); - printf(" Prefix: %s\n", (*i).second.sPrefix.c_str() ); - printf(" Type: %s\n", (*i).second.sType.c_str() ); - printf(" Input: "); - printBuildList( (*i).second.lInput ); - printf("\n Requires: "); - printBuildList( (*i).second.lRequires ); - printf("\n Vars:\n"); - - for( SetVarList::iterator j = (*i).second.lVar.begin(); - j != (*i).second.lVar.end(); j++ ) - { - const char *op; - switch( (*j).third ) - { - case setSet: op = "="; break; - case setAdd: op = "+="; break; - } - printf(" %s %s %s\n", (*j).first.c_str(), op, (*j).second.c_str() ); - } - } - - printf("\nGlobals:\n"); - for( SetVarList::iterator j = lGlobalVars.begin(); - j != lGlobalVars.end(); j++ ) - { - const char *op; - switch( (*j).third ) - { - case setSet: op = "="; break; - case setAdd: op = "+="; break; - } - printf(" %s %s %s\n", (*j).first.c_str(), op, (*j).second.c_str() ); - } - - printf("\nRules:\n"); - for( RuleTmpList::iterator i = lRuleTmp.begin(); - i != lRuleTmp.end(); i++ ) - { - printf(" %s:\n", (*i).sName.c_str() ); - printf(" Matches: func()\n"); - printf(" Produces: "); - printBuildList( (*i).lProduces ); - printf("\n Requires: "); - printBuildList( (*i).lRequires ); - printf("\n Filters: %d\n", (*i).lFilter.size() ); - printf(" Performs: %d\n", (*i).lPerform.size() ); - } -} - -void BuildParser::printBuildList( const BuildList &lst ) -{ - printf("["); - for( BuildListCore::const_iterator k = lst.first.begin(); - k != lst.first.end(); k++ ) - { - if( k != lst.first.begin() ) - { - printf(", "); - } - if( (*k).second ) - { - printf("func()"); - } - else - { - printf("\"%s\"", (*k).first.c_str() ); - } - } - printf("]"); -} - -// -// Actually make a build object -// -Build *BuildParser::genBuild() -{ - Build *bld = new Build; - bld->setStringProc( new StringProcBuild( bld ) ); - - for( SetVarList::iterator i = lGlobalVars.begin(); - i != lGlobalVars.end(); i++ ) - { - switch( (*i).third ) - { - case setSet: - bld->set( "", (*i).first, (*i).second ); - break; - - case setAdd: - bld->setAdd( "", (*i).first, (*i).second ); - break; - } - } - - for( TargetTmpList::iterator i = lTargetTmp.begin(); - i != lTargetTmp.end(); i++ ) - { - StringList lTargetNames = buildToStringList( - (*i).first, StringList(), bld - ); - for( StringList::iterator j = lTargetNames.begin(); - j != lTargetNames.end(); j++ ) - { - if( (*i).second.sType != "" ) - { - Target *pTarget = fTarget.instantiate( - (*i).second.sType.c_str() - ); - pTarget->setName( *j ); - pTarget->setRule( (*i).second.sRule ); - - VarMap mExtra; - mExtra["target"] = (*j); - - StringList lInputs = buildToStringListDup( - (*i).second.lInput, StringList(), - *bld, *j, &mExtra /*, bld <-- should this be here? */ - ); - pTarget->getInput().insert( - pTarget->getInput().end(), - lInputs.begin(), lInputs.end() - ); - - 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() - ); - for( StringList::iterator k = lReqs.begin(); - k != lReqs.end(); k++ ) - { - bld->addRequires( (*j), (*k) ); - } - for( SetVarList::iterator k = (*i).second.lVar.begin(); - k != (*i).second.lVar.end(); k++ ) - { - switch( (*k).third ) - { - case setSet: - bld->set( *j, (*k).first, (*k).second ); - break; - - case setAdd: - bld->setAdd( *j, (*k).first, (*k).second ); - break; - } - } - } - } - - for( RuleTmpList::iterator i = lRuleTmp.begin(); i != lRuleTmp.end(); i++ ) - { - Rule *pRule = new Rule; - pRule->setName( (*i).sName ); - pRule->getMatchesList().push_back( (*i).pMatches ); - - for( FunctionList::iterator j = (*i).lFilter.begin(); - j != (*i).lFilter.end(); j++ ) - { - pRule->getFilterList().push_back( *j ); - } - - for( PerformList::iterator j = (*i).lPerform.begin(); - j != (*i).lPerform.end(); j++ ) - { - pRule->getPerformList().push_back( *j ); - } - - for( BuildListCore::iterator j = (*i).lProduces.first.begin(); - j != (*i).lProduces.first.end(); j++ ) - { - if( (*j).second ) - { - throw BuildException( - "You cannot have functions in produces lists (rule %s).", - (*i).sName.c_str() ); - } - pRule->getProducesList().push_back( (*j).first ); - } - - if( (*i).pAggregate ) - { - pRule->setAggregate( (*i).pAggregate ); - } - - for( BuildListCore::iterator j = (*i).lRequires.first.begin(); - j != (*i).lRequires.first.end(); j++ ) - { - if( (*j).second ) - { - pRule->getReqFuncList().push_back( (*j).second ); - } - else - { - pRule->getReqStrList().push_back( (*j).first ); - } - } - - bld->addRule( pRule ); - } - - for( ActionTmpList::iterator i = lActions.begin(); - i != lActions.end(); i++ ) - { - Action *pAct = new Action; - pAct->setName( (*i).first ); - - for( ActionTmpCmdList::iterator j = (*i).second.begin(); - j != (*i).second.end(); j++ ) - { - if( (*j).bGroup ) - { - pAct->addCommand( - (Action::eAction)((*j).nAct), (*j).sGroup, true - ); - } - else - { - StringList lWhat = buildToStringList( - (*j).lCmds, StringList(), bld - ); - - for( StringList::iterator k = lWhat.begin(); - k != lWhat.end(); k++ ) - { - pAct->addCommand( (Action::eAction)((*j).nAct), *k, false ); - } - } - } - - bld->addAction( pAct ); - } - - // Now create an auto check-action for each group where there isn't already - // an action. - for( TargetTmpList::iterator i = lTargetTmp.begin(); - i != lTargetTmp.end(); i++ ) - { - for( StringList::iterator j = (*i).second.lGroups.begin(); - j != (*i).second.lGroups.end(); j++ ) - { - if( !bld->hasAction( (*j) ) ) - { - Action *pAct = new Action; - pAct->setName( *j ); - pAct->addCommand( Action::actCheck, *j, true ); - bld->addAction( pAct ); - } - } - } - - return bld; -} - diff --git a/src/buildparser.h b/src/buildparser.h deleted file mode 100644 index 516760c..0000000 --- a/src/buildparser.h +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef BUILDER_H -#define BUILDER_H - -#include -#include -#include -#include -#include -#include "build.tab.h" -#include "parser.h" - -class Build; -class BuildParser; -class Function; -class FunctionFactory; -class Perform; -class PerformFactory; -class Target; -class TargetFactory; - -#define YY_DECL int yylex( YYSTYPE *yylval_param, YYLTYPE *yylloc_param, BuildParser &bld ) -YY_DECL; - -typedef std::list StringList; -typedef std::list FunctionList; -typedef std::list PerformList; -typedef std::map VarMap; - -template -class Triplet -{ -public: - Triplet( const tx &x, const ty &y, const tz &z ) : - first( x ), second( y ), third( z ) - {} - - Triplet( const Triplet &src ) : - first( src.first ), second( src.second ), third( src.third ) - {} - - tx first; - ty second; - tz third; -}; - -enum eSetHow -{ - setSet, - setAdd -}; - -class BuildParser : public Parser -{ - typedef std::pair BuildListItem; - typedef std::list BuildListCore; - typedef std::pair BuildList; - typedef Triplet SetVar; - typedef std::list SetVarList; -public: - BuildParser(); - virtual ~BuildParser(); - - Build *load( const std::string &sFile ); - -private: - void scanBegin(); - void scanEnd(); - - Build *genBuild(); - -public: // Target functions - bool isTarget( const char *sType ); - void newTarget(); - void setTargetRule( const char *sRule ); - void setTargetPrefix( const char *sPrefix ); - void setTargetType( const char *sType ); - void addTargetInput(); - void addTargetRequires(); - void addTargetSet( const char *sVar, const char *sVal, int nHow ); - void addTargetGroup( const char *sGroup ); - -private: // Target variables - TargetFactory &fTarget; - class TargetInfo - { - public: - std::string sRule; - std::string sPrefix; - std::string sType; - BuildList lInput; - BuildList lRequires; - StringList lGroups; - SetVarList lVar; - }; - typedef std::pair TargetTmp; - typedef std::list TargetTmpList; - TargetTmpList lTargetTmp; - -public: // Function functions - bool isFunction( const char *sFunc ); - void newFunctionCall( const char *sName ); - void addFunctionParam( const char *sParam ); - -private: // Function variables - Function *pTmpFunc; - FunctionFactory &fFunction; - -public: // Perform functions - bool isPerform( const char *sPerf ); - void newPerform( const char *sName ); - void addPerformParam( const char *sParam ); - -private: // Perform variables - Perform *pTmpPerform; - PerformFactory &fPerform; - -public: // List functions - void newList(); - void addListString( const char *str ); - void addListFunc(); - void filterList(); - - void buildListFilter( BuildList &lSrc ); - StringList buildToStringList( const BuildList &lSrc, const StringList &lIn, Build *pPass=NULL ); - StringList buildToStringListDup( const BuildList &lSrc, const StringList &lIn, Build &bld, const std::string &sCont, VarMap *mExtra, Build *pPass=NULL ); - -private: // List variables - BuildList lTmp; - -public: // Rules functions - void addRule( const char *sName ); - void addRuleMatches(); - void addRuleProduces(); - void addRuleRequires(); - void addRuleInputFilter(); - void addRulePerform(); - void setRuleAggregate(); - -private: // Rule variables - class RuleInfo - { - public: - std::string sName; - Function *pMatches; - BuildList lProduces; - BuildList lRequires; - FunctionList lFilter; - PerformList lPerform; - Function *pAggregate; - }; - - typedef std::list RuleTmpList; - RuleTmpList lRuleTmp; - -public: // Action functions - void addAction(); - void addAction( const char *sName ); - void addCommand( int nType ); - void addGrpCommand( const char *sGroup, int nType ); - -private: // Action variables - typedef struct ActionTmpCmd - { - ActionTmpCmd( int nAct, BuildList &l ) : - nAct( nAct ), bGroup( false ), lCmds( l ) { }; - ActionTmpCmd( int nAct, const char *s ) : - nAct( nAct ), bGroup( true ), sGroup( s ) { }; - int nAct; - bool bGroup; - BuildList lCmds; - std::string sGroup; - } ActionTmpCmd; - //typedef std::pair ActionTmpCmd; - //typedef std::pair ActionTmpGrpCmd - typedef std::list ActionTmpCmdList; - //typedef std::list ActionTmpGrpCmdList; - typedef std::pair ActionTmp; - typedef std::list ActionTmpList; - ActionTmpList lActions; - -public: // Global variable functions - void addGlobalSet( const char *sVar, const char *sValue, int nHow ); - -private: // Global variable variables - SetVarList lGlobalVars; - -public: // Debug - void debugDump(); - void printBuildList( const BuildList &lst ); -}; - -#endif diff --git a/src/cache.cpp b/src/cache.cpp deleted file mode 100644 index d2bf537..0000000 --- a/src/cache.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include "cache.h" -#include "bu/fstring.h" -#include "bu/archive.h" - -Cache::Cache() -{ -} - -Cache::~Cache() -{ - for( std::map::iterator i = mCache.begin(); - i != mCache.end(); i++ ) - { - delete (*i).second; - } -} - -void Cache::archive( class Bu::ArchiveBase &ar ) -{ - if( ar.isLoading() ) - { - uint32_t sCache, sData, sIndex; - - ar >> sIndex; - Bu::FString *Index = new Bu::FString[sIndex]; - for( uint32_t i = 0; i < sIndex; i++ ) - { - ar >> Index[i]; - } - - ar >> sCache; - uint32_t nTmp; - for( uint32_t i = 0; i < sCache; i++ ) - { - Entry *e = new Entry; - ar >> e->tCreated; - ar >> sData; - std::list &lData = e->lData; - for( uint32_t j = 0; j < sData; j++ ) - { - ar >> nTmp; - lData.push_back( Index[nTmp].getStr() ); - } - ar >> nTmp; - mCache[Index[nTmp].getStr()] = e; - } - /* - uint32_t sCache, sData; - ar >> sCache; - std::string sTmp; - - for( uint32_t i = 0; i < sCache; i++ ) - { - Entry *e = new Entry; - ar >> e->tCreated; - ar >> sData; - std::list &lData = e->lData; - for( uint32_t j = 0; j < sData; j++ ) - { - ar >> sTmp; - lData.push_back( sTmp ); - } - ar >> sTmp; - mCache[sTmp] = e; - } - */ - } - else - { - std::map mIndex; - for( std::map::iterator i = mCache.begin(); - i != mCache.end(); i++ ) - { - mIndex[(*i).first] = 0; - std::list &lData = (*i).second->lData; - for( std::list::iterator j = lData.begin(); - j != lData.end(); j++ ) - { - mIndex[(*j)] = 0; - } - } - - ar << (uint32_t)mIndex.size(); - uint32_t cnt = 0; - for( std::map::iterator i = mIndex.begin(); - i != mIndex.end(); i++ ) - { - (*i).second = cnt; - cnt++; - Bu::FString s( ((*i).first).c_str(), ((*i).first).size() ); - ar << s; - } - - ar << (uint32_t)mCache.size(); - for( std::map::iterator i = mCache.begin(); - i != mCache.end(); i++ ) - { - ar << (*i).second->tCreated; - std::list &lData = (*i).second->lData; - ar << (uint32_t)lData.size(); - for( std::list::iterator j = lData.begin(); - j != lData.end(); j++ ) - { - ar << mIndex[(*j)]; - } - - ar << mIndex[(*i).first]; - } - - - /* - ar << mCache.size(); - for( std::map::iterator i = mCache.begin(); - i != mCache.end(); i++ ) - { - ar << (*i).second->tCreated; - std::list &lData = (*i).second->lData; - ar << lData.size(); - for( std::list::iterator j = lData.begin(); - j != lData.end(); j++ ) - { - ar << (*j); - } - - std::string str = (*i).first; - ar << str; - } - */ - } -} - -Cache::Entry *Cache::get( const std::string &id ) -{ - std::map::iterator i = mCache.find( id ); - if( i != mCache.end() ) - return (*i).second; - - return NULL; -} - -void Cache::put( const std::string &id, Entry *data ) -{ - std::map::iterator i = mCache.find( id ); - if( i != mCache.end() ) - delete (*i).second; - - mCache[id] = data; -} - diff --git a/src/cache.h b/src/cache.h deleted file mode 100644 index 50264de..0000000 --- a/src/cache.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef CACHE_H -#define CACHE_H - -#include -#include -#include "bu/archival.h" -#include -#include -#include - -class Cache : public Bu::Archival -{ -public: - Cache(); - virtual ~Cache(); - - virtual void archive( class Bu::ArchiveBase &ar ); - - class Entry - { - public: - uint32_t tCreated; - std::list lData; - }; - - Entry *get( const std::string &id ); - void put( const std::string &id, Entry *data ); - -private: - std::map mCache; -}; - -#endif diff --git a/src/function.cpp b/src/function.cpp deleted file mode 100644 index 6e4f1d7..0000000 --- a/src/function.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "function.h" - -Function::Function() -{ -} - -Function::~Function() -{ -} - -void Function::addParam( const char *str ) -{ - lParams.push_back( str ); -} - -void Function::copyData( Function *pSrc, Build &bld, const StringList *cont, VarMap *mExtra ) -{ - lParams.clear(); - for( std::list::iterator i = pSrc->lParams.begin(); - i != pSrc->lParams.end(); i++ ) - { - lParams.push_back( bld.replVars( *i, cont, mExtra ) ); - } -} - diff --git a/src/function.h b/src/function.h deleted file mode 100644 index af0d3fc..0000000 --- a/src/function.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef FUNCTION_H -#define FUNCTION_H - -#include -#include "build.h" - -class Function -{ -public: - Function(); - virtual ~Function(); - - void addParam( const char *str ); - virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput )=0; - virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) = 0; - void copyData( Function *pSrc, Build &bld, const StringList *cont, VarMap *mExtra ); - -protected: - StringList lParams; - -}; - -#endif diff --git a/src/functioncommandtolist.cpp b/src/functioncommandtolist.cpp deleted file mode 100644 index 68c4564..0000000 --- a/src/functioncommandtolist.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "functioncommandtolist.h" -#include "bu/plugger.h" - -PluginInterface2(commandToList, FunctionCommandToList, Function, "Mike Buland", 0, 1 ); - -FunctionCommandToList::FunctionCommandToList() -{ -} - -FunctionCommandToList::~FunctionCommandToList() -{ -} - -void FunctionCommandToList::execute( Build *bld, const StringList &lInput, StringList &lOutput ) -{ - //rView.beginExtraRequiresCheck( s.c_str() ); - //rView.executeCmd( s.c_str() ); - FILE *fcmd = popen( lParams.front().c_str(), "r" ); - std::string rhs; - bool bHeader = true; - for(;;) - { - if( feof( fcmd ) ) - break; - int cc = fgetc( fcmd ); - if( cc == EOF ) - break; - unsigned char c = cc; - if( bHeader ) - { - if( c == ':' ) - bHeader = false; - } - else - { - if( c == ' ' || c == '\t' ) - { - if( rhs != "" ) - { - lOutput.push_back( rhs ); - rhs = ""; - } - } - else - { - if( c == '\\' ) - c = fgetc( fcmd ); - if( c != '\n' ) - rhs += c; - } - } - } - if( rhs != "" ) - { - lOutput.push_back( rhs ); - rhs = ""; - } - pclose( fcmd ); - //rView.endExtraRequiresCheck(); -} - -Function *FunctionCommandToList::duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) -{ - Function *pRet = new FunctionCommandToList(); - pRet->copyData( this, bld, cont, mExtra ); - return pRet; -} - diff --git a/src/functioncommandtolist.h b/src/functioncommandtolist.h deleted file mode 100644 index 05bc393..0000000 --- a/src/functioncommandtolist.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FUNCTION_COMMAND_TO_LIST_H -#define FUNCTION__H - -#include - -#include "function.h" - -class FunctionCommandToList : public Function -{ -public: - FunctionCommandToList(); - virtual ~FunctionCommandToList(); - - virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput ); - virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra ); - -private: - -}; - -#endif diff --git a/src/functiondirectoriesin.cpp b/src/functiondirectoriesin.cpp deleted file mode 100644 index 0ebbbc8..0000000 --- a/src/functiondirectoriesin.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include - -#include "functiondirectoriesin.h" -#include "bu/plugger.h" - -PluginInterface2(directoriesIn, FunctionDirectoriesIn, Function, "Mike Buland", 0, 1 ); - -FunctionDirectoriesIn::FunctionDirectoriesIn() -{ -} - -FunctionDirectoriesIn::~FunctionDirectoriesIn() -{ -} - -void FunctionDirectoriesIn::execute( Build *bld, const StringList &lInput, StringList &lOutput ) -{ - DIR *d = opendir( lParams.front().c_str() ); - if( d == NULL ) - throw BuildException( - "Can't open directory %s.", - lParams.front().c_str() - ); - - struct dirent *e; - - std::string prefix; - if( lParams.size() >= 2 ) - { - StringList::iterator i = lParams.begin(); - i++; - prefix = *i; - } - else - { - prefix = lParams.front() + "/"; - } - - while( (e = readdir( d )) ) - { - if( e->d_type == DT_DIR ) - { - if( e->d_name[0] == '.' || e->d_name[0] == '\0' ) - continue; - std::string sOut = prefix + e->d_name; - lOutput.push_back( sOut ); - if( bld ) - { - std::string sV = lParams.front() + "/"; - sV += e->d_name; - bld->set( sOut, "fulldir", sV ); - } - else - { - printf("no build access.\n"); - } - } - } - - closedir( d ); -} - -Function *FunctionDirectoriesIn::duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) -{ - Function *pRet = new FunctionDirectoriesIn(); - pRet->copyData( this, bld, cont, mExtra ); - return pRet; -} - diff --git a/src/functiondirectoriesin.h b/src/functiondirectoriesin.h deleted file mode 100644 index 7ec86e3..0000000 --- a/src/functiondirectoriesin.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FUNCTION_DIRECTORIES_IN_H -#define FUNCTION_DIRECTORIES_IN_H - -#include - -#include "function.h" - -class FunctionDirectoriesIn : public Function -{ -public: - FunctionDirectoriesIn(); - virtual ~FunctionDirectoriesIn(); - - virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput ); - virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra ); - -private: - -}; - -#endif diff --git a/src/functionfactory.cpp b/src/functionfactory.cpp deleted file mode 100644 index f72e8f6..0000000 --- a/src/functionfactory.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "functionfactory.h" - -extern struct Bu::PluginInfo directoriesIn; -extern struct Bu::PluginInfo filesIn; -extern struct Bu::PluginInfo regexp; -extern struct Bu::PluginInfo toString; -extern struct Bu::PluginInfo commandToList; -extern struct Bu::PluginInfo targets; - -FunctionFactory::FunctionFactory() -{ - registerBuiltinPlugin( &directoriesIn ); - registerBuiltinPlugin( &filesIn ); - registerBuiltinPlugin( ®exp ); - registerBuiltinPlugin( &toString ); - registerBuiltinPlugin( &commandToList ); - registerBuiltinPlugin( &targets ); -} - -FunctionFactory::~FunctionFactory() -{ -} diff --git a/src/functionfactory.h b/src/functionfactory.h deleted file mode 100644 index 2cc28fe..0000000 --- a/src/functionfactory.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef FUNCTION_FACTORY_H -#define FUNCTION_FACTORY_H - -#include - -#include "bu/plugger.h" -#include "bu/singleton.h" -#include "function.h" - -class FunctionFactory : public Bu::Plugger, public Bu::Singleton -{ -public: - FunctionFactory(); - virtual ~FunctionFactory(); - -private: - -}; - -#endif diff --git a/src/functionfilesin.cpp b/src/functionfilesin.cpp deleted file mode 100644 index 5301cd2..0000000 --- a/src/functionfilesin.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include - -#include "functionfilesin.h" -#include "bu/plugger.h" -#include "build.h" - -PluginInterface2(filesIn, FunctionFilesIn, Function, "Mike Buland", 0, 1 ); - -FunctionFilesIn::FunctionFilesIn() -{ -} - -FunctionFilesIn::~FunctionFilesIn() -{ -} - -void FunctionFilesIn::execute( Build *bld, const StringList &lInput, StringList &lOutput ) -{ - DIR *d = opendir( lParams.front().c_str() ); - if( d == NULL ) - throw BuildException( - "Can't open directory %s.", - lParams.front().c_str() - ); - - struct dirent *e; - - std::string prefix; - if( lParams.size() >= 2 ) - { - StringList::iterator i = lParams.begin(); - i++; - prefix = *i; - } - else - { - prefix = lParams.front() + "/"; - } - - while( (e = readdir( d )) ) - { - if( e->d_type != DT_DIR ) - { - if( e->d_name[0] != '.') - lOutput.push_back( prefix + e->d_name ); - } - } - - closedir( d ); -} - -Function *FunctionFilesIn::duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) -{ - Function *pRet = new FunctionFilesIn(); - pRet->copyData( this, bld, cont, mExtra ); - return pRet; -} - diff --git a/src/functionfilesin.h b/src/functionfilesin.h deleted file mode 100644 index 904837f..0000000 --- a/src/functionfilesin.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FUNCTION_FILES_IN_H -#define FUNCTION_FILES_IN_H - -#include - -#include "function.h" - -class FunctionFilesIn : public Function -{ -public: - FunctionFilesIn(); - virtual ~FunctionFilesIn(); - - virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput ); - virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra ); - -private: - -}; - -#endif diff --git a/src/functionregexp.cpp b/src/functionregexp.cpp deleted file mode 100644 index 2dc18b2..0000000 --- a/src/functionregexp.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "functionregexp.h" -#include "bu/plugger.h" -#include "regexp.h" - -PluginInterface2(regexp, FunctionRegexp, Function, "Mike Buland", 0, 1 ); - -FunctionRegexp::FunctionRegexp() -{ -} - -FunctionRegexp::~FunctionRegexp() -{ -} - -void FunctionRegexp::execute( Build *bld, const StringList &lInput, StringList &lOutput ) -{ - if( lParams.size() == 1 ) - { - RegExp re( lParams.front().c_str() ); - - for( StringList::const_iterator i = lInput.begin(); - i != lInput.end(); i++ ) - { - if( re.execute( (*i).c_str() ) ) - { - lOutput.push_back( *i ); - if( bld ) - { - int jmax = re.getNumSubStrings(); - for( int j = 0; j < jmax; j++ ) - { - char buf[30]; - sprintf( buf, "re:%d", j ); - bld->set( *i, buf, re.getSubString( j ) ); - } - } - } - } - } - else - { - if( !bld ) - { - throw BuildException("You apparently can't use regexp with two params here. Isn't that odd?"); - } - - RegExp re( lParams.front().c_str() ); - lParams.pop_front(); - std::string p2 = lParams.front(); - - for( StringList::const_iterator i = lInput.begin(); - i != lInput.end(); i++ ) - { - if( re.execute( (*i).c_str() ) ) - { - VarMap ext; - int jmax = re.getNumSubStrings(); - for( int j = 0; j < jmax; j++ ) - { - char buf[30]; - sprintf( buf, "re:%d", j ); - ext[buf] = re.getSubString( j ); - } - - std::string sNew = bld->replVars( p2, NULL, &ext ); - lOutput.push_back( sNew ); - - for( int j = 0; j < jmax; j++ ) - { - char buf[30]; - sprintf( buf, "re:%d", j ); - bld->set( sNew, buf, re.getSubString( j ) ); - } - bld->copyContext( *i, sNew ); - } - } - } -} - -Function *FunctionRegexp::duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) -{ - Function *pRet = new FunctionRegexp(); - pRet->copyData( this, bld, cont, mExtra ); - return pRet; -} - diff --git a/src/functionregexp.h b/src/functionregexp.h deleted file mode 100644 index 42fe811..0000000 --- a/src/functionregexp.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FUNCTION_REGEXP_H -#define FUNCTION_REGEXP_H - -#include - -#include "function.h" - -class FunctionRegexp : public Function -{ -public: - FunctionRegexp(); - virtual ~FunctionRegexp(); - - virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput ); - virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra ); - -private: - -}; - -#endif diff --git a/src/functiontargets.cpp b/src/functiontargets.cpp deleted file mode 100644 index a94f43e..0000000 --- a/src/functiontargets.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "functiontargets.h" -#include "bu/plugger.h" -#include "build.h" - -PluginInterface2(targets, FunctionTargets, Function, "Mike Buland", 0, 1 ); - -FunctionTargets::FunctionTargets() -{ -} - -FunctionTargets::~FunctionTargets() -{ -} - -void FunctionTargets::execute( Build *bld, const StringList &lInput, StringList &lOutput ) -{ - if( bld == NULL ) - { - throw BuildException("You cannot call targets() from anywhere, see the manual."); - } - - for( TargetMap::iterator i = bld->getTargetMap().begin(); - i != bld->getTargetMap().end(); i++ ) - { - lOutput.push_back( (*i).first ); - } -} - -Function *FunctionTargets::duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) -{ - Function *pRet = new FunctionTargets(); - pRet->copyData( this, bld, cont, mExtra ); - return pRet; -} - diff --git a/src/functiontargets.h b/src/functiontargets.h deleted file mode 100644 index f42ce96..0000000 --- a/src/functiontargets.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FUNCTION_TARGETS_H -#define FUNCTION_TARGETS_H - -#include - -#include "function.h" - -class FunctionTargets : public Function -{ -public: - FunctionTargets(); - virtual ~FunctionTargets(); - - virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput ); - virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra ); - -private: - -}; - -#endif diff --git a/src/functiontostring.cpp b/src/functiontostring.cpp deleted file mode 100644 index 2fdcc1c..0000000 --- a/src/functiontostring.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "functiontostring.h" -#include "bu/plugger.h" - -PluginInterface2(toString, FunctionToString, Function, "Mike Buland", 0, 1 ); - -FunctionToString::FunctionToString() -{ -} - -FunctionToString::~FunctionToString() -{ -} - -void FunctionToString::execute( Build *bld, const StringList &lInput, StringList &lOutput ) -{ - std::string sOut; - - for( StringList::const_iterator i = lInput.begin(); i != lInput.end(); i++ ) - { - if( i != lInput.begin() ) sOut += " "; - sOut += *i; - } - - lOutput.push_back( sOut ); -} - -Function *FunctionToString::duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) -{ - Function *pRet = new FunctionToString(); - pRet->copyData( this, bld, cont, mExtra ); - return pRet; -} - diff --git a/src/functiontostring.h b/src/functiontostring.h deleted file mode 100644 index d9c5af7..0000000 --- a/src/functiontostring.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FUNCTION_TO_STRING_H -#define FUNCTION_TO_STRING_H - -#include - -#include "function.h" - -class FunctionToString : public Function -{ -public: - FunctionToString(); - virtual ~FunctionToString(); - - virtual void execute( Build *bld, const StringList &lInput, StringList &lOutput ); - virtual Function *duplicate( Build &bld, const StringList *cont, VarMap *mExtra ); - -private: - -}; - -#endif diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index 1d3dc10..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,172 +0,0 @@ -#include "buildparser.h" -//#include "viewerplain.h" -//#include "viewerpercent.h" -//#include "viewermake.h" -#include "bu/paramproc.h" -#include "bu/fstring.h" -#include "build.h" -#include "action.h" - -#include - -class Param : public Bu::ParamProc -{ -public: - Param() : - sFile("build.conf"), - sCache(".build.cache"), - bDebug( false ), - bPostDebug( false ), - sView("colorpct"), - bInfo( false ), - bCleanMode( false ), - sDir("") - { - addHelpBanner("Build r?\n\n"); - addParam("file", 'f', &sFile, - "Set the input script, default: build.conf"); - addParam("info", 'i', &bInfo, - "Display useful info about the loaded config file.", NULL, "true" ); - addParam("chdir", 'C', &sDir, - "Change to the specified dir before doing anything else." ); - addParam("clean", 'c', &bCleanMode, - "Clean instead of checking the given action.", NULL, "true" ); - addParam('p', mkproc(Param::procViewPercent), - "Switch to percent view."); - addParam('P', mkproc(Param::procViewPlain), - "Switch to plain view."); - addParam("color", mkproc(Param::procColorPercent), - "Switch to colored percent view."); - addParam('m', mkproc(Param::procViewMake), - "Switch to 'make' style view."); - addParam("cache", &sCache, - "Set an alternative cache file, default: .build.cache" ); - addParam('d', &bDebug, - "Display debug info instead of building", NULL, "true" ); - addParam('D', &bPostDebug, - "Display debug info after building", NULL, "true" ); - addParam("help", mkproc(ParamProc::help), - "This help"); - //pViewer = new ViewerPlain; - } - - virtual ~Param() - { - //delete pViewer; - } - - virtual int cmdParam( int argc, char *argv[] ) - { - if( sAction.isSet() ) - { - printf("You can only specify one action per command line.\n\n"); - exit( 1 ); - } - sAction = argv[0]; - return 1; - } - - int procViewPercent( int argc, char *argv[] ) - { - sView = "percent"; - } - - int procViewPlain( int argc, char *argv[] ) - { - sView = "plain"; - } - - int procViewMake( int argc, char *argv[] ) - { - sView = "make"; - } - - int procColorPercent( int argc, char *argv[] ) - { - sView = "colorpct"; - } - - Bu::FString sCache; - Bu::FString sFile; - Bu::FString sView; - Bu::FString sDir; - Bu::FString sAction; - //Viewer *pViewer; - bool bDebug; - bool bPostDebug; - bool bInfo; - bool bCleanMode; - -private: -}; - -int main( int argc, char *argv[] ) -{ - Param prm; - prm.process( argc, argv ); - - BuildParser bld; - Build *pBuild = NULL; - - char *olddir = NULL; - - try - { - if( prm.sDir != "" ) - { - olddir = new char[4096]; - getcwd( olddir, 4096 ); - chdir( prm.sDir.getStr() ); - } - - pBuild = bld.load( prm.sFile.getStr() ); - pBuild->setCache( prm.sCache.getStr() ); - pBuild->setView( prm.sView.getStr() ); - if( prm.bCleanMode ) - pBuild->setMode( Action::actClean ); - - if( prm.bInfo ) - { - pBuild->printInfo(); - delete pBuild; - if( olddir ) { chdir( olddir ); delete[] olddir; } - return 0; - } - if( prm.bDebug ) - { - printf("\n\n----------\nDebug dump\n----------\n"); - pBuild->debugDump(); - } - else - { - if( prm.sAction.isSet() ) - pBuild->execAction( prm.sAction.getStr() ); - else - pBuild->execAction(""); - } - if( prm.bPostDebug ) - { - printf("\n\n----------\nDebug dump\n----------\n"); - pBuild->debugDump(); - } - } - catch( BuildException &e ) - { - fputs( e.what(), stderr ); - fputs( "\n", stderr ); - if( prm.bPostDebug ) - { - printf("\n\n----------\nDebug dump\n----------\n"); - pBuild->debugDump(); - } - delete pBuild; - if( olddir ) { chdir( olddir ); delete[] olddir; } - return 1; - } - - delete pBuild; - if( olddir ) { chdir( olddir ); delete[] olddir; } - - return 0; -} - diff --git a/src/parser.cpp b/src/parser.cpp deleted file mode 100644 index d9fd2d0..0000000 --- a/src/parser.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "parser.h" -#include "build.h" - -Parser::Parser() -{ -} - -Parser::~Parser() -{ -} - -void Parser::error( YYLTYPE *locp, const char *msg ) -{ - fflush( stdout ); - throw BuildException("%s: %d.%d-%d.%d: %s", - file.c_str(), - locp->first_line, locp->first_column, - locp->last_line, locp->last_column, - msg ); -} - -void Parser::error( const std::string &msg ) -{ - fflush( stdout ); - throw BuildException("%s", msg.c_str() ); -} - diff --git a/src/parser.h b/src/parser.h deleted file mode 100644 index 675e28b..0000000 --- a/src/parser.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef PARSER_H -#define PARSER_H - -#include -#include - -class Build; - -#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED) -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 -#endif - -class Parser -{ -public: - Parser(); - virtual ~Parser(); - - virtual void error( YYLTYPE *locp, const char *msg ); - virtual void error( const std::string &msg ); - - virtual Build *load( const std::string &sFile ) = 0; - -protected: - std::string file; - -private: - -}; - -#endif diff --git a/src/perform.cpp b/src/perform.cpp deleted file mode 100644 index 25d54c7..0000000 --- a/src/perform.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "perform.h" -#include "build.h" - -Perform::Perform() -{ -} - -Perform::~Perform() -{ -} - -void Perform::addParam( const char *sParam ) -{ - lParam.push_back( sParam ); -} - -void Perform::copyData( Perform *pSrc, Build &bld, const StringList *cont, VarMap *mExtra ) -{ - lParam.clear(); - for( std::list::iterator i = pSrc->lParam.begin(); - i != pSrc->lParam.end(); i++ ) - { - lParam.push_back( bld.replVars( *i, cont, mExtra ) ); - } -} - diff --git a/src/perform.h b/src/perform.h deleted file mode 100644 index 031e007..0000000 --- a/src/perform.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef PERFORM_H -#define PERFORM_H - -#include -#include -#include -#include - -typedef std::map VarMap; -typedef std::list StringList; - -class Build; - -class Perform -{ -public: - Perform(); - virtual ~Perform(); - - void addParam( const char *sParam ); - virtual Perform *duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) = 0; - virtual void execute( Build &bld ) = 0; - void copyData( Perform *pSrc, Build &bld, const StringList *cont, VarMap *mExtra ); - std::string getTarget() - { - return sTarget; - } - void setTarget( std::string sTarget ) - { - this->sTarget = sTarget; - } - - std::list &getReqFuncs() - { - return lReqFuncs; - } - - void setRule( const std::string &sRule ) - { - this->sRule = sRule; - } - - std::string &getRule() - { - return sRule; - } - -protected: - std::list lParam; - std::string sTarget; - std::string sRule; - std::list lReqFuncs; -}; - -#endif diff --git a/src/performcommand.cpp b/src/performcommand.cpp deleted file mode 100644 index 65827c5..0000000 --- a/src/performcommand.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "performcommand.h" -#include "bu/plugger.h" -#include "build.h" -#include "viewer.h" - -#include - -PluginInterface2(command, PerformCommand, Perform, "Mike Buland", 0, 1 ); - -PerformCommand::PerformCommand() -{ -} - -PerformCommand::~PerformCommand() -{ -} - -Perform *PerformCommand::duplicate( Build &bld, const StringList *cont, VarMap *mExtra ) -{ - Perform *pRet = new PerformCommand(); - pRet->copyData( this, bld, cont, mExtra ); - return pRet; -} - -void PerformCommand::execute( Build &bld ) -{ - bld.getView()->executeCmd( lParam.front() ); - int n = system( lParam.front().c_str() ); - if( n != 0 ) - throw BuildException( - "Command exited with error code %d.", - WEXITSTATUS(n) - ); -} - diff --git a/src/performcommand.h b/src/performcommand.h deleted file mode 100644 index 62bf61e..0000000 --- a/src/performcommand.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef PERFORM_COMMAND_H -#define PERFORM_COMMAND_H - -#include - -#include "perform.h" - -class PerformCommand : public Perform -{ -public: - PerformCommand(); - virtual ~PerformCommand(); - - virtual Perform *duplicate( Build &bld, const StringList *cont, VarMap *mExtra ); - virtual void execute( Build &bld ); - -private: - -}; - -#endif diff --git a/src/performfactory.cpp b/src/performfactory.cpp deleted file mode 100644 index 6926a3b..0000000 --- a/src/performfactory.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "performfactory.h" - -extern struct Bu::PluginInfo command; - -PerformFactory::PerformFactory() -{ - registerBuiltinPlugin( &command ); -} - -PerformFactory::~PerformFactory() -{ -} diff --git a/src/performfactory.h b/src/performfactory.h deleted file mode 100644 index 435d9c6..0000000 --- a/src/performfactory.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef PERFORM_FACTORY_H -#define PERFORM_FACTORY_H - -#include - -#include "perform.h" -#include "bu/plugger.h" -#include "bu/singleton.h" - -class PerformFactory : public Bu::Plugger, public Bu::Singleton -{ -public: - PerformFactory(); - virtual ~PerformFactory(); - -private: - -}; - -#endif diff --git a/src/regexp.cpp b/src/regexp.cpp deleted file mode 100644 index 4370667..0000000 --- a/src/regexp.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "regexp.h" -#include "build.h" // For BuildException -#include "bu/fstring.h" - -RegExp::RegExp() : - bCompiled( false ), - aSubStr( NULL ) -{ -} - -RegExp::RegExp( const char *sSrc ) : - bCompiled( false ), - aSubStr( NULL ) -{ - compile( sSrc ); -} - -RegExp::~RegExp() -{ - if( bCompiled ) - { - regfree( &re ); - delete[] aSubStr; - } -} - -void RegExp::compile( const char *sSrc ) -{ - if( bCompiled ) - { - regfree( &re ); - delete[] aSubStr; - bCompiled = false; - } - - int nErr = regcomp( &re, sSrc, REG_EXTENDED|REG_NEWLINE ); - if( nErr ) - { - size_t length = regerror( nErr, &re, NULL, 0 ); - char *buffer = new char[length]; - (void) regerror( nErr, &re, buffer, length ); - Bu::FString s( buffer ); - delete[] buffer; - throw BuildException( s.getStr() ); - } - bCompiled = true; - this->sSrc = sSrc; - - nSubStr = re.re_nsub+1; - aSubStr = new regmatch_t[nSubStr]; -} - -int RegExp::getNumSubStrings() -{ - return nSubStr; -} - -bool RegExp::execute( const char *sSrc ) -{ - sTest = sSrc; - if( regexec( &re, sSrc, nSubStr, aSubStr, 0 ) ) - return false; - return true; -} - -std::pair RegExp::getSubStringRange( int nIndex ) -{ - return std::pair( aSubStr[nIndex].rm_so, aSubStr[nIndex].rm_eo ); -} - -std::string RegExp::getSubString( int nIndex ) -{ - return std::string( - sTest.getStr()+aSubStr[nIndex].rm_so, - aSubStr[nIndex].rm_eo - aSubStr[nIndex].rm_so - ); -} - diff --git a/src/regexp.h b/src/regexp.h deleted file mode 100644 index a5fab14..0000000 --- a/src/regexp.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef REG_EXP_H -#define REG_EXP_H - -#include -#include -#include -#include -#include "bu/fstring.h" - -class RegExp -{ -public: - RegExp(); - RegExp( const char *sSrc ); - virtual ~RegExp(); - - void compile( const char *sSrc ); - int getNumSubStrings(); - bool execute( const char *sSrc ); - std::pair getSubStringRange( int nIndex ); - std::string getSubString( int nIndex ); - const char *getSource() - { - return sSrc.getStr(); - } - -private: - Bu::FString sSrc; - Bu::FString sTest; - regex_t re; - bool bCompiled; - int nSubStr; - regmatch_t *aSubStr; -}; - -#endif diff --git a/src/rule.cpp b/src/rule.cpp deleted file mode 100644 index 7924ba4..0000000 --- a/src/rule.cpp +++ /dev/null @@ -1,159 +0,0 @@ -#include "rule.h" -#include "build.h" -#include "function.h" -#include "perform.h" - -#include - -Rule::Rule() : - pAggregate( NULL ) -{ -} - -Rule::~Rule() -{ -} - -StringList Rule::execute( Build &bld, StringList &lInput, PerformList &lPerf, bool bFirstOnly ) -{ - StringList lOutput; - - RuleList rl = bld.findChainRules( this ); - - for( RuleList::iterator i = rl.begin(); i != rl.end(); i++ ) - { - (*i)->setTarget( sTarget ); - StringList tmp = (*i)->execute( bld, lInput, lPerf, bFirstOnly ); - lOutput.insert( lOutput.end(), tmp.begin(), tmp.end() ); - } - - StringList lMine; - for( FunctionList::iterator i = lMatches.begin(); i != lMatches.end(); i++ ) - { - (*i)->execute( &bld, lInput, lMine ); - } - - StringList lTmp; - for( FunctionList::iterator i = lFilter.begin(); i != lFilter.end(); i++ ) - { - (*i)->execute( &bld, lMine, lTmp ); - lMine.swap( lTmp ); - lTmp.clear(); - } - - bool bHasProduces = true; - if( lProduces.empty() ) - { - bHasProduces = false; - lProduces.push_back( sTarget ); - } - - { - std::set sUsed; - for( StringList::iterator i = lInput.begin(); i != lInput.end(); i++ ) - { -isuck: if( i == lInput.end() ) break; - if( sUsed.find( *i ) != sUsed.end() ) - { - StringList::iterator j = i; - j++; - lInput.erase( i ); - i = j; - goto isuck; - } - sUsed.insert( *i ); - } - } - - StringList lNewOut; - if( pAggregate ) - { - VarMap mTmp; - std::string target = lProduces.front();//, lProduces.front(), NULL ).c_str(); - mTmp["target"] = target; - lNewOut.push_back( target ); - - for( StringList::iterator i = lMine.begin(); i != lMine.end(); i++ ) - { - bld.addRequires( target, (*i) ); - } - for( StringList::iterator i = lReqStrs.begin(); - i != lReqStrs.end(); i++ ) - { - bld.addRequires( target, (*i) ); - } - - StringList lTmp; - pAggregate->execute( &bld, lMine, lTmp ); - mTmp["match"] = lTmp.front(); - - for( PerformList::iterator k = lPerform.begin(); - k != lPerform.end(); k++ ) - { - StringList cont; - cont.push_front( target ); - Perform *p = (*k)->duplicate( bld, &cont, &mTmp ); - p->setTarget( target ); - p->setRule( sName ); - //p->setReqFuncs( &lReqFuncs ); - lPerf.push_back( p ); - } - } - else - { - for( StringList::iterator i = lMine.begin(); i != lMine.end(); i++ ) - { - for( StringList::iterator j = lProduces.begin(); - j != lProduces.end(); j++ ) - //StringList::iterator j = lProduces.begin(); - { - VarMap mTmp; - StringList cont; - cont.push_front( sTarget ); - cont.push_front( (*i) ); - std::string target = bld.replVars( (*j), &cont, NULL ); - mTmp["target"] = target; - lNewOut.push_back( target ); - mTmp["match"] = (*i); - bld.addRequires( target, (*i) ); - for( StringList::iterator k = lReqStrs.begin(); - k != lReqStrs.end(); k++ ) - { - bld.addRequires( target, (*k) ); - } - for( PerformList::iterator k = lPerform.begin(); - k != lPerform.end(); k++ ) - { - StringList cont2; - cont2.push_front( sTarget ); - cont2.push_front( (*i) ); - cont2.push_front( target ); - Perform *p = (*k)->duplicate( bld, &cont2, &mTmp ); - p->setTarget( target ); - p->setRule( sName ); - for( FunctionList::iterator f = lReqFuncs.begin(); - f != lReqFuncs.end(); f++ ) - { - p->getReqFuncs().push_back( - (*f)->duplicate( bld, &cont2, &mTmp ) - ); - } - lPerf.push_back( p ); - } - if( bFirstOnly ) - break; - } - } - } - - lInput.insert( lInput.end(), lNewOut.begin(), lNewOut.end() ); - lOutput.insert( lOutput.end(), lNewOut.begin(), lNewOut.end() ); - - if( bHasProduces == false ) - { - lProduces.clear(); - } - - return lOutput; -} - diff --git a/src/rule.h b/src/rule.h deleted file mode 100644 index c6e8336..0000000 --- a/src/rule.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef RULE_H -#define RULE_H - -#include -#include -#include - -class Function; -class Perform; -class Build; - -typedef std::list FunctionList; -typedef std::list PerformList; -typedef std::list StringList; - -class Rule -{ -public: - Rule(); - virtual ~Rule(); - - StringList execute( Build &bld, StringList &lInput, PerformList &lPerf, bool bFirstOnly=true ); - - void setTarget( const std::string &sTarget ) - { - this->sTarget = sTarget; - } - - std::string getName() - { - return sName; - } - - void setName( const std::string &sName ) - { - this->sName = sName; - } - - FunctionList &getFilterList() - { - return lFilter; - } - - PerformList &getPerformList() - { - return lPerform; - } - - FunctionList &getMatchesList() - { - return lMatches; - } - - StringList &getProducesList() - { - return lProduces; - } - - void setAggregate( Function *pAggregate ) - { - this->pAggregate = pAggregate; - } - - StringList &getReqStrList() - { - return lReqStrs; - } - - FunctionList &getReqFuncList() - { - return lReqFuncs; - } - -private: - std::string sName; - FunctionList lMatches; - FunctionList lFilter; - PerformList lPerform; - StringList lProduces; - std::string sTarget; - Function *pAggregate; - StringList lReqStrs; - FunctionList lReqFuncs; -}; - -#endif diff --git a/src/stringproc.cpp b/src/stringproc.cpp deleted file mode 100644 index 23abca9..0000000 --- a/src/stringproc.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "stringproc.h" - -StringProc::StringProc( Build *pBld ) : - pBld( pBld ) -{ -} - -StringProc::~StringProc() -{ -} - - diff --git a/src/stringproc.h b/src/stringproc.h deleted file mode 100644 index d408601..0000000 --- a/src/stringproc.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef STRING_PROC_H -#define STRING_PROC_H - -#include -#include -#include -#include - -class Build; - -typedef std::map VarMap; -typedef std::list StringList; - -class StringProc -{ -public: - StringProc( Build *pBld ); - virtual ~StringProc(); - - virtual std::string replVars( const std::string &sSrc, const StringList *pCont, VarMap *mExtra )=0; - -protected: - Build *getBuild() - { - return pBld; - } - -private: - Build *pBld; - -}; - -#endif diff --git a/src/stringprocbuild.cpp b/src/stringprocbuild.cpp deleted file mode 100644 index 419d819..0000000 --- a/src/stringprocbuild.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "stringprocbuild.h" -#include "build.h" - -StringProcBuild::StringProcBuild( Build *pBld ) : - StringProc( pBld ) -{ -} - -StringProcBuild::~StringProcBuild() -{ -} - -std::string StringProcBuild::replVars( const std::string &sSrc, const StringList *pCont, VarMap *mExtra ) -{ - std::string sDes, sBuf; - int nMode = 0; - - int nLen = sSrc.size(); - for( int j = 0; j < nLen; j++ ) - { - if( sSrc[j] == '{' ) - { - sBuf = ""; - nMode = 1; - } - else if( nMode == 0 ) - { - sDes += sSrc[j]; - } - else if( nMode == 1 ) - { - if( sSrc[j] == '}' ) - { - sDes += getBuild()->getVar( pCont, sBuf, mExtra ); - nMode = 0; - } - else - { - sBuf += sSrc[j]; - } - } - } - - if( nMode == 1 ) - { - throw BuildException( - "Unterminated variable replacement found: \"%s\"", - sSrc.c_str() - ); - } - - return sDes; -} - diff --git a/src/stringprocbuild.h b/src/stringprocbuild.h deleted file mode 100644 index f3cf3b4..0000000 --- a/src/stringprocbuild.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef STRING_PROC_BUILD_H -#define STRING_PROC_BUILD_H - -#include - -#include "stringproc.h" - -class StringProcBuild : public StringProc -{ -public: - StringProcBuild( Build *pBld ); - virtual ~StringProcBuild(); - - virtual std::string replVars( const std::string &sSrc, const StringList *pCont, VarMap *mExtra ); - -private: - -}; - -#endif diff --git a/src/target.cpp b/src/target.cpp deleted file mode 100644 index 3150c38..0000000 --- a/src/target.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "target.h" -#include "build.h" -#include "viewer.h" - -Target::Target() : - bRun( false ) -{ -} - -Target::~Target() -{ -} - -void Target::run( Action::eAction nAct, Build &bld ) -{ - bRun = true; - - bld.getView()->beginCommand( nAct, sName ); - switch( nAct ) - { - case Action::actCheck: - check( bld ); - break; - - case Action::actClean: - clean( bld ); - break; - } - bld.getView()->endCommand(); -} - diff --git a/src/target.h b/src/target.h deleted file mode 100644 index f51e0e0..0000000 --- a/src/target.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef TARGET_H -#define TARGET_H - -#include - -#include -#include - -#include "action.h" - -typedef std::list StringList; - -class Build; - -class Target -{ -public: - Target(); - virtual ~Target(); - - void run( Action::eAction nAct, Build &bld ); - virtual void check( Build &bld ) = 0; - virtual void clean( Build &bld ) = 0; - - void setName( const std::string &sName ) - { - this->sName = sName; - } - - std::string getName() - { - return sName; - } - - void setRule( const std::string &sRule ) - { - this->sRule = sRule; - } - - std::string getRule() - { - return sRule; - } - - StringList &getInput() - { - return lInput; - } - - bool wasRun() - { - return bRun; - } - - -private: - std::string sName; - std::string sRule; - StringList lInput; - bool bRun; -}; - -#endif diff --git a/src/targetfactory.cpp b/src/targetfactory.cpp deleted file mode 100644 index a0bc0b0..0000000 --- a/src/targetfactory.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "targetfactory.h" - -extern struct Bu::PluginInfo file; - -TargetFactory::TargetFactory() -{ - registerBuiltinPlugin( &file ); -} - -TargetFactory::~TargetFactory() -{ -} diff --git a/src/targetfactory.h b/src/targetfactory.h deleted file mode 100644 index ee1fc2a..0000000 --- a/src/targetfactory.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef TARGET_FACTORY_H -#define TARGET_FACTORY_H - -#include - -#include "bu/plugger.h" -#include "bu/singleton.h" -#include "target.h" - -class TargetFactory : public Bu::Plugger, public Bu::Singleton -{ -public: - TargetFactory(); - virtual ~TargetFactory(); - -private: - -}; - -#endif diff --git a/src/targetfile.cpp b/src/targetfile.cpp deleted file mode 100644 index 0e2d43e..0000000 --- a/src/targetfile.cpp +++ /dev/null @@ -1,158 +0,0 @@ -#include "targetfile.h" -#include "bu/plugger.h" -#include "rule.h" -#include "build.h" -#include "perform.h" -#include "function.h" -#include "viewer.h" - -#include - -PluginInterface2(file, TargetFile, Target, "Mike Buland", 0, 1 ); - -TargetFile::TargetFile() -{ -} - -TargetFile::~TargetFile() -{ -} - -void TargetFile::check( Build &bld ) -{ - Rule *pRule = bld.getRule( getRule() ); - PerformList lPerf; - pRule->setTarget( getName() ); - StringList lFinal = pRule->execute( bld, getInput(), lPerf ); - - { - std::set sUsed; - for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ ) - { -isuck: if( i == lPerf.end() ) break; - if( sUsed.find( (*i)->getTarget() ) != sUsed.end() ) - { - PerformList::iterator j = i; - j++; - delete *i; - lPerf.erase( i ); - i = j; - goto isuck; - } - sUsed.insert( (*i)->getTarget() ); - } - } - - bld.getView()->beginPerforms( lPerf.size() ); - - for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ ) - { - StringList &reqs = bld.getRequires( (*i)->getTarget() ); - for( StringList::iterator j = reqs.begin(); j != reqs.end(); j++ ) - { - bld.chainTarget( *j ); - } - } - - for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ ) - { - time_t tTarget = getTime( bld, (*i)->getTarget() ); - StringList &reqs = bld.getRequires( (*i)->getTarget() ); - bool bExtras = false, bBuilt = false, bUpdate = false; - for( StringList::iterator j = reqs.begin(); j != reqs.end(); j++ ) - { - //bld.chainTarget( *j ); - if( getTime( bld, *j ) > tTarget ) - { - if( bUpdate == false ) - bld.getView()->skipRequiresCheck( false, (*i)->getTarget() ) ; - bld.getView()->beginPerform( *i ); - (*i)->execute( bld ); - bld.getView()->endPerform(); - updateTime( (*i)->getTarget() ); - bBuilt = true; - break; - } - if( bExtras == false ) - { - StringList::iterator jj = j; - jj++; - if( jj == reqs.end() ) - { - if( !bld.getCached( (*i)->getTarget(), tTarget, reqs ) ) - { - bld.updateCache( (*i)->getTarget(), (*i)->getReqFuncs(), reqs ); - bUpdate = true; - } - bExtras = true; - } - } - } - if( bBuilt == false ) - { - if( bUpdate == false ) - { - bld.getView()->skipRequiresCheck( false, (*i)->getTarget() ); - } - bld.getView()->skipPerform( *i ); - } - } - - bld.getView()->endPerforms(); -} - -void TargetFile::clean( Build &bld ) -{ - Rule *pRule = bld.getRule( getRule() ); - PerformList lPerf; - pRule->setTarget( getName() ); - StringList lFinal = pRule->execute( bld, getInput(), lPerf, false ); - - bld.getView()->beginPerforms( lPerf.size() ); - - for( PerformList::iterator i = lPerf.begin(); i != lPerf.end(); i++ ) - { - if( access( (*i)->getTarget().c_str(), W_OK ) == 0 ) - { - (*i)->setRule("clean"); - bld.getView()->beginPerform( *i ); - unlink( (*i)->getTarget().c_str() ); - bld.getView()->endPerform(); - } - } - - bld.getView()->endPerforms(); -} - -time_t TargetFile::getTime( Build &bld, std::string str ) -{ - std::map::iterator i = mTimes.find( str ); - if( i != mTimes.end() ) - { - //nCache++; - //bld.view().beginRequiresCheck( true, str.c_str() ); - //bld.view().endRequiresCheck(); - return (*i).second; - } - - //bld.view().beginRequiresCheck( false, str.c_str() ); - struct stat st; - stat( str.c_str(), &st ); - - mTimes[str] = st.st_mtime; - - //nNew++; - - //bld.view().endRequiresCheck(); - - return st.st_mtime; -} - -void TargetFile::updateTime( std::string str ) -{ - struct stat st; - stat( str.c_str(), &st ); - - mTimes[str] = st.st_mtime; -} - diff --git a/src/targetfile.h b/src/targetfile.h deleted file mode 100644 index 368e252..0000000 --- a/src/targetfile.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef TARGET_FILE_H -#define TARGET_FILE_H - -#include -#include -#include -#include -#include - -#include "target.h" - -class TargetFile : public Target -{ -public: - TargetFile(); - virtual ~TargetFile(); - - virtual void check( Build &bld ); - virtual void clean( Build &bld ); - - time_t getTime( class Build &bld, std::string str ); - void updateTime( std::string str ); - -private: - std::map mTimes; -}; - -#endif diff --git a/src/viewer.cpp b/src/viewer.cpp deleted file mode 100644 index 1f3b26f..0000000 --- a/src/viewer.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "viewer.h" - -Viewer::Viewer() -{ -} - -Viewer::~Viewer() -{ -} - -void Viewer::beginAction( const std::string &sName, int nCommands ) -{ -} - -void Viewer::endAction() -{ -} - -void Viewer::beginCommand( Action::eAction nAct, const std::string &sTarget ) -{ -} - -void Viewer::beginPerforms( int nCount ) -{ -} - -void Viewer::endPerforms() -{ -} - -void Viewer::endCommand() -{ -} - -void Viewer::beginRequiresCheck( bool bCached, const std::string &sName ) -{ -} - -void Viewer::endRequiresCheck() -{ -} - -void Viewer::skipRequiresCheck( bool bCached, const std::string &sName ) -{ -} - -void Viewer::beginPerform( Perform *pPerform ) -{ -} - -void Viewer::endPerform() -{ -} - -void Viewer::skipPerform( Perform *pPerform ) -{ -} - -void Viewer::beginExecute() -{ -} - -void Viewer::endExecute() -{ -} - -void Viewer::executeCmd( const std::string &sCmd ) -{ -} - diff --git a/src/viewer.h b/src/viewer.h deleted file mode 100644 index 7ee6b21..0000000 --- a/src/viewer.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef VIEWER_H -#define VIEWER_H - -#include -#include -#include "action.h" - -class Perform; - -class Viewer -{ -public: - Viewer(); - virtual ~Viewer(); - - virtual void beginAction( const std::string &sName, int nCommands ); - virtual void endAction(); - - virtual void beginCommand( Action::eAction nAct, const std::string &sTarget ); - virtual void endCommand(); - virtual void beginPerforms( int nCount ); - virtual void endPerforms(); - - virtual void beginRequiresCheck( bool bCached, const std::string &sName ); - virtual void endRequiresCheck(); - virtual void skipRequiresCheck( bool bCached, const std::string &sName ); - virtual void beginPerform( Perform *pPerform ); - virtual void endPerform(); - virtual void skipPerform( Perform *pPerform ); - virtual void beginExecute(); - virtual void endExecute(); - virtual void executeCmd( const std::string &sCmd ); - -private: - -}; - -#endif diff --git a/src/viewercolorpct.cpp b/src/viewercolorpct.cpp deleted file mode 100644 index 5bc3cba..0000000 --- a/src/viewercolorpct.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include "viewercolorpct.h" -#include "perform.h" -#include "bu/plugger.h" -#include - -PluginInterface2( colorpct, ViewerColorPct, Viewer, "Mike Buland", 0, 1 ); - -ViewerColorPct::ViewerColorPct() : - bRunClean( true ) -{ -} - -ViewerColorPct::~ViewerColorPct() -{ -} - -void ViewerColorPct::beginCommand( Action::eAction nAct, const std::string &sTarget ) -{ - Cmd cmd; - if( sCmd.empty() ) - cmd.nLevel = 0; - else - cmd.nLevel = sCmd.front().nLevel+1; - - cmd.bCmdClean = true; - cmd.sTarget = sTarget; - - sCmd.push_front( cmd ); -} - -void ViewerColorPct::endCommand() -{ - if( sCmd.front().bCmdClean == false ) - printf("\n"); - sCmd.pop_front(); - if(sCmd.empty()) - iCC++; -} - -void ViewerColorPct::indent() -{ - if( sCmd.empty() ) return; - int jmax = sCmd.front().nLevel; - for( int j = 0; j < jmax; j++ ) - { - printf(" "); - } -} - -void ViewerColorPct::printHead() -{ - if( sCmd.front().bCmdClean == true ) - { - bRunClean = false; - sCmd.front().bCmdClean = false; - indent(); - if(sCmd.size() > 1) - printf("\033[37;22m--- \033[36m%s\033[37m ---\033[0m\n", sCmd.front().sTarget.c_str() ); - else - printf("\033[37;1m--- [\033[32m%d/%d\033[37m] \033[36m%s\033[37m ---\033[0m\n", iCC, iTC, sCmd.front().sTarget.c_str() ); - } -} - -void ViewerColorPct::printPerform(const char *sRule, const char *sTarget) -{ - int iPct = (int)round( - ((double)sCmd.front().iCP/(double)sCmd.front().iTP)*100.0 - ); - if(sCmd.size() > 1) - printf( "\033[37;22m[\033[32m%3d%%\033[37m] \033[35m%8s\033[37m: %s\033[0m\n", iPct, sRule, sTarget ); - else - printf( "\033[37;1m[\033[32m%3d%%\033[37m] \033[35m%8s\033[37m: %s\033[0m\n", iPct, sRule, sTarget ); -} - -void ViewerColorPct::beginRequiresCheck( bool bCached, const std::string &sName ) -{ - printHead(); - indent(); - printPerform("deps", sName.c_str()); -} - -void ViewerColorPct::endRequiresCheck() -{ - sCmd.front().iCP++; -} - -void ViewerColorPct::skipRequiresCheck( bool bCached, const std::string &sName ) -{ - sCmd.front().iCP++; -} - -void ViewerColorPct::beginPerform( Perform *pPerform ) -{ - printHead(); - indent(); - printPerform(pPerform->getRule().c_str(), pPerform->getTarget().c_str()); -} - -void ViewerColorPct::endPerform() -{ - sCmd.front().iCP++; -} - -void ViewerColorPct::skipPerform( Perform *pPerform ) -{ - sCmd.front().iCP++; -} - -void ViewerColorPct::beginPerforms( int nCount ) -{ - sCmd.front().iTP = nCount*2; - sCmd.front().iCP = 1; -} - -void ViewerColorPct::beginAction( const std::string &sName, int nCommands ) -{ - iTC = nCommands; - iCC = 1; -} - -void ViewerColorPct::endAction() -{ - if( bRunClean == true ) - { - printf("Nothing to be done.\n\n"); - } - printf("\033[0m"); -} - diff --git a/src/viewercolorpct.h b/src/viewercolorpct.h deleted file mode 100644 index dc810c1..0000000 --- a/src/viewercolorpct.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef VIEWER_COLOR_PCT_H -#define VIEWER_COLOR_PCT_H - -#include -#include -#include "viewer.h" - -class ViewerColorPct : public Viewer -{ -public: - ViewerColorPct(); - virtual ~ViewerColorPct(); - - virtual void beginCommand( Action::eAction nAct, const std::string &sTarget ); - virtual void endCommand(); - - virtual void beginRequiresCheck( bool bCached, const std::string &sName ); - virtual void endRequiresCheck(); - virtual void beginPerform( Perform *pPerform ); - virtual void endPerform(); - virtual void beginPerforms( int nCount ); - - virtual void skipRequiresCheck( bool bCached, const std::string &sName ); - virtual void skipPerform( Perform *pPerform ); - - virtual void beginAction( const std::string &sName, int nCommands ); - - virtual void endAction(); - - void printPerform(const char *sRule, const char *sTarget); - void printHead(); - void indent(); - -private: - int iTC, iCC; - - bool bRunClean; - typedef struct - { - int nLevel; - bool bCmdClean; - std::string sTarget; - int iTP, iCP; - } Cmd; - typedef std::list CmdStack; - CmdStack sCmd; -}; - -#endif diff --git a/src/viewerfactory.cpp b/src/viewerfactory.cpp deleted file mode 100644 index 5726e56..0000000 --- a/src/viewerfactory.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "viewerfactory.h" - -extern struct Bu::PluginInfo plain; -extern struct Bu::PluginInfo percent; -extern struct Bu::PluginInfo make; -extern struct Bu::PluginInfo plainpct; -extern struct Bu::PluginInfo colorpct; - -ViewerFactory::ViewerFactory() -{ - registerBuiltinPlugin( &plain ); - registerBuiltinPlugin( &percent ); - registerBuiltinPlugin( &make ); - registerBuiltinPlugin( &plainpct ); - registerBuiltinPlugin( &colorpct ); -} - -ViewerFactory::~ViewerFactory() -{ -} diff --git a/src/viewerfactory.h b/src/viewerfactory.h deleted file mode 100644 index ffa5b31..0000000 --- a/src/viewerfactory.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef VIEWER_FACTORY_H -#define VIEWER_FACTORY_H - -#include - -#include "viewer.h" -#include "bu/plugger.h" -#include "bu/singleton.h" - -class ViewerFactory : public Bu::Plugger, public Bu::Singleton -{ -public: - ViewerFactory(); - virtual ~ViewerFactory(); - -private: - -}; - -#endif diff --git a/src/viewermake.cpp b/src/viewermake.cpp deleted file mode 100644 index ed11b5f..0000000 --- a/src/viewermake.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "viewermake.h" -#include "perform.h" -#include "bu/plugger.h" - -PluginInterface2( make, ViewerMake, Viewer, "Mike Buland", 0, 1 ); - -ViewerMake::ViewerMake() -{ -} - -ViewerMake::~ViewerMake() -{ -} - -void ViewerMake::executeCmd( const std::string &sCmd ) -{ - printf("%s\n", sCmd.c_str() ); -} - diff --git a/src/viewermake.h b/src/viewermake.h deleted file mode 100644 index 11b8741..0000000 --- a/src/viewermake.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef VIEWER_MAKE_H -#define VIEWER_MAKE_H - -#include - -#include "viewer.h" - -class ViewerMake : public Viewer -{ -public: - ViewerMake(); - virtual ~ViewerMake(); - - virtual void executeCmd( const std::string &sCmd ); - -private: - -}; - -#endif diff --git a/src/viewerpercent.cpp b/src/viewerpercent.cpp deleted file mode 100644 index baca82a..0000000 --- a/src/viewerpercent.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include "viewerpercent.h" -#include "perform.h" -#include "bu/plugger.h" - -#include -#include -#include - -PluginInterface2( percent, ViewerPercent, Viewer, "Mike Buland", 0, 1 ); - -ViewerPercent::ViewerPercent() : - nWidth( 15 ) -{ -} - -ViewerPercent::~ViewerPercent() -{ -} - -void ViewerPercent::beginAction( const std::string &sName, int nCommands ) -{ - nTotalCommands = nCommands; - nCurCommand = 0; -} - -void ViewerPercent::endAction() -{ -} - -void ViewerPercent::beginCommand( Action::eAction nAct, const std::string &sTarget ) -{ - this->sTarget = sTarget; - nCurCommand++; - - struct winsize scrn; - - ioctl( fileno( stdout ), TIOCGWINSZ, &scrn ); - - nTermWidth = scrn.ws_col; -} - -void ViewerPercent::endCommand() -{ - printf("\n"); - fflush(stdout); -} - -void ViewerPercent::beginPerforms( int nCount ) -{ - nTotalPerforms = nCount; - nCurPerform = 0; - nLastLen = 0; -} - -void ViewerPercent::endPerforms() -{ - nCurPerform = nTotalPerforms; - - printPercent(""); -} - -void ViewerPercent::beginRequiresCheck( bool bCached, const std::string &sName ) -{ -} - -void ViewerPercent::endRequiresCheck() -{ -} - -void ViewerPercent::beginPerform( Perform *pPerform ) -{ - nCurPerform++; - printPercent( pPerform->getTarget() ); -} - -void ViewerPercent::printPercent( const std::string &sCur ) -{ - char buf[2048]; - char *bi = buf; - int nLen = sprintf( buf, "\r[%d/%d] %s [", - nCurCommand, nTotalCommands, - sTarget.c_str() ); - bi += nLen; - int jmax = nCurPerform*nWidth/nTotalPerforms; - for( int j = 0; j < jmax; j++ ) - { - *bi = '#'; - bi++; - } - jmax = nWidth-jmax; - for( int j = 0; j < jmax; j++ ) - { - *bi = ' '; - bi++; - } - nLen += nWidth; - nLen += sprintf( bi, "] %-2d%% %s", - nCurPerform*100/nTotalPerforms, - sCur.c_str() ); - bi = buf + nLen; - if( (int)(bi - buf) >= nTermWidth ) - { - nLastLen = nLen = nTermWidth; - strcpy( buf+nTermWidth-3, "..."); - } - else - { - if( nLastLen > nLen ) - { - jmax = nLastLen-nLen; - for( int j = 0; j < jmax; j++ ) - { - *bi = ' '; - bi++; - } - } - nLastLen = nLen; - *bi = '\0'; - } - - fputs( buf, stdout ); - - fflush( stdout ); -} - -void ViewerPercent::endPerform() -{ -} - diff --git a/src/viewerpercent.h b/src/viewerpercent.h deleted file mode 100644 index d40ca1b..0000000 --- a/src/viewerpercent.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef VIEWER_PERCENT_H -#define VIEWER_PERCENT_H - -#include - -#include "viewer.h" - -class ViewerPercent : public Viewer -{ -public: - ViewerPercent(); - virtual ~ViewerPercent(); - - virtual void beginCommand( Action::eAction nAct, const std::string &sTarget ); - virtual void endCommand(); - - virtual void beginRequiresCheck( bool bCached, const std::string &sName ); - virtual void endRequiresCheck(); - virtual void beginPerform( Perform *pPerform ); - virtual void endPerform(); - virtual void beginPerforms( int nCount ); - virtual void endPerforms(); - virtual void beginAction( const std::string &sName, int nCommands ); - virtual void endAction(); - - void printPercent( const std::string &sCur ); - -private: - int nTotalCommands; - int nCurCommand; - int nTotalPerforms; - int nCurPerform; - std::string sTarget; - int nLastLen; - int nWidth; - int nTermWidth; -}; - -#endif diff --git a/src/viewerplain.cpp b/src/viewerplain.cpp deleted file mode 100644 index 3e65f21..0000000 --- a/src/viewerplain.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "viewerplain.h" -#include "perform.h" -#include "bu/plugger.h" - -PluginInterface2( plain, ViewerPlain, Viewer, "Mike Buland", 0, 1 ); - -ViewerPlain::ViewerPlain() : - bRunClean( true ) -{ -} - -ViewerPlain::~ViewerPlain() -{ -} - -void ViewerPlain::beginCommand( Action::eAction nAct, const std::string &sTarget ) -{ - Cmd cmd; - if( sCmd.empty() ) - cmd.nLevel = 0; - else - cmd.nLevel = sCmd.front().nLevel+1; - - cmd.bCmdClean = true; - cmd.sTarget = sTarget; - - sCmd.push_front( cmd ); -} - -void ViewerPlain::endCommand() -{ - if( sCmd.front().bCmdClean == false ) - printf("\n"); - sCmd.pop_front(); -} - -void ViewerPlain::indent() -{ - if( sCmd.empty() ) return; - int jmax = sCmd.front().nLevel; - for( int j = 0; j < jmax; j++ ) - { - printf(" "); - } -} - -void ViewerPlain::printHead() -{ - if( sCmd.front().bCmdClean == true ) - { - bRunClean = false; - sCmd.front().bCmdClean = false; - indent(); - printf("--- %s ---\n", sCmd.front().sTarget.c_str() ); - } -} - -void ViewerPlain::beginRequiresCheck( bool bCached, const std::string &sName ) -{ - printHead(); - indent(); - printf(" deps: %s\n", sName.c_str() ); -} - -void ViewerPlain::endRequiresCheck() -{ -} - -void ViewerPlain::beginPerform( Perform *pPerform ) -{ - printHead(); - indent(); - printf(" %8s: %s\n", pPerform->getRule().c_str(), pPerform->getTarget().c_str() ); -} - -void ViewerPlain::endPerform() -{ -} - -void ViewerPlain::endAction() -{ - if( bRunClean == true ) - { - printf("Nothing to be done.\n\n"); - } -} - diff --git a/src/viewerplain.h b/src/viewerplain.h deleted file mode 100644 index 118ae80..0000000 --- a/src/viewerplain.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef VIEWER_PLAIN_H -#define VIEWER_PLAIN_H - -#include -#include -#include "viewer.h" - -class ViewerPlain : public Viewer -{ -public: - ViewerPlain(); - virtual ~ViewerPlain(); - - virtual void beginCommand( Action::eAction nAct, const std::string &sTarget ); - virtual void endCommand(); - - virtual void beginRequiresCheck( bool bCached, const std::string &sName ); - virtual void endRequiresCheck(); - virtual void beginPerform( Perform *pPerform ); - virtual void endPerform(); - - virtual void endAction(); - - void printHead(); - void indent(); - -private: - bool bRunClean; - typedef struct - { - int nLevel; - bool bCmdClean; - std::string sTarget; - } Cmd; - typedef std::list CmdStack; - CmdStack sCmd; -}; - -#endif diff --git a/src/viewerplainpct.cpp b/src/viewerplainpct.cpp deleted file mode 100644 index 4d9fa7b..0000000 --- a/src/viewerplainpct.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "viewerplainpct.h" -#include "perform.h" -#include "bu/plugger.h" -#include "math.h" - -PluginInterface2( plainpct, ViewerPlainPct, Viewer, "Mike Buland", 0, 1 ); - -ViewerPlainPct::ViewerPlainPct() : - bRunClean( true ) -{ -} - -ViewerPlainPct::~ViewerPlainPct() -{ -} - -void ViewerPlainPct::beginCommand( Action::eAction nAct, const std::string &sTarget ) -{ - Cmd cmd; - if( sCmd.empty() ) - cmd.nLevel = 0; - else - cmd.nLevel = sCmd.front().nLevel+1; - - cmd.bCmdClean = true; - cmd.sTarget = sTarget; - - sCmd.push_front( cmd ); -} - -void ViewerPlainPct::endCommand() -{ - if( sCmd.front().bCmdClean == false ) - printf("\n"); - sCmd.pop_front(); - if(sCmd.empty()) - iCC++; -} - -void ViewerPlainPct::indent() -{ - if( sCmd.empty() ) return; - int jmax = sCmd.front().nLevel; - for( int j = 0; j < jmax; j++ ) - { - printf(" "); - } -} - -void ViewerPlainPct::printHead() -{ - if( sCmd.front().bCmdClean == true ) - { - bRunClean = false; - sCmd.front().bCmdClean = false; - indent(); - if(sCmd.size() > 1) - printf("--- %s ---\n", sCmd.front().sTarget.c_str() ); - else - printf("--- [%d/%d] %s ---\n", iCC, iTC, sCmd.front().sTarget.c_str() ); - } -} - -void ViewerPlainPct::printPerform(const char *sRule, const char *sTarget) -{ - int iPct = (int)round( - ((double)sCmd.front().iCP/(double)sCmd.front().iTP)*100.0 - ); - if(sCmd.size() > 1) - printf( "[%3d%%] %8s: %s\n", iPct, sRule, sTarget ); - else - printf( "[%3d%%] %8s: %s\n", iPct, sRule, sTarget ); -} - -void ViewerPlainPct::beginRequiresCheck( bool bCached, const std::string &sName ) -{ - printHead(); - indent(); - printPerform("deps", sName.c_str()); -} - -void ViewerPlainPct::endRequiresCheck() -{ - sCmd.front().iCP++; -} - -void ViewerPlainPct::skipRequiresCheck( bool bCached, const std::string &sName ) -{ - sCmd.front().iCP++; -} - -void ViewerPlainPct::beginPerform( Perform *pPerform ) -{ - printHead(); - indent(); - printPerform(pPerform->getRule().c_str(), pPerform->getTarget().c_str()); -} - -void ViewerPlainPct::endPerform() -{ - sCmd.front().iCP++; -} - -void ViewerPlainPct::skipPerform( Perform *pPerform ) -{ - sCmd.front().iCP++; -} - -void ViewerPlainPct::beginPerforms( int nCount ) -{ - sCmd.front().iTP = nCount*2; - sCmd.front().iCP = 1; -} - -void ViewerPlainPct::beginAction( const std::string &sName, int nCommands ) -{ - iTC = nCommands; - iCC = 1; -} - -void ViewerPlainPct::endAction() -{ - if( bRunClean == true ) - { - printf("Nothing to be done.\n\n"); - } -} - diff --git a/src/viewerplainpct.h b/src/viewerplainpct.h deleted file mode 100644 index 63bc00d..0000000 --- a/src/viewerplainpct.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef VIEWER_PLAIN_PCT_H -#define VIEWER_PLAIN_PCT_H - -#include -#include -#include "viewer.h" - -class ViewerPlainPct : public Viewer -{ -public: - ViewerPlainPct(); - virtual ~ViewerPlainPct(); - - virtual void beginCommand( Action::eAction nAct, const std::string &sTarget ); - virtual void endCommand(); - - virtual void beginRequiresCheck( bool bCached, const std::string &sName ); - virtual void endRequiresCheck(); - virtual void beginPerform( Perform *pPerform ); - virtual void endPerform(); - virtual void beginPerforms( int nCount ); - - virtual void skipRequiresCheck( bool bCached, const std::string &sName ); - virtual void skipPerform( Perform *pPerform ); - - virtual void beginAction( const std::string &sName, int nCommands ); - - virtual void endAction(); - - void printPerform(const char *sRule, const char *sTarget); - void printHead(); - void indent(); - -private: - int iTC, iCC; - - bool bRunClean; - typedef struct - { - int nLevel; - bool bCmdClean; - std::string sTarget; - int iTP, iCP; - } Cmd; - typedef std::list CmdStack; - CmdStack sCmd; -}; - -#endif -- cgit v1.2.3