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

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

Issue 440333002: Support more configurability in GN toolchains (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_PATTERN_H_ 5 #ifndef TOOLS_GN_SUBSTITUTION_PATTERN_H_
6 #define TOOLS_GN_SUBSTITUTION_PATTERN_H_ 6 #define TOOLS_GN_SUBSTITUTION_PATTERN_H_
7 7
8 #include <functional>
jamesr 2014/08/19 19:30:41 doesn't appear to be used
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "tools/gn/substitution_type.h" 12 #include "tools/gn/substitution_type.h"
12 13
14 class BuildSettings;
13 class Err; 15 class Err;
14 class ParseNode; 16 class ParseNode;
15 class Value; 17 class Value;
16 18
17 // Represents a string with {{substitution_patterns}} in them. 19 // Represents a string with {{substitution_patterns}} in them.
18 class SubstitutionPattern { 20 class SubstitutionPattern {
19 public: 21 public:
20 struct Subrange { 22 struct Subrange {
21 Subrange(); 23 Subrange();
22 Subrange(SubstitutionType t, const std::string& l = std::string()); 24 Subrange(SubstitutionType t, const std::string& l = std::string());
23 ~Subrange(); 25 ~Subrange();
24 26
27 inline bool operator==(const Subrange& other) const {
28 return type == other.type && literal == other.literal;
29 }
30
25 SubstitutionType type; 31 SubstitutionType type;
26 32
27 // When type_ == LITERAL, this specifies the literal. 33 // When type_ == LITERAL, this specifies the literal.
28 std::string literal; 34 std::string literal;
29 }; 35 };
30 36
31 SubstitutionPattern(); 37 SubstitutionPattern();
32 ~SubstitutionPattern(); 38 ~SubstitutionPattern();
33 39
34 // Parses the given string and fills in the pattern. The pattern must only 40 // Parses the given string and fills in the pattern. The pattern must only
35 // be initialized once. On failure, returns false and sets the error. 41 // be initialized once. On failure, returns false and sets the error.
36 bool Parse(const Value& value, Err* err); 42 bool Parse(const Value& value, Err* err);
37 bool Parse(const std::string& str, const ParseNode* origin, Err* err); 43 bool Parse(const std::string& str, const ParseNode* origin, Err* err);
38 44
39 // Returns the pattern as a string with substitutions in them. 45 // Returns the pattern as a string with substitutions in them.
40 std::string AsString() const; 46 std::string AsString() const;
41 47
42 // Sets the bits in the given vector corresponding to the substitutions used 48 // Sets the bits in the given vector corresponding to the substitutions used
43 // by this pattern. SUBSTITUTION_LITERAL is ignored. 49 // by this pattern. SUBSTITUTION_LITERAL is ignored.
44 void FillRequiredTypes(bool required_types[SUBSTITUTION_NUM_TYPES]) const; 50 void FillRequiredTypes(SubstitutionBits* bits) const;
51
52 // Checks whether this pattern resolves to something in the output directory
53 // for the given build settings. If not, returns false and fills in the given
54 // error.
55 bool IsInOutputDir(const BuildSettings* build_settings,
56 Err* err) const;
45 57
46 // Returns a vector listing the substitutions used by this pattern, not 58 // Returns a vector listing the substitutions used by this pattern, not
47 // counting SUBSTITUTION_LITERAL. 59 // counting SUBSTITUTION_LITERAL.
48 const std::vector<SubstitutionType>& required_types() const { 60 const std::vector<SubstitutionType>& required_types() const {
49 return required_types_; 61 return required_types_;
50 } 62 }
51 63
52 const std::vector<Subrange>& ranges() const { return ranges_; } 64 const std::vector<Subrange>& ranges() const { return ranges_; }
53 bool empty() const { return ranges_.empty(); } 65 bool empty() const { return ranges_.empty(); }
54 66
55 private: 67 private:
56 std::vector<Subrange> ranges_; 68 std::vector<Subrange> ranges_;
69 const ParseNode* origin_;
57 70
58 std::vector<SubstitutionType> required_types_; 71 std::vector<SubstitutionType> required_types_;
59 }; 72 };
60 73
61 #endif // TOOLS_GN_SUBSTITUTION_PATTERN_H_ 74 #endif // TOOLS_GN_SUBSTITUTION_PATTERN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698