Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Side by Side Diff: tools/gn/substitution_writer.h

Issue 462103004: GN: Bug fixes in process_file_template (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TOOLS_GN_SUBSTITUTION_WRITER_H_ 5 #ifndef TOOLS_GN_SUBSTITUTION_WRITER_H_
6 #define TOOLS_GN_SUBSTITUTION_WRITER_H_ 6 #define TOOLS_GN_SUBSTITUTION_WRITER_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 16 matching lines...) Expand all
27 public: 27 public:
28 enum OutputStyle { 28 enum OutputStyle {
29 OUTPUT_ABSOLUTE, // Dirs will be absolute "//foo/bar". 29 OUTPUT_ABSOLUTE, // Dirs will be absolute "//foo/bar".
30 OUTPUT_RELATIVE, // Dirs will be relative to a given directory. 30 OUTPUT_RELATIVE, // Dirs will be relative to a given directory.
31 }; 31 };
32 32
33 SubstitutionWriter(); 33 SubstitutionWriter();
34 ~SubstitutionWriter(); 34 ~SubstitutionWriter();
35 35
36 // Applies the substitution pattern to a source file, returning the result 36 // Applies the substitution pattern to a source file, returning the result
37 // as either a SourceFile or OutputFile. 37 // as either a string, a SourceFile or an OutputFile. If the result is
38 // expected to be a SourceFile or an OutputFile, this will CHECK if the
39 // result isn't in the correct directory. The caller should validate this
40 // first (see for example IsFileInOuputDir).
38 static SourceFile ApplyPatternToSource( 41 static SourceFile ApplyPatternToSource(
39 const Settings* settings, 42 const Settings* settings,
40 const SubstitutionPattern& pattern, 43 const SubstitutionPattern& pattern,
41 const SourceFile& source); 44 const SourceFile& source);
45 static std::string ApplyPatternToSourceAsString(
46 const Settings* settings,
47 const SubstitutionPattern& pattern,
48 const SourceFile& source);
42 static OutputFile ApplyPatternToSourceAsOutputFile( 49 static OutputFile ApplyPatternToSourceAsOutputFile(
43 const Settings* settings, 50 const Settings* settings,
44 const SubstitutionPattern& pattern, 51 const SubstitutionPattern& pattern,
45 const SourceFile& source); 52 const SourceFile& source);
46 53
47 // Applies the substitution list to a source, APPENDING the result to the 54 // Applies the substitution list to a source, APPENDING the result to the
48 // given output vector. It works this way so one can call multiple times to 55 // given output vector. It works this way so one can call multiple times to
49 // apply to multiple files and create a list. The result can either be 56 // apply to multiple files and create a list. The result can either be
50 // SourceFiles or OutputFiles. 57 // SourceFiles or OutputFiles.
51 static void ApplyListToSource( 58 static void ApplyListToSource(
52 const Settings* settings, 59 const Settings* settings,
53 const SubstitutionList& list, 60 const SubstitutionList& list,
54 const SourceFile& source, 61 const SourceFile& source,
55 std::vector<SourceFile>* output); 62 std::vector<SourceFile>* output);
63 static void ApplyListToSourceAsString(
64 const Settings* settings,
65 const SubstitutionList& list,
66 const SourceFile& source,
67 std::vector<std::string>* output);
56 static void ApplyListToSourceAsOutputFile( 68 static void ApplyListToSourceAsOutputFile(
57 const Settings* settings, 69 const Settings* settings,
58 const SubstitutionList& list, 70 const SubstitutionList& list,
59 const SourceFile& source, 71 const SourceFile& source,
60 std::vector<OutputFile>* output); 72 std::vector<OutputFile>* output);
61 73
62 // Like ApplyListToSource but applies the list to all sources and replaces 74 // Like ApplyListToSource but applies the list to all sources and replaces
63 // rather than appesnds the output (this produces the complete output). 75 // rather than appesnds the output (this produces the complete output).
64 static void ApplyListToSources( 76 static void ApplyListToSources(
65 const Settings* settings, 77 const Settings* settings,
66 const SubstitutionList& list, 78 const SubstitutionList& list,
67 const std::vector<SourceFile>& sources, 79 const std::vector<SourceFile>& sources,
68 std::vector<SourceFile>* output); 80 std::vector<SourceFile>* output);
81 static void ApplyListToSourcesAsString(
82 const Settings* settings,
83 const SubstitutionList& list,
84 const std::vector<SourceFile>& sources,
85 std::vector<std::string>* output);
69 static void ApplyListToSourcesAsOutputFile( 86 static void ApplyListToSourcesAsOutputFile(
70 const Settings* settings, 87 const Settings* settings,
71 const SubstitutionList& list, 88 const SubstitutionList& list,
72 const std::vector<SourceFile>& sources, 89 const std::vector<SourceFile>& sources,
73 std::vector<OutputFile>* output); 90 std::vector<OutputFile>* output);
74 91
75 // Given a list of source replacement types used, writes the Ninja variable 92 // Given a list of source replacement types used, writes the Ninja variable
76 // definitions for the given source file to use for those replacements. The 93 // definitions for the given source file to use for those replacements. The
77 // variables will be indented two spaces. Since this is for writing to 94 // variables will be indented two spaces. Since this is for writing to
78 // Ninja files, paths will be relative to the build dir, and no definition 95 // Ninja files, paths will be relative to the build dir, and no definition
(...skipping 19 matching lines...) Expand all
98 // to, otherwise it is ignored. 115 // to, otherwise it is ignored.
99 static std::string GetSourceSubstitution( 116 static std::string GetSourceSubstitution(
100 const Settings* settings, 117 const Settings* settings,
101 const SourceFile& source, 118 const SourceFile& source,
102 SubstitutionType type, 119 SubstitutionType type,
103 OutputStyle output_style, 120 OutputStyle output_style,
104 const SourceDir& relative_to); 121 const SourceDir& relative_to);
105 }; 122 };
106 123
107 #endif // TOOLS_GN_SUBSTITUTION_WRITER_H_ 124 #endif // TOOLS_GN_SUBSTITUTION_WRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698