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_TARGET_WRITER_H_ | 5 #ifndef TOOLS_GN_NINJA_TARGET_WRITER_H_ |
6 #define TOOLS_GN_NINJA_TARGET_WRITER_H_ | 6 #define TOOLS_GN_NINJA_TARGET_WRITER_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "tools/gn/path_output.h" | 11 #include "tools/gn/path_output.h" |
12 #include "tools/gn/substitution_type.h" | 12 #include "tools/gn/substitution_type.h" |
13 | 13 |
14 class FileTemplate; | 14 class FileTemplate; |
| 15 class OutputFile; |
15 class Settings; | 16 class Settings; |
16 class Target; | 17 class Target; |
17 | 18 |
18 // Generates one target's ".ninja" file. The toplevel "build.ninja" file is | 19 // Generates one target's ".ninja" file. The toplevel "build.ninja" file is |
19 // generated by the NinjaBuildWriter. | 20 // generated by the NinjaBuildWriter. |
20 class NinjaTargetWriter { | 21 class NinjaTargetWriter { |
21 public: | 22 public: |
22 NinjaTargetWriter(const Target* target, std::ostream& out); | 23 NinjaTargetWriter(const Target* target, std::ostream& out); |
23 virtual ~NinjaTargetWriter(); | 24 virtual ~NinjaTargetWriter(); |
24 | 25 |
25 static void RunAndWriteFile(const Target* target); | 26 static void RunAndWriteFile(const Target* target); |
26 | 27 |
27 virtual void Run() = 0; | 28 virtual void Run() = 0; |
28 | 29 |
29 protected: | 30 protected: |
30 // Writes out the substitution values that are shared between the different | 31 // Writes out the substitution values that are shared between the different |
31 // types of tools (target gen dir, target label, etc.). Only the substitutions | 32 // types of tools (target gen dir, target label, etc.). Only the substitutions |
32 // identified by the given bits will be written. | 33 // identified by the given bits will be written. |
33 void WriteSharedVars(const SubstitutionBits& bits); | 34 void WriteSharedVars(const SubstitutionBits& bits); |
34 | 35 |
35 // Writes to the output stream a stamp rule for input dependencies, and | 36 // Writes to the output stream a stamp rule for input dependencies, and |
36 // returns the string to be appended to source rules that encodes the | 37 // returns the file to be appended to source rules that encodes the |
37 // order-only dependencies for the current target. This will include the "|" | 38 // order-only dependencies for the current target. The returned OutputFile |
38 // character so can just be appended to the source rules. If there are no | 39 // will be empty if there are no implicit dependencies and no extra target |
39 // implicit dependencies and no extra target dependencies passed in, returns | 40 // dependencies passed in. |
40 // the empty string. | 41 OutputFile WriteInputDepsStampAndGetDep( |
41 std::string WriteInputDepsStampAndGetDep( | |
42 const std::vector<const Target*>& extra_hard_deps) const; | 42 const std::vector<const Target*>& extra_hard_deps) const; |
43 | 43 |
44 // Writes to the output file a final stamp rule for the target that stamps | 44 // Writes to the output file a final stamp rule for the target that stamps |
45 // the given list of files. This function assumes the stamp is for the target | 45 // the given list of files. This function assumes the stamp is for the target |
46 // as a whole so the stamp file is set as the target's dependency output. | 46 // as a whole so the stamp file is set as the target's dependency output. |
47 void WriteStampForTarget(const std::vector<OutputFile>& deps, | 47 void WriteStampForTarget(const std::vector<OutputFile>& deps, |
48 const std::vector<OutputFile>& order_only_deps); | 48 const std::vector<OutputFile>& order_only_deps); |
49 | 49 |
50 const Settings* settings_; // Non-owning. | 50 const Settings* settings_; // Non-owning. |
51 const Target* target_; // Non-owning. | 51 const Target* target_; // Non-owning. |
52 std::ostream& out_; | 52 std::ostream& out_; |
53 PathOutput path_output_; | 53 PathOutput path_output_; |
54 | 54 |
55 private: | 55 private: |
56 void WriteCopyRules(); | 56 void WriteCopyRules(); |
57 | 57 |
58 DISALLOW_COPY_AND_ASSIGN(NinjaTargetWriter); | 58 DISALLOW_COPY_AND_ASSIGN(NinjaTargetWriter); |
59 }; | 59 }; |
60 | 60 |
61 #endif // TOOLS_GN_NINJA_TARGET_WRITER_H_ | 61 #endif // TOOLS_GN_NINJA_TARGET_WRITER_H_ |
OLD | NEW |