From d2fe7edb2bfea20987a1f69935179fa5fc9f3b37 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 23 Aug 2006 22:09:30 +0000 Subject: Really close...functions are doing their stuff, we have inputs, almost have rules. --- src/build.cpp | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) (limited to 'src/build.cpp') diff --git a/src/build.cpp b/src/build.cpp index d9a8b39..ec97ccb 100644 --- a/src/build.cpp +++ b/src/build.cpp @@ -29,6 +29,62 @@ 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; +} + +void Build::set( const std::string &cont, const std::string &var, const std::string &val ) +{ + if( cont == "" ) + { + mVars[var] = val; + } + else + { + mContVars[cont][var] = val; + } +} + +void Build::setAdd( const std::string &cont, const std::string &var, const std::string &val ) +{ + if( cont == "" ) + { + mVars[var] = getVar( cont, var ) + " " + val; + } + else + { + mContVars[cont][var] = getVar( cont, var ) + " " + val; + } +} + +std::string Build::getVar( const std::string &cont, const std::string &var ) +{ + if( cont == "" ) + { + 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( mContVars[cont].find(var) == mContVars[cont].end() ) + { + mContVars[cont][var] = getVar( "", var ); + } + return mContVars[cont][var]; + } +} + void Build::debugDump() { printf("Requires:\n"); @@ -45,5 +101,42 @@ void Build::debugDump() } 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() + ); + } + } } -- cgit v1.2.3