diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-12-21 18:04:02 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-12-21 18:04:02 +0000 |
commit | fb28f6800864176be2ffca29e8e664b641f33170 (patch) | |
tree | ba9180ac442939edc4eacbe1fdae93c5a7f87cee /src/context.h | |
parent | 51e21a316be6e052251b3dfc7d671061ebd67cee (diff) | |
download | build-fb28f6800864176be2ffca29e8e664b641f33170.tar.gz build-fb28f6800864176be2ffca29e8e664b641f33170.tar.bz2 build-fb28f6800864176be2ffca29e8e664b641f33170.tar.xz build-fb28f6800864176be2ffca29e8e664b641f33170.zip |
m3 is copied into trunk, we should be good to go, now.
Diffstat (limited to '')
-rw-r--r-- | src/context.h | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/context.h b/src/context.h new file mode 100644 index 0000000..0d9aaff --- /dev/null +++ b/src/context.h | |||
@@ -0,0 +1,101 @@ | |||
1 | #ifndef CONTEXT_H | ||
2 | #define CONTEXT_H | ||
3 | |||
4 | #include "bu/hash.h" | ||
5 | #include "bu/fstring.h" | ||
6 | |||
7 | #include "variable.h" | ||
8 | |||
9 | class Target; | ||
10 | class Rule; | ||
11 | class Function; | ||
12 | class Action; | ||
13 | class View; | ||
14 | |||
15 | class Context | ||
16 | { | ||
17 | friend Bu::Formatter &operator<<( Bu::Formatter &f, const Context &c ); | ||
18 | public: | ||
19 | Context(); | ||
20 | virtual ~Context(); | ||
21 | |||
22 | void addTarget( Target *pTarget ); | ||
23 | void addRule( Rule *pRule ); | ||
24 | void addFunction( Function *pFunction ); | ||
25 | void addVariable( const Bu::FString &sName, const Variable &vValue ); | ||
26 | void addAction( Action *pAction ); | ||
27 | Action *getAction( const Bu::FString &sName ); | ||
28 | |||
29 | void addTargetToTag( Target *pTarget, const Bu::FString &sTag ); | ||
30 | void addTargetToTags( Target *pTarget, const StrList &sTags ); | ||
31 | TargetList &getTag( const Bu::FString &sTag ); | ||
32 | |||
33 | Variable &getVariable( const Bu::FString &sName ); | ||
34 | void delVariable( const Bu::FString &sName ); | ||
35 | |||
36 | void pushScope(); | ||
37 | void pushScope( const VarHash &hNewVars ); | ||
38 | VarHash &getScope(); | ||
39 | void popScope(); | ||
40 | |||
41 | Variable call( const Bu::FString &sName, Variable &input, VarList lParams ); | ||
42 | |||
43 | Bu::FString expand( const Bu::FString &sIn ); | ||
44 | |||
45 | Target *getTarget( const Bu::FString &sOutput ); | ||
46 | TargetList getExplicitTargets(); | ||
47 | |||
48 | /** | ||
49 | * This function actually builds the dependancy tree, and is responsible | ||
50 | * for creating all of the auto-generated targets that are required by the | ||
51 | * explicitly created targets. | ||
52 | */ | ||
53 | void buildTargetTree( class Runner &r ); | ||
54 | |||
55 | /** | ||
56 | * This is done as a final step, it goes through all targets and | ||
57 | * attaches things that they should have even if they haven't defined them, | ||
58 | * like a clean profile, they'll get that even if they haven't added one of | ||
59 | * their own. The defaults in this routine are added only if they aren't | ||
60 | * already defined in the target. It should be excetued after | ||
61 | * buildTargetTree, which means it doesn't need to affect rules. | ||
62 | */ | ||
63 | void attachDefaults(); | ||
64 | |||
65 | /** | ||
66 | * This function generates some default actions if they don't already | ||
67 | * exist, pretty straight forward, it will create all, clean, and default | ||
68 | * (default is the same as all). | ||
69 | */ | ||
70 | void genDefaultActions(); | ||
71 | |||
72 | void writeTargetDot(); | ||
73 | |||
74 | void setView( View *pNewView ); | ||
75 | View *getView(); | ||
76 | |||
77 | void printBasicInfo(); | ||
78 | |||
79 | private: | ||
80 | void buildTargetTree( class Runner &r, class Target *pTarget, const Bu::FString &sInput, class Rule *pMaster, StrList &lNewIns ); | ||
81 | |||
82 | private: | ||
83 | typedef Bu::Hash<Bu::FString, Target *> TargetHash; | ||
84 | typedef Bu::Hash<Bu::FString, Rule *> RuleHash; | ||
85 | typedef Bu::Hash<Bu::FString, Function *> FunctionHash; | ||
86 | typedef Bu::Hash<Bu::FString, Action *> ActionHash; | ||
87 | typedef Bu::List<VarHash> ScopeStack; | ||
88 | typedef Bu::Hash<Bu::FString, TargetList> TagHash; | ||
89 | |||
90 | TargetHash hTarget; | ||
91 | RuleHash hRule; | ||
92 | FunctionHash hFunction; | ||
93 | ScopeStack sVars; | ||
94 | ActionHash hAction; | ||
95 | TagHash hTag; | ||
96 | View *pView; | ||
97 | }; | ||
98 | |||
99 | Bu::Formatter &operator<<( Bu::Formatter &f, const Context &c ); | ||
100 | |||
101 | #endif | ||