// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef TOOLS_GN_ANALYZER_H_ #define TOOLS_GN_ANALYZER_H_ #include #include #include #include "tools/gn/builder.h" #include "tools/gn/item.h" #include "tools/gn/label.h" #include "tools/gn/source_file.h" // An Analyzer can answer questions about a build graph. It is used // to answer queries for the `refs` and `analyze` commands, where we // need to look at the graph in ways that can't easily be determined // from just a single Target. class Analyzer { public: Analyzer(const Builder& builder, const SourceFile& build_config_file, const SourceFile& dot_file, const std::set& build_args_dependency_files); ~Analyzer(); // Figures out from a Buider and a JSON-formatted string containing lists // of files and targets, which targets would be affected by modifications // to the files . See the help text for the analyze command (kAnalyze_Help) // for the specification of the input and output string formats and the // expected behavior of the method. std::string Analyze(const std::string& input, Err* err) const; private: // Returns the set of all items that might be affected, directly or // indirectly, by modifications to the given source files. std::set GetAllAffectedItems( const std::set& source_files) const; // Returns the set of labels that do not refer to objects in the graph. std::set