14using namespace tooling;
15using namespace dependencies;
20 : Worker(Service,
std::move(FS)) {}
26 void handleBuildCommand(
Command)
override {}
30 this->Opts = std::make_unique<DependencyOutputOptions>(Opts);
33 void handleFileDependency(StringRef
File)
override {
34 Dependencies.push_back(std::string(
File));
41 void handleModuleDependency(
ModuleDeps MD)
override {
47 void handleContextHash(std::string Hash)
override {}
49 void printDependencies(std::string &S) {
50 assert(Opts &&
"Handled dependency output options.");
57 for (
const auto &Dep : Dependencies)
61 void printDependencies(std::string &S) {
62 llvm::raw_string_ostream
OS(S);
63 outputDependencyFile(
OS);
67 DependencyPrinter
Generator(*Opts, Dependencies);
72 std::unique_ptr<DependencyOutputOptions> Opts;
73 std::vector<std::string> Dependencies;
78 const std::vector<std::string> &CommandLine, StringRef CWD) {
79 MakeDependencyPrinterConsumer Consumer;
86 Consumer.printDependencies(Output);
92 std::string &MakeformatOutputPath) {
93 class P1689ModuleDependencyPrinterConsumer
94 :
public MakeDependencyPrinterConsumer {
96 P1689ModuleDependencyPrinterConsumer(
P1689Rule &Rule,
102 void handleProvidedAndRequiredStdCXXModules(
103 std::optional<P1689ModuleInfo> Provided,
104 std::vector<P1689ModuleInfo> Requires)
override {
111 StringRef getMakeFormatDependencyOutputPath() {
112 if (Opts->OutputFormat != DependencyOutputFormat::Make)
114 return Opts->OutputFile;
125 std::string lookupModuleOutput(
const ModuleID &,
132 P1689ModuleDependencyPrinterConsumer Consumer(Rule,
Command);
133 P1689ActionController Controller;
139 MakeformatOutputPath = Consumer.getMakeFormatDependencyOutputPath();
140 if (!MakeformatOutputPath.empty())
141 Consumer.printDependencies(MakeformatOutput);
147 const std::vector<std::string> &CommandLine, StringRef CWD,
148 const llvm::StringSet<> &AlreadySeen,
160 StringRef ModuleName,
const std::vector<std::string> &CommandLine,
161 StringRef CWD,
const llvm::StringSet<> &AlreadySeen,
166 Controller, ModuleName);
176 TU.
FileDeps = std::move(Dependencies);
180 for (
auto &&M : ClangModuleDeps) {
182 if (MD.ImportedByMainFile)
186 if (AlreadySeen.count(M.first))
197 for (
auto &&M : ClangModuleDeps) {
201 if (AlreadySeen.count(M.first))
203 ModuleGraph.push_back(std::move(MD));
Builds a dependency file when attached to a Preprocessor (for includes) and ASTReader (for module imp...
DependencyOutputOptions - Options for controlling the compiler dependency file generation.
@ Result
The result type of a method or function.