Index: tools/gn/ninja_binary_target_writer.h |
diff --git a/tools/gn/ninja_binary_target_writer.h b/tools/gn/ninja_binary_target_writer.h |
index 977e9823fe4fd075949b2f1d9058126cc66ac541..fe7a132c9baa38d9aed9e7c1bbc7d18c4b5cfa0d 100644 |
--- a/tools/gn/ninja_binary_target_writer.h |
+++ b/tools/gn/ninja_binary_target_writer.h |
@@ -12,11 +12,14 @@ |
#include "tools/gn/unique_vector.h" |
struct EscapeOptions; |
+class SourceFileTypeSet; |
// Writes a .ninja file for a binary target type (an executable, a shared |
// library, or a static library). |
class NinjaBinaryTargetWriter : public NinjaTargetWriter { |
public: |
+ class SourceFileTypeSet; |
+ |
NinjaBinaryTargetWriter(const Target* target, std::ostream& out); |
~NinjaBinaryTargetWriter() override; |
@@ -25,9 +28,57 @@ class NinjaBinaryTargetWriter : public NinjaTargetWriter { |
private: |
typedef std::set<OutputFile> OutputFileSet; |
- void WriteCompilerVars(); |
- void WriteSources(std::vector<OutputFile>* object_files, |
+ // Writes all flags for the compiler: includes, defines, cflags, etc. |
+ void WriteCompilerVars(const SourceFileTypeSet& used_types); |
+ |
+ // has_precompiled_headers is set when this substitution matches a tool type |
+ // that supports precompiled headers, and this target supports precompiled |
+ // headers. It doesn't indicate if the tool has precompiled headers (this |
+ // will be looked up by this function). |
+ // |
+ // The tool_type indicates the corresponding tool for flags that are |
+ // tool-specific (e.g. "cflags_c"). For non-tool-specific flags (e.g. |
+ // "defines") tool_type should be TYPE_NONE. |
+ void WriteOneFlag( |
+ SubstitutionType subst_enum, |
+ bool has_precompiled_headers, |
+ Toolchain::ToolType tool_type, |
+ const std::vector<std::string>& (ConfigValues::* getter)() const, |
+ EscapeOptions flag_escape_options); |
+ |
+ // Writes build lines required for precompiled headers. Any generated |
+ // object files will be appended to the given vector. |
+ // |
+ // input_dep is the stamp file collecting the dependencies required before |
+ // compiling this target. It will be empty if there are no input deps. |
+ void WritePrecompiledHeaderCommands(const SourceFileTypeSet& used_types, |
+ const OutputFile& input_dep, |
+ std::vector<OutputFile>* object_files); |
+ |
+ // Writes a Windows .pch compile build line for a language type. |
+ void WriteWindowsPCHCommand(SubstitutionType flag_type, |
+ Toolchain::ToolType tool_type, |
+ const OutputFile& input_dep, |
+ std::vector<OutputFile>* object_files); |
+ |
+ // extra_deps are additional dependencies to run before the rule. |
+ // |
+ // iorder_only_dep is the name of the stamp file that covers the dependencies |
+ // that must be run before doing any compiles. |
+ // |
+ // The files produced by the compiler will be added to two output vectors. |
+ void WriteSources(const std::vector<OutputFile>& extra_deps, |
+ const OutputFile& order_only_dep, |
+ std::vector<OutputFile>* object_files, |
std::vector<SourceFile>* other_files); |
+ |
+ // Writes a build line. |
+ void WriteCompilerBuildLine(const SourceFile& source, |
+ const std::vector<OutputFile>& extra_deps, |
+ const OutputFile& order_only_dep, |
+ Toolchain::ToolType tool_type, |
+ const std::vector<OutputFile>& outputs); |
+ |
void WriteLinkerStuff(const std::vector<OutputFile>& object_files, |
const std::vector<SourceFile>& other_files); |
void WriteLinkerFlags(const SourceFile* optional_def_file); |
@@ -61,25 +112,15 @@ class NinjaBinaryTargetWriter : public NinjaTargetWriter { |
void WriteOrderOnlyDependencies( |
const UniqueVector<const Target*>& non_linkable_deps); |
- // Computes the set of output files resulting from compiling the given source |
- // file. If the file can be compiled and the tool exists, fills the outputs in |
- // and writes the tool type to computed_tool_type. If the file is not |
- // compilable, returns false. |
- // |
- // The target that the source belongs to is passed as an argument. In the |
- // case of linking to source sets, this can be different than the target |
- // this class is currently writing. |
- // |
- // The function can succeed with a "NONE" tool type for object files which are |
- // just passed to the output. The output will always be overwritten, not |
- // appended to. |
- bool GetOutputFilesForSource(const Target* target, |
- const SourceFile& source, |
- Toolchain::ToolType* computed_tool_type, |
- std::vector<OutputFile>* outputs) const; |
+ // Returns the computed name of the Windows .pch file for the given |
+ // tool type. The tool must support precompiled headers. |
+ OutputFile GetWindowsPCHFile(Toolchain::ToolType tool_type) const; |
const Tool* tool_; |
+ // Cached version of the prefix used for rule types for this toolchain. |
+ std::string rule_prefix_; |
+ |
DISALLOW_COPY_AND_ASSIGN(NinjaBinaryTargetWriter); |
}; |