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 "clang/Basic/HeaderInclude.h"
13 #include <string>
14 #include <vector>
15 
16 namespace clang {
17 
18 /// ShowIncludesDestination - Destination for /showIncludes output.
19 enum class ShowIncludesDestination { None, Stdout, Stderr };
20 
21 /// DependencyOutputFormat - Format for the compiler dependency file.
22 enum class DependencyOutputFormat { Make, NMake };
23 
24 /// ExtraDepKind - The kind of extra dependency file.
25 enum ExtraDepKind {
26   EDK_SanitizeIgnorelist,
27   EDK_ProfileList,
28   EDK_ModuleFile,
29   EDK_DepFileEntry,
30 };
31 
32 /// DependencyOutputOptions - Options for controlling the compiler dependency
33 /// file generation.
34 class DependencyOutputOptions {
35 public:
36   unsigned IncludeSystemHeaders : 1; ///< Include system header dependencies.
37   unsigned ShowHeaderIncludes : 1;   ///< Show header inclusions (-H).
38   unsigned UsePhonyTargets : 1;      ///< Include phony targets for each
39                                      /// dependency, which can avoid some 'make'
40                                      /// problems.
41   unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency list
42   unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
43   unsigned ShowSkippedHeaderIncludes : 1; ///< With ShowHeaderIncludes, show
44                                           /// also includes that were skipped
45                                           /// due to the "include guard
46                                           /// optimization" or #pragma once.
47 
48   /// The format of header information.
49   HeaderIncludeFormatKind HeaderIncludeFormat = HIFMT_Textual;
50 
51   /// Determine whether header information should be filtered.
52   HeaderIncludeFilteringKind HeaderIncludeFiltering = HIFIL_None;
53 
54   /// Destination of cl.exe style /showIncludes info.
55   ShowIncludesDestination ShowIncludesDest = ShowIncludesDestination::None;
56 
57   /// The format for the dependency file.
58   DependencyOutputFormat OutputFormat = DependencyOutputFormat::Make;
59 
60   /// The file to write dependency output to.
61   std::string OutputFile;
62 
63   /// The file to write header include output to. This is orthogonal to
64   /// ShowHeaderIncludes (-H) and will include headers mentioned in the
65   /// predefines buffer. If the output file is "-", output will be sent to
66   /// stderr.
67   std::string HeaderIncludeOutputFile;
68 
69   /// A list of names to use as the targets in the dependency file; this list
70   /// must contain at least one entry.
71   std::vector<std::string> Targets;
72 
73   /// A list of extra dependencies (filename and kind) to be used for every
74   /// target.
75   std::vector<std::pair<std::string, ExtraDepKind>> ExtraDeps;
76 
77   /// In /showIncludes mode, pretend the main TU is a header with this name.
78   std::string ShowIncludesPretendHeader;
79 
80   /// The file to write GraphViz-formatted header dependencies to.
81   std::string DOTOutputFile;
82 
83   /// The directory to copy module dependencies to when collecting them.
84   std::string ModuleDependencyOutputDir;
85 
86 public:
87   DependencyOutputOptions()
88       : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
89         AddMissingHeaderDeps(0), IncludeModuleFiles(0),
90         ShowSkippedHeaderIncludes(0), HeaderIncludeFormat(HIFMT_Textual),
91         HeaderIncludeFiltering(HIFIL_None) {}
92 };
93 
94 }  // end namespace clang
95 
96 #endif
97