Fixed incorrect call of updateContextMenuActionItems.
[chromium-blink-merge.git] / tools / gn / label_pattern.h
blobe805ffb62ef60dc82419f4baf6dbd9528ed6923b
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
3 // found in the LICENSE file.
5 #ifndef TOOLS_GN_LABEL_PATTERN_H_
6 #define TOOLS_GN_LABEL_PATTERN_H_
8 #include "base/strings/string_piece.h"
9 #include "tools/gn/label.h"
10 #include "tools/gn/source_dir.h"
12 class Err;
13 class Value;
15 extern const char kLabelPattern_Help[];
17 // A label pattern is a simple pattern that matches labels. It is used for
18 // specifying visibility and other times when multiple targets need to be
19 // referenced.
20 class LabelPattern {
21 public:
22 enum Type {
23 MATCH = 1, // Exact match for a given target.
24 DIRECTORY, // Only targets in the file in the given directory.
25 RECURSIVE_DIRECTORY // The given directory and any subdir.
26 // (also indicates "public" when dir is empty).
29 LabelPattern();
30 LabelPattern(Type type,
31 const SourceDir& dir,
32 const base::StringPiece& name,
33 const Label& toolchain_label);
34 ~LabelPattern();
36 // Converts the given input string to a pattern. This does special stuff
37 // to treat the pattern as a label. Sets the error on failure.
38 static LabelPattern GetPattern(const SourceDir& current_dir,
39 const Value& value,
40 Err* err);
42 // Returns true if this pattern matches the given label.
43 bool Matches(const Label& label) const;
45 // Returns a string representation of this pattern.
46 std::string Describe() const;
48 Type type() const { return type_; }
50 const SourceDir& dir() const { return dir_; }
51 const std::string& name() const { return name_; }
53 const Label& toolchain() const { return toolchain_; }
54 void set_toolchain(const Label& tc) { toolchain_ = tc; }
56 private:
57 // If nonempty, specifies the toolchain to use. If empty, this will match
58 // all toolchains. This is independent of the match type.
59 Label toolchain_;
61 Type type_;
63 // Used when type_ == PRIVATE and PRIVATE_RECURSIVE. This specifies the
64 // directory that to which the pattern is private to.
65 SourceDir dir_;
67 // Empty name means match everything. Otherwise the name must match
68 // exactly.
69 std::string name_;
72 #endif // TOOLS_GN_LABEL_PATTERN_H_