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.
5 #ifndef TOOLS_GN_NINJA_BUILD_WRITER_H_
6 #define TOOLS_GN_NINJA_BUILD_WRITER_H_
12 #include "tools/gn/path_output.h"
20 // Generates the toplevel "build.ninja" file. This references the individual
21 // toolchain files and lists all input .gn files as dependencies of the
23 class NinjaBuildWriter
{
25 static bool RunAndWriteFile(
26 const BuildSettings
* settings
,
27 const std::vector
<const Settings
*>& all_settings
,
28 const Toolchain
* default_toolchain
,
29 const std::vector
<const Target
*>& default_toolchain_targets
,
33 NinjaBuildWriter(const BuildSettings
* settings
,
34 const std::vector
<const Settings
*>& all_settings
,
35 const Toolchain
* default_toolchain
,
36 const std::vector
<const Target
*>& default_toolchain_targets
,
38 std::ostream
& dep_out
);
43 void WriteNinjaRules();
45 void WriteSubninjas();
46 bool WritePhonyAndAllRules(Err
* err
);
48 // Writes a phony rule for the given target with the given name. Adds the new
49 // name to the given set. If the name is already in the set, does nothing.
50 void WritePhonyRule(const Target
* target
,
51 const OutputFile
& target_file
,
52 const std::string
& phony_name
,
53 std::set
<std::string
>* written_rules
);
55 const BuildSettings
* build_settings_
;
56 std::vector
<const Settings
*> all_settings_
;
57 const Toolchain
* default_toolchain_
;
58 std::vector
<const Target
*> default_toolchain_targets_
;
60 std::ostream
& dep_out_
;
61 PathOutput path_output_
;
63 DISALLOW_COPY_AND_ASSIGN(NinjaBuildWriter
);
66 #endif // TOOLS_GN_NINJA_BUILD_WRITER_H_