Revert 264226 "Reduce dependency of TiclInvalidationService on P..."
[chromium-blink-merge.git] / tools / gn / ninja_target_writer.h
blob38378686947a82de96c8b78835a910d45d94926f
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_
8 #include <iosfwd>
10 #include "base/basictypes.h"
11 #include "tools/gn/ninja_helper.h"
12 #include "tools/gn/path_output.h"
14 class FileTemplate;
15 class Settings;
16 class Target;
18 // Generates one target's ".ninja" file. The toplevel "build.ninja" file is
19 // generated by the NinjaBuildWriter.
20 class NinjaTargetWriter {
21 public:
22 NinjaTargetWriter(const Target* target,
23 const Toolchain* toolchain,
24 std::ostream& out);
25 virtual ~NinjaTargetWriter();
27 static void RunAndWriteFile(const Target* target, const Toolchain* toolchain);
29 virtual void Run() = 0;
31 protected:
32 // Returns the string to be appended to source rules that encodes the
33 // order-only dependencies for the current target. This will include the
34 // "|" character so can just be appended to the source rules. If there are no
35 // implicit dependencies, returns the empty string.
36 std::string GetSourcesImplicitDeps() const;
38 // Returns the FileTemplate constructed from the outputs variable. This is
39 // like FileTemplate::GetForTargetOutputs except this additionally trims the
40 // build directory from the front so we can just write the names without
41 // further processing.
42 FileTemplate GetOutputTemplate() const;
44 const Settings* settings_; // Non-owning.
45 const Target* target_; // Non-owning.
46 const Toolchain* toolchain_; // Non-owning.
47 std::ostream& out_;
48 PathOutput path_output_;
50 NinjaHelper helper_;
52 private:
53 void WriteCopyRules();
55 DISALLOW_COPY_AND_ASSIGN(NinjaTargetWriter);
58 #endif // TOOLS_GN_NINJA_TARGET_WRITER_H_