Fix components/undo/BUILD.gn
[chromium-blink-merge.git] / tools / gn / ninja_action_target_writer.h
blob71c123976220782cadad5b5bdedab0a5f34474d8
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_ACTION_TARGET_WRITER_H_
6 #define TOOLS_GN_NINJA_ACTION_TARGET_WRITER_H_
8 #include <vector>
10 #include "base/gtest_prod_util.h"
11 #include "base/macros.h"
12 #include "tools/gn/ninja_target_writer.h"
14 class OutputFile;
16 // Writes a .ninja file for a action target type.
17 class NinjaActionTargetWriter : public NinjaTargetWriter {
18 public:
19 NinjaActionTargetWriter(const Target* target, std::ostream& out);
20 ~NinjaActionTargetWriter() override;
22 void Run() override;
24 private:
25 FRIEND_TEST_ALL_PREFIXES(NinjaActionTargetWriter,
26 WriteOutputFilesForBuildLine);
27 FRIEND_TEST_ALL_PREFIXES(NinjaActionTargetWriter,
28 WriteOutputFilesForBuildLineWithDepfile);
29 FRIEND_TEST_ALL_PREFIXES(NinjaActionTargetWriter,
30 WriteArgsSubstitutions);
32 // Writes the Ninja rule for invoking the script.
34 // Returns the name of the custom rule generated. This will be based on the
35 // target name, and will include the string "$unique_name" if there are
36 // multiple inputs.
37 std::string WriteRuleDefinition();
39 // Writes the rules for compiling each source, writing all output files
40 // to the given vector.
42 // input_dep is a file expressing the depencies common to all build steps.
43 // It will be a stamp file if there is more than one.
44 void WriteSourceRules(const std::string& custom_rule_name,
45 const OutputFile& input_dep,
46 std::vector<OutputFile>* output_files);
48 // Writes the output files generated by the output template for the given
49 // source file. This will start with a space and will not include a newline.
50 // Appends the output files to the given vector.
51 void WriteOutputFilesForBuildLine(const SourceFile& source,
52 std::vector<OutputFile>* output_files);
54 void WriteDepfile(const SourceFile& source);
56 // Path output writer that doesn't do any escaping or quoting. It does,
57 // however, convert slashes. Used for
58 // computing intermediate strings.
59 PathOutput path_output_no_escaping_;
61 DISALLOW_COPY_AND_ASSIGN(NinjaActionTargetWriter);
64 #endif // TOOLS_GN_NINJA_ACTION_TARGET_WRITER_H_