]> git.tdb.fi Git - builder.git/blob - source/analyzer.h
Style update: add spaces around assignment operators
[builder.git] / source / analyzer.h
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2006-2007, 2009  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef ANALYZER_H_
9 #define ANALYZER_H_
10
11 #include <list>
12 #include <string>
13 #include <vector>
14
15 class Builder;
16 class Target;
17
18 /**
19 Performs various kinds of dependency analysis on the build tree.
20 */
21 class Analyzer
22 {
23 public:
24         enum Mode
25         {
26                 DEPS,     //< Skip over "trivial" targets such as Install and Compile
27                 ALLDEPS,  //< Print out absolutely every target
28                 REBUILD,  //< Print targets that are going to be rebuilt
29                 RDEPS     //< Print targets that depend on the given targets (NYI)
30         };
31
32 private:
33         typedef std::vector<std::string> TableRow;
34         typedef std::list<TableRow> Table;
35
36         Builder &builder;
37         Mode mode;
38         Table table;
39         unsigned max_depth;
40         bool full_paths;
41
42 public:
43         Analyzer(Builder &);
44         void set_mode(Mode m) { mode = m; }
45         void set_max_depth(unsigned m) { max_depth = m; }
46         void set_full_paths(bool f) { full_paths = f; }
47
48         /**
49         Performs the analysis and prints out the resulting dependency tree.
50         */
51         void analyze();
52
53 private:
54         /**
55         Adds rows to the table for the given target and its dependencies.
56         */
57         void build_depend_table(Target &, unsigned);
58
59         /**
60         Prints out the table that resulted from the analysis.
61         */
62         void print_table() const;
63
64         static bool target_order(Target *, Target *);
65 };
66
67 #endif