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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "tools/gn/ninja_target_writer.h" | 9 #include "tools/gn/ninja_target_writer.h" |
10 #include "tools/gn/toolchain.h" | 10 #include "tools/gn/toolchain.h" |
11 | 11 |
12 // Writes a .ninja file for a binary target type (an executable, a shared | 12 // Writes a .ninja file for a binary target type (an executable, a shared |
13 // library, or a static library). | 13 // library, or a static library). |
14 class NinjaBinaryTargetWriter : public NinjaTargetWriter { | 14 class NinjaBinaryTargetWriter : public NinjaTargetWriter { |
15 public: | 15 public: |
16 NinjaBinaryTargetWriter(const Target* target, std::ostream& out); | 16 NinjaBinaryTargetWriter(const Target* target, std::ostream& out); |
17 virtual ~NinjaBinaryTargetWriter(); | 17 virtual ~NinjaBinaryTargetWriter(); |
18 | 18 |
19 virtual void Run() OVERRIDE; | 19 virtual void Run() OVERRIDE; |
20 | 20 |
21 private: | 21 private: |
22 typedef std::set<OutputFile> OutputFileSet; | |
23 | |
22 void WriteCompilerVars(); | 24 void WriteCompilerVars(); |
23 void WriteSources(std::vector<OutputFile>* object_files); | 25 void WriteSources(std::vector<OutputFile>* object_files); |
24 void WriteLinkerStuff(const std::vector<OutputFile>& object_files); | 26 void WriteLinkerStuff(const std::vector<OutputFile>& object_files); |
25 void WriteLinkerFlags(); | 27 void WriteLinkerFlags(); |
26 | 28 |
27 // Writes the build line for linking the target. Includes newline. | 29 // Writes the build line for linking the target. Includes newline. |
28 void WriteLinkCommand(const OutputFile& external_output_file, | 30 void WriteLinkCommand(const OutputFile& external_output_file, |
29 const OutputFile& internal_output_file, | 31 const OutputFile& internal_output_file, |
30 const std::vector<OutputFile>& object_files); | 32 const std::vector<OutputFile>& object_files); |
31 | 33 |
34 // Writes the stamp line for a source set. These are not linked. | |
35 void WriteSourceSetStamp(const std::vector<OutputFile>& object_files); | |
36 | |
37 // Gets all target dependencies and classifies them, as well as accumulates | |
38 // object files from source sets we need to link. | |
39 void GetDeps(std::set<OutputFile>* extra_object_files, | |
40 std::vector<const Target*>* linkable_deps, | |
41 std::vector<const Target*>* non_linkable_deps) const; | |
42 | |
43 // Classifies the dependency as linkable or nonlinkable with the current | |
44 // target, addint it to the appropriate vector. If the dependency is a source | |
scottmg
2013/10/08 18:42:03
addint -> adding
| |
45 // set we should link in, the source set's object files will be appended to | |
46 // |extra_object_files|. | |
47 void ClassifyDependency(const Target* dep, | |
48 std::set<OutputFile>* extra_object_files, | |
49 std::vector<const Target*>* linkable_deps, | |
50 std::vector<const Target*>* non_linkable_deps) const; | |
51 | |
52 // Writes the implicit dependencies for the link or stamp line. This is | |
53 // the "||" and everything following it on the ninja line. | |
54 // | |
55 // The implicit dependencies are the non-linkable deps passed in as an | |
56 // argument, plus the data file depdencies in the target. | |
57 void WriteImplicitDependencies( | |
58 const std::vector<const Target*>& non_linkable_deps); | |
59 | |
32 Toolchain::ToolType tool_type_; | 60 Toolchain::ToolType tool_type_; |
33 | 61 |
34 DISALLOW_COPY_AND_ASSIGN(NinjaBinaryTargetWriter); | 62 DISALLOW_COPY_AND_ASSIGN(NinjaBinaryTargetWriter); |
35 }; | 63 }; |
36 | 64 |
37 #endif // TOOLS_GN_NINJA_BINARY_TARGET_WRITER_H_ | 65 #endif // TOOLS_GN_NINJA_BINARY_TARGET_WRITER_H_ |
38 | 66 |
OLD | NEW |