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_TOOLCHAIN_WRITER_H_ | 5 #ifndef TOOLS_GN_NINJA_TOOLCHAIN_WRITER_H_ |
6 #define TOOLS_GN_NINJA_TOOLCHAIN_WRITER_H_ | 6 #define TOOLS_GN_NINJA_TOOLCHAIN_WRITER_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "tools/gn/ninja_writer.h" |
15 #include "tools/gn/path_output.h" | 16 #include "tools/gn/path_output.h" |
16 #include "tools/gn/toolchain.h" | 17 #include "tools/gn/toolchain.h" |
17 | 18 |
18 class BuildSettings; | 19 class BuildSettings; |
19 struct EscapeOptions; | 20 struct EscapeOptions; |
20 class Settings; | 21 class Settings; |
21 class Target; | 22 class Target; |
22 class Tool; | 23 class Tool; |
23 | 24 |
24 class NinjaToolchainWriter { | 25 class NinjaToolchainWriter { |
25 public: | 26 public: |
26 // Takes the settings for the toolchain, as well as the list of all targets | 27 // Takes the settings for the toolchain, as well as the list of all targets |
27 // associated with the toolchain. | 28 // associated with the toolchain. |
28 static bool RunAndWriteFile(const Settings* settings, | 29 static bool RunAndWriteFile( |
29 const Toolchain* toolchain, | 30 const Settings* settings, |
30 const std::vector<const Target*>& targets); | 31 const Toolchain* toolchain, |
| 32 const std::vector<NinjaWriter::TargetRulePair>& rules); |
31 | 33 |
32 private: | 34 private: |
33 FRIEND_TEST_ALL_PREFIXES(NinjaToolchainWriter, WriteToolRule); | 35 FRIEND_TEST_ALL_PREFIXES(NinjaToolchainWriter, WriteToolRule); |
34 | 36 |
35 NinjaToolchainWriter(const Settings* settings, | 37 NinjaToolchainWriter(const Settings* settings, |
36 const Toolchain* toolchain, | 38 const Toolchain* toolchain, |
37 const std::vector<const Target*>& targets, | |
38 std::ostream& out); | 39 std::ostream& out); |
39 ~NinjaToolchainWriter(); | 40 ~NinjaToolchainWriter(); |
40 | 41 |
41 void Run(); | 42 void Run(const std::vector<NinjaWriter::TargetRulePair>& extra_rules); |
42 | 43 |
43 void WriteRules(); | 44 void WriteRules(); |
44 void WriteToolRule(Toolchain::ToolType type, | 45 void WriteToolRule(Toolchain::ToolType type, |
45 const Tool* tool, | 46 const Tool* tool, |
46 const std::string& rule_prefix); | 47 const std::string& rule_prefix); |
47 void WriteRulePattern(const char* name, | 48 void WriteRulePattern(const char* name, |
48 const SubstitutionPattern& pattern, | 49 const SubstitutionPattern& pattern, |
49 const EscapeOptions& options); | 50 const EscapeOptions& options); |
50 void WriteSubninjas(); | |
51 | 51 |
52 const Settings* settings_; | 52 const Settings* settings_; |
53 const Toolchain* toolchain_; | 53 const Toolchain* toolchain_; |
54 std::vector<const Target*> targets_; | |
55 std::ostream& out_; | 54 std::ostream& out_; |
56 PathOutput path_output_; | 55 PathOutput path_output_; |
57 | 56 |
58 DISALLOW_COPY_AND_ASSIGN(NinjaToolchainWriter); | 57 DISALLOW_COPY_AND_ASSIGN(NinjaToolchainWriter); |
59 }; | 58 }; |
60 | 59 |
61 #endif // TOOLS_GN_NINJA_TOOLCHAIN_WRITER_H_ | 60 #endif // TOOLS_GN_NINJA_TOOLCHAIN_WRITER_H_ |
OLD | NEW |