X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fanalyzer.h;h=5827480cdd913765a7353e73a97068d20b6f4f27;hb=d1f9551e05c9d341149eb490e05b1465d3d6b711;hp=6c7b9dc70790838ba681875ad000729530f60840;hpb=0d80cabf649b931b26e7055385156c75a7385d35;p=builder.git diff --git a/source/analyzer.h b/source/analyzer.h index 6c7b9dc..5827480 100644 --- a/source/analyzer.h +++ b/source/analyzer.h @@ -1,43 +1,58 @@ #ifndef ANALYZER_H_ #define ANALYZER_H_ -#include +#include +#include #include #include class Builder; class Target; +/** +Performs various kinds of dependency analysis on the build tree. +*/ class Analyzer { public: enum Mode { - DEPS, - ALLDEPS, - REBUILD, - RDEPS + DEPS, //< Skip over "trivial" targets such as InstalledFile + ALLDEPS, //< Print out absolutely every target + REBUILD, //< Print targets that are going to be rebuilt + RDEPS //< Print targets that depend on the given targets }; - Analyzer(Builder &); - void set_mode(Mode m) { mode=m; } - void set_max_depth(unsigned m) { max_depth=m; } - void set_full_paths(bool f) { full_paths=f; } - void analyze(); private: - typedef std::vector TableRow; - typedef std::list Table; + using TableRow = std::vector; + + Builder &builder; + Mode mode = DEPS; + std::vector table; + unsigned max_depth = 0; + bool full_paths = false; + std::map > rdepends; + +public: + Analyzer(Builder &); + + void set_mode(Mode m) { mode = m; } + void set_max_depth(unsigned m) { max_depth = m; } + void set_full_paths(bool f) { full_paths = f; } - Builder &builder; - Mode mode; - Table table; - unsigned max_depth; - bool full_paths; + /// Performs the analysis and prints out the resulting dependency tree. + void analyze(); +private: + /** Adds rows for a target, then recursively adds rows for dependencies as + needed. */ void build_depend_table(Target &, unsigned); + + /// Prints out the table that resulted from the analysis. void print_table() const; - static bool target_order(Target *, Target *); + static bool target_order(const Target *, const Target *); + static bool target_order_full(const Target *, const Target *); }; #endif