X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fanalyzer.h;h=d30de049bab557ed7c0195be8a9471b4d378f9ff;hb=c8c51fac9453a677fc3e6932c4730f35e237af89;hp=b4ffd8b65d0aabc7b2beb04273e896e7c583ba0a;hpb=7aeaa4ba965f596edad438c02e345a8843f7469a;p=builder.git diff --git a/source/analyzer.h b/source/analyzer.h index b4ffd8b..d30de04 100644 --- a/source/analyzer.h +++ b/source/analyzer.h @@ -1,14 +1,8 @@ -/* $Id$ - -This file is part of builder -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef ANALYZER_H_ #define ANALYZER_H_ -#include +#include +#include #include #include @@ -23,31 +17,42 @@ class Analyzer public: enum Mode { - DEPS, /// Skip over "trivial" targets such as Install and Compile - ALLDEPS, /// Print out absolutely every target - REBUILD, /// Print targets that are going to be rebuilt - RDEPS /// Print targets that depend on the given targets (NYI) + 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; - Builder &builder; - Mode mode; - Table table; - unsigned max_depth; - bool full_paths; +public: + Analyzer(Builder &b): builder(b) { } + 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; } + + /// 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