OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef TOOLS_GN_NINJA_BINARY_TARGET_WRITER_H_ | 5 #ifndef TOOLS_GN_NINJA_BINARY_TARGET_WRITER_H_ |
6 #define TOOLS_GN_NINJA_BINARY_TARGET_WRITER_H_ | 6 #define TOOLS_GN_NINJA_BINARY_TARGET_WRITER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "tools/gn/config_values.h" | 9 #include "tools/gn/config_values.h" |
10 #include "tools/gn/ninja_target_writer.h" | 10 #include "tools/gn/ninja_target_writer.h" |
11 #include "tools/gn/toolchain.h" | 11 #include "tools/gn/toolchain.h" |
12 #include "tools/gn/unique_vector.h" | 12 #include "tools/gn/unique_vector.h" |
13 | 13 |
14 struct EscapeOptions; | 14 struct EscapeOptions; |
| 15 class SourceFileTypeSet; |
15 | 16 |
16 // Writes a .ninja file for a binary target type (an executable, a shared | 17 // Writes a .ninja file for a binary target type (an executable, a shared |
17 // library, or a static library). | 18 // library, or a static library). |
18 class NinjaBinaryTargetWriter : public NinjaTargetWriter { | 19 class NinjaBinaryTargetWriter : public NinjaTargetWriter { |
19 public: | 20 public: |
20 NinjaBinaryTargetWriter(const Target* target, std::ostream& out); | 21 NinjaBinaryTargetWriter(const Target* target, std::ostream& out); |
21 ~NinjaBinaryTargetWriter() override; | 22 ~NinjaBinaryTargetWriter() override; |
22 | 23 |
23 void Run() override; | 24 void Run() override; |
24 | 25 |
25 private: | 26 private: |
26 typedef std::set<OutputFile> OutputFileSet; | 27 typedef std::set<OutputFile> OutputFileSet; |
| 28 class SourceFileTypeSet; |
27 | 29 |
28 void WriteCompilerVars(); | 30 // Writes all flags for the compiler: includes, defines, cflags, etc. |
29 void WriteSources(std::vector<OutputFile>* object_files, | 31 // Any .pch files this function generates references to will be appended to |
| 32 // the *pch_files vector. |
| 33 void WriteCompilerVars(const SourceFileTypeSet& used_types); |
| 34 void WriteOneFlag( |
| 35 SubstitutionType subst_enum, |
| 36 const std::vector<std::string>& (ConfigValues::* getter)() const, |
| 37 EscapeOptions flag_escape_options); |
| 38 |
| 39 void WritePrecompiledHeaderCommands(const SourceFileTypeSet& used_types, |
| 40 const OutputFile& input_dep, |
| 41 std::vector<OutputFile>* object_files); |
| 42 void WritePrecompiledHeaderCommand(SubstitutionType flag_type, |
| 43 Toolchain::ToolType tool_type, |
| 44 const OutputFile& input_dep, |
| 45 std::vector<OutputFile>* object_files); |
| 46 |
| 47 // extra_deps are additional dependencies to run before the rule. |
| 48 // |
| 49 // iorder_only_dep is the name of the stamp file that covers the dependencies |
| 50 // that must be run before doing any compiles. |
| 51 // |
| 52 // The files produced by the compiler will be added to two output vectors. |
| 53 void WriteSources(const std::vector<OutputFile>& extra_deps, |
| 54 const OutputFile& order_only_dep, |
| 55 std::vector<OutputFile>* object_files, |
30 std::vector<SourceFile>* other_files); | 56 std::vector<SourceFile>* other_files); |
| 57 |
| 58 // Writes a build line. |
| 59 void WriteCompilerBuildLine(const SourceFile& source, |
| 60 const std::vector<OutputFile>& extra_deps, |
| 61 const OutputFile& order_only_dep, |
| 62 Toolchain::ToolType tool_type, |
| 63 const std::vector<OutputFile>& outputs); |
| 64 |
31 void WriteLinkerStuff(const std::vector<OutputFile>& object_files, | 65 void WriteLinkerStuff(const std::vector<OutputFile>& object_files, |
32 const std::vector<SourceFile>& other_files); | 66 const std::vector<SourceFile>& other_files); |
33 void WriteLinkerFlags(const SourceFile* optional_def_file); | 67 void WriteLinkerFlags(const SourceFile* optional_def_file); |
34 void WriteLibs(); | 68 void WriteLibs(); |
35 void WriteOutputExtension(); | 69 void WriteOutputExtension(); |
36 void WriteSolibs(const std::vector<OutputFile>& solibs); | 70 void WriteSolibs(const std::vector<OutputFile>& solibs); |
37 | 71 |
38 // Writes the stamp line for a source set. These are not linked. | 72 // Writes the stamp line for a source set. These are not linked. |
39 void WriteSourceSetStamp(const std::vector<OutputFile>& object_files); | 73 void WriteSourceSetStamp(const std::vector<OutputFile>& object_files); |
40 | 74 |
(...skipping 30 matching lines...) Expand all Loading... |
71 // this class is currently writing. | 105 // this class is currently writing. |
72 // | 106 // |
73 // The function can succeed with a "NONE" tool type for object files which are | 107 // The function can succeed with a "NONE" tool type for object files which are |
74 // just passed to the output. The output will always be overwritten, not | 108 // just passed to the output. The output will always be overwritten, not |
75 // appended to. | 109 // appended to. |
76 bool GetOutputFilesForSource(const Target* target, | 110 bool GetOutputFilesForSource(const Target* target, |
77 const SourceFile& source, | 111 const SourceFile& source, |
78 Toolchain::ToolType* computed_tool_type, | 112 Toolchain::ToolType* computed_tool_type, |
79 std::vector<OutputFile>* outputs) const; | 113 std::vector<OutputFile>* outputs) const; |
80 | 114 |
| 115 // Appends the object files generated by the given source set to the given |
| 116 // output vector. |
| 117 void AddSourceSetObjectFiles(const Target* source_set, |
| 118 UniqueVector<OutputFile>* obj_files) const; |
| 119 |
| 120 // Returns the object files for the precompiled header of the given type |
| 121 // (flag type and tool type must match). The given target is used rather than |
| 122 // this class' target_ so any target's object files can be retrieved. |
| 123 void GetWindowsPCHObjectFiles(const Target* target, |
| 124 SubstitutionType flag_type, |
| 125 Toolchain::ToolType tool_type, |
| 126 std::vector<OutputFile>* outputs) const; |
| 127 |
| 128 // Returns the computed name of the Windows .pch file for the given |
| 129 // flag type (C/C++/ObjC/ObjC++). |
| 130 OutputFile GetWindowsPCHFile(SubstitutionType flag_type) const; |
| 131 |
81 const Tool* tool_; | 132 const Tool* tool_; |
82 | 133 |
| 134 // Cached version of the prefix used for rule types for this toolchain. |
| 135 std::string rule_prefix_; |
| 136 |
83 DISALLOW_COPY_AND_ASSIGN(NinjaBinaryTargetWriter); | 137 DISALLOW_COPY_AND_ASSIGN(NinjaBinaryTargetWriter); |
84 }; | 138 }; |
85 | 139 |
86 #endif // TOOLS_GN_NINJA_BINARY_TARGET_WRITER_H_ | 140 #endif // TOOLS_GN_NINJA_BINARY_TARGET_WRITER_H_ |
87 | 141 |
OLD | NEW |