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_TARGET_WRITER_H_
6 #define TOOLS_GN_NINJA_TARGET_WRITER_H_
10 #include "base/basictypes.h"
11 #include "tools/gn/ninja_helper.h"
12 #include "tools/gn/path_output.h"
18 // Generates one target's ".ninja" file. The toplevel "build.ninja" file is
19 // generated by the NinjaBuildWriter.
20 class NinjaTargetWriter
{
22 NinjaTargetWriter(const Target
* target
, std::ostream
& out
);
23 virtual ~NinjaTargetWriter();
25 static void RunAndWriteFile(const Target
* target
);
27 virtual void Run() = 0;
30 void WriteEnvironment();
32 // Returns the toolchain associated with the target.
33 const Toolchain
* GetToolchain() const;
35 // Returns the string to be appended to source rules that encodes the
36 // order-only dependencies for the current target. This will include the
37 // "|" character so can just be appended to the source rules. If there are no
38 // implicit dependencies, returns the empty string.
39 std::string
GetSourcesImplicitDeps() const;
41 // Returns the FileTemplate constructed from the outputs variable.
42 FileTemplate
GetOutputTemplate() const;
44 const Settings
* settings_
; // Non-owning.
45 const Target
* target_
; // Non-owning.
47 PathOutput path_output_
;
52 void WriteCopyRules();
54 DISALLOW_COPY_AND_ASSIGN(NinjaTargetWriter
);
57 #endif // TOOLS_GN_NINJA_TARGET_WRITER_H_