• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef TOOLS_GN_NINJA_BUILD_WRITER_H_
6 #define TOOLS_GN_NINJA_BUILD_WRITER_H_
7 
8 #include <iosfwd>
9 #include <vector>
10 
11 #include "tools/gn/ninja_helper.h"
12 #include "tools/gn/path_output.h"
13 
14 class BuildSettings;
15 class Settings;
16 class Target;
17 
18 // Generates the toplevel "build.ninja" file. This references the individual
19 // toolchain files and lists all input .gn files as dependencies of the
20 // build itself.
21 class NinjaBuildWriter {
22  public:
23   static bool RunAndWriteFile(
24       const BuildSettings* settings,
25       const std::vector<const Settings*>& all_settings,
26       const std::vector<const Target*>& default_toolchain_targets);
27 
28  private:
29   NinjaBuildWriter(const BuildSettings* settings,
30                    const std::vector<const Settings*>& all_settings,
31                    const std::vector<const Target*>& default_toolchain_targets,
32                    std::ostream& out,
33                    std::ostream& dep_out);
34   ~NinjaBuildWriter();
35 
36   void Run();
37 
38   void WriteNinjaRules();
39   void WriteSubninjas();
40   void WritePhonyAndAllRules();
41 
42   const BuildSettings* build_settings_;
43   std::vector<const Settings*> all_settings_;
44   std::vector<const Target*> default_toolchain_targets_;
45   std::ostream& out_;
46   std::ostream& dep_out_;
47   PathOutput path_output_;
48 
49   NinjaHelper helper_;
50 
51   DISALLOW_COPY_AND_ASSIGN(NinjaBuildWriter);
52 };
53 
54 #endif  // TOOLS_GN_NINJA_BUILD_GENERATOR_H_
55 
56