diff options
author | Mike Buland <eichlan@xagasoft.com> | 2006-08-23 22:09:30 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2006-08-23 22:09:30 +0000 |
commit | d2fe7edb2bfea20987a1f69935179fa5fc9f3b37 (patch) | |
tree | ee35479f264788bf43b7904f31a528699b53e955 /src/build.cpp | |
parent | 7a7390337e04d0163b97c1da7bdaa198bacaff72 (diff) | |
download | build-d2fe7edb2bfea20987a1f69935179fa5fc9f3b37.tar.gz build-d2fe7edb2bfea20987a1f69935179fa5fc9f3b37.tar.bz2 build-d2fe7edb2bfea20987a1f69935179fa5fc9f3b37.tar.xz build-d2fe7edb2bfea20987a1f69935179fa5fc9f3b37.zip |
Really close...functions are doing their stuff, we have inputs, almost have rules.
Diffstat (limited to '')
-rw-r--r-- | src/build.cpp | 93 |
1 files changed, 93 insertions, 0 deletions
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 ) | |||
29 | mRequires[who].push_back( what ); | 29 | mRequires[who].push_back( what ); |
30 | } | 30 | } |
31 | 31 | ||
32 | void Build::addRule( Rule *pRule ) | ||
33 | { | ||
34 | mRule[pRule->getName()] = pRule; | ||
35 | } | ||
36 | |||
37 | void Build::set( const std::string &cont, const std::string &var, const std::string &val ) | ||
38 | { | ||
39 | if( cont == "" ) | ||
40 | { | ||
41 | mVars[var] = val; | ||
42 | } | ||
43 | else | ||
44 | { | ||
45 | mContVars[cont][var] = val; | ||
46 | } | ||
47 | } | ||
48 | |||
49 | void Build::setAdd( const std::string &cont, const std::string &var, const std::string &val ) | ||
50 | { | ||
51 | if( cont == "" ) | ||
52 | { | ||
53 | mVars[var] = getVar( cont, var ) + " " + val; | ||
54 | } | ||
55 | else | ||
56 | { | ||
57 | mContVars[cont][var] = getVar( cont, var ) + " " + val; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | std::string Build::getVar( const std::string &cont, const std::string &var ) | ||
62 | { | ||
63 | if( cont == "" ) | ||
64 | { | ||
65 | if( mVars.find(var) == mVars.end() ) | ||
66 | { | ||
67 | if( getenv( var.c_str() ) == NULL ) | ||
68 | { | ||
69 | mVars[var] = ""; | ||
70 | } | ||
71 | else | ||
72 | { | ||
73 | mVars[var] = getenv( var.c_str() ); | ||
74 | } | ||
75 | } | ||
76 | return mVars[var]; | ||
77 | } | ||
78 | else | ||
79 | { | ||
80 | if( mContVars[cont].find(var) == mContVars[cont].end() ) | ||
81 | { | ||
82 | mContVars[cont][var] = getVar( "", var ); | ||
83 | } | ||
84 | return mContVars[cont][var]; | ||
85 | } | ||
86 | } | ||
87 | |||
32 | void Build::debugDump() | 88 | void Build::debugDump() |
33 | { | 89 | { |
34 | printf("Requires:\n"); | 90 | printf("Requires:\n"); |
@@ -45,5 +101,42 @@ void Build::debugDump() | |||
45 | } | 101 | } |
46 | printf("\n"); | 102 | printf("\n"); |
47 | } | 103 | } |
104 | |||
105 | printf("Targets:\n"); | ||
106 | for( TargetMap::iterator i = mTarget.begin(); i != mTarget.end(); i++ ) | ||
107 | { | ||
108 | printf(" %s:\n", (*i).first.c_str() ); | ||
109 | printf(" Rule: %s\n", (*i).second->getRule().c_str() ); | ||
110 | printf(" Input: "); | ||
111 | for( StringList::iterator j = (*i).second->getInput().begin(); | ||
112 | j != (*i).second->getInput().end(); j++ ) | ||
113 | { | ||
114 | if( j != (*i).second->getInput().begin() ) | ||
115 | printf(", "); | ||
116 | printf("%s", (*j).c_str() ); | ||
117 | } | ||
118 | printf("\n"); | ||
119 | } | ||
120 | |||
121 | printf("Global Variables:\n"); | ||
122 | for( VarMap::iterator i = mVars.begin(); i != mVars.end(); i++ ) | ||
123 | { | ||
124 | printf(" \"%s\" = \"%s\"\n", (*i).first.c_str(), (*i).second.c_str() ); | ||
125 | } | ||
126 | |||
127 | printf("Context Variables:\n"); | ||
128 | for( ContextMap::iterator i = mContVars.begin(); i != mContVars.end(); i++ ) | ||
129 | { | ||
130 | printf(" %s:\n", (*i).first.c_str() ); | ||
131 | |||
132 | for( VarMap::iterator j = (*i).second.begin(); | ||
133 | j != (*i).second.end(); j++ ) | ||
134 | { | ||
135 | printf(" \"%s\" = \"%s\"\n", | ||
136 | (*j).first.c_str(), | ||
137 | (*j).second.c_str() | ||
138 | ); | ||
139 | } | ||
140 | } | ||
48 | } | 141 | } |
49 | 142 | ||