aboutsummaryrefslogtreecommitdiff
path: root/src/build.h
blob: d5e6604690ccd024a1fd22d264425a91ee939afe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef BUILD_H
#define BUILD_H

#include <stdint.h>

#include <map>
#include <string>

#include "exceptions.h"
#include "rule.h"
#include "target.h"
#include "action.h"
#include "stringproc.h"

subExceptionDecl( BuildException );

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 );

	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 );
	std::string getVar( const std::string &cont, const std::string &var );

	Rule *getRule( const std::string &name );

	void debugDump();

	void setStringProc( StringProc *pStrProc );
	std::string replVars( const std::string &sSrc, const std::string &sCont );

private:
	typedef std::map<std::string, Target *> TargetMap;
	typedef std::list<std::string> StringList;
	typedef std::map<std::string, StringList> ReqMap;
	typedef std::map<std::string, std::string> VarMap;
	typedef std::map<std::string, VarMap> ContextMap;
	typedef std::map<std::string, Rule *> RuleMap;
	typedef std::map<std::string, Action *> ActionMap;

	TargetMap mTarget;
	ReqMap mRequires;
	VarMap mVars;
	ContextMap mContVars;
	RuleMap mRule;
	ActionMap mAction;
	StringProc *pStrProc;

	//std::map<std::string, Rule *> mRule;
	//Action *pActDefault;
	//std::map<std::string, Action *> mAction;

};

#endif