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_WRITER_H_ | 5 #ifndef TOOLS_GN_NINJA_WRITER_H_ |
6 #define TOOLS_GN_NINJA_WRITER_H_ | 6 #define TOOLS_GN_NINJA_WRITER_H_ |
7 | 7 |
| 8 #include <map> |
8 #include <set> | 9 #include <set> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 | 14 |
14 class Builder; | 15 class Builder; |
15 class BuildSettings; | 16 class BuildSettings; |
16 class Err; | 17 class Err; |
17 class Pool; | 18 class Pool; |
18 class Settings; | 19 class Settings; |
19 class Target; | 20 class Target; |
| 21 class Toolchain; |
20 | 22 |
21 class NinjaWriter { | 23 class NinjaWriter { |
22 public: | 24 public: |
23 // On failure will populate |err| and will return false. | 25 // Combines a target and the computed build rule for it. |
24 static bool RunAndWriteFiles(const BuildSettings* build_settings, | 26 using TargetRulePair = std::pair<const Target*, std::string>; |
25 Builder* builder, | |
26 Err* err); | |
27 | 27 |
28 // Writes only the toolchain.ninja files, skipping the root buildfile. The | 28 // Associates the build rules with each toolchain. |
29 // settings for the files written will be added to the vector. | 29 using PerToolchainRules = |
30 static bool RunAndWriteToolchainFiles( | 30 std::map<const Toolchain*, std::vector<TargetRulePair>>; |
| 31 |
| 32 // On failure will populate |err| and will return false. The map contains |
| 33 // the per-toolchain set of rules collected to write to the toolchain build |
| 34 // files. |
| 35 static bool RunAndWriteFiles( |
31 const BuildSettings* build_settings, | 36 const BuildSettings* build_settings, |
32 Builder* builder, | 37 const Builder& builder, |
33 std::vector<const Settings*>* all_settings, | 38 const PerToolchainRules& per_toolchain_rules, |
34 Err* err); | 39 Err* err); |
35 | 40 |
36 private: | 41 private: |
37 NinjaWriter(const BuildSettings* build_settings, Builder* builder); | 42 NinjaWriter(const Builder& builder); |
38 ~NinjaWriter(); | 43 ~NinjaWriter(); |
39 | 44 |
40 bool WriteToolchains(std::vector<const Settings*>* all_settings, | 45 bool WriteToolchains(const PerToolchainRules& per_toolchain_rules, |
41 std::vector<const Target*>* default_targets, | |
42 std::vector<const Pool*>* all_pools, | |
43 Err* err); | 46 Err* err); |
44 bool WriteRootBuildfiles(const std::vector<const Settings*>& all_settings, | |
45 const std::vector<const Target*>& default_targets, | |
46 const std::vector<const Pool*>& all_pools, | |
47 Err* err); | |
48 | 47 |
49 const BuildSettings* build_settings_; | 48 const Builder& builder_; |
50 Builder* builder_; | |
51 | 49 |
52 DISALLOW_COPY_AND_ASSIGN(NinjaWriter); | 50 DISALLOW_COPY_AND_ASSIGN(NinjaWriter); |
53 }; | 51 }; |
54 | 52 |
55 #endif // TOOLS_GN_NINJA_WRITER_H_ | 53 #endif // TOOLS_GN_NINJA_WRITER_H_ |
OLD | NEW |