1 //===--- DependencyOutputOptions.h ------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_FRONTEND_DEPENDENCYOUTPUTOPTIONS_H
10 #define LLVM_CLANG_FRONTEND_DEPENDENCYOUTPUTOPTIONS_H
11 
12 #include <string>
13 #include <vector>
14 
15 namespace clang {
16 
17 /// ShowIncludesDestination - Destination for /showIncludes output.
18 enum class ShowIncludesDestination { None, Stdout, Stderr };
19 
20 /// DependencyOutputFormat - Format for the compiler dependency file.
21 enum class DependencyOutputFormat { Make, NMake };
22 
23 /// ExtraDepKind - The kind of extra dependency file.
24 enum ExtraDepKind {
25   EDK_SanitizeIgnorelist,
26   EDK_ProfileList,
27   EDK_ModuleFile,
28   EDK_DepFileEntry,
29 };
30 
31 /// DependencyOutputOptions - Options for controlling the compiler dependency
32 /// file generation.
33 class DependencyOutputOptions {
34 public:
35   unsigned IncludeSystemHeaders : 1; ///< Include system header dependencies.
36   unsigned ShowHeaderIncludes : 1;   ///< Show header inclusions (-H).
37   unsigned UsePhonyTargets : 1;      ///< Include phony targets for each
38                                      /// dependency, which can avoid some 'make'
39                                      /// problems.
40   unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency list
41   unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
42   unsigned ShowSkippedHeaderIncludes : 1; ///< With ShowHeaderIncludes, show
43                                           /// also includes that were skipped
44                                           /// due to the "include guard
45                                           /// optimization" or #pragma once.
46 
47   /// Destination of cl.exe style /showIncludes info.
48   ShowIncludesDestination ShowIncludesDest = ShowIncludesDestination::None;
49 
50   /// The format for the dependency file.
51   DependencyOutputFormat OutputFormat = DependencyOutputFormat::Make;
52 
53   /// The file to write dependency output to.
54   std::string OutputFile;
55 
56   /// The file to write header include output to. This is orthogonal to
57   /// ShowHeaderIncludes (-H) and will include headers mentioned in the
58   /// predefines buffer. If the output file is "-", output will be sent to
59   /// stderr.
60   std::string HeaderIncludeOutputFile;
61 
62   /// A list of names to use as the targets in the dependency file; this list
63   /// must contain at least one entry.
64   std::vector<std::string> Targets;
65 
66   /// A list of extra dependencies (filename and kind) to be used for every
67   /// target.
68   std::vector<std::pair<std::string, ExtraDepKind>> ExtraDeps;
69 
70   /// In /showIncludes mode, pretend the main TU is a header with this name.
71   std::string ShowIncludesPretendHeader;
72 
73   /// The file to write GraphViz-formatted header dependencies to.
74   std::string DOTOutputFile;
75 
76   /// The directory to copy module dependencies to when collecting them.
77   std::string ModuleDependencyOutputDir;
78 
79 public:
80   DependencyOutputOptions()
81       : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
82         AddMissingHeaderDeps(0), IncludeModuleFiles(0),
83         ShowSkippedHeaderIncludes(0) {}
84 };
85 
86 }  // end namespace clang
87 
88 #endif
89