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

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

Issue 21114002: Add initial prototype for the GN meta-buildsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add owners and readme Created 7 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
« no previous file with comments | « tools/gn/escape_unittest.cc ('k') | tools/gn/file_template.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef TOOLS_GN_FILE_TEMPLATE_H_
6 #define TOOLS_GN_FILE_TEMPLATE_H_
7
8 #include "base/basictypes.h"
9 #include "base/containers/stack_container.h"
10 #include "tools/gn/err.h"
11 #include "tools/gn/value.h"
12
13 class ParseNode;
14
15 class FileTemplate {
16 public:
17 struct Subrange {
18 enum Type {
19 LITERAL = 0,
20 SOURCE,
21 NAME_PART,
22 NUM_TYPES // Must be last
23 };
24 Subrange(Type t, const std::string& l = std::string())
25 : type(t),
26 literal(l) {
27 }
28
29 Type type;
30
31 // When type_ == LITERAL, this specifies the literal.
32 std::string literal;
33 };
34
35 // Constructs a template from the given value. On error, the err will be
36 // set. In this case you should not use this object.
37 FileTemplate(const Value& t, Err* err);
38 FileTemplate(const std::vector<std::string>& t);
39 ~FileTemplate();
40
41 // Applies this template to the given list of sources, appending all
42 // results to the given dest list. The sources must be a list for the
43 // one that takes a value as an input, otherwise the given error will be set.
44 void Apply(const Value& sources,
45 const ParseNode* origin,
46 std::vector<Value>* dest,
47 Err* err) const;
48 void ApplyString(const std::string& input,
49 std::vector<std::string>* output) const;
50
51 // Known template types.
52 static const char kSource[];
53 static const char kSourceNamePart[];
54
55 private:
56 typedef base::StackVector<Subrange, 8> Template;
57 typedef base::StackVector<Template, 8> TemplateVector;
58
59 void ParseInput(const Value& value, Err* err);
60
61 // Parses a template string and adds it to the templates_ list.
62 void ParseOneTemplateString(const std::string& str);
63
64 TemplateVector templates_;
65
66 // The corresponding value is set to true if the given subrange type is
67 // required. This allows us to precompute these types whem applying them
68 // to a given source file.
69 bool types_required_[Subrange::NUM_TYPES];
70
71 DISALLOW_COPY_AND_ASSIGN(FileTemplate);
72 };
73
74 #endif // TOOLS_GN_FILE_TEMPLATE_H_
OLDNEW
« no previous file with comments | « tools/gn/escape_unittest.cc ('k') | tools/gn/file_template.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698