Rewrite apps::SavedDevicesService as extensions::DevicePermissionsManager.
[chromium-blink-merge.git] / tools / gn / substitution_type.h
blobe0f3a26e554011f62c679e73431adc10343b2b8b
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_SUBSTITUTION_TYPE_H_
6 #define TOOLS_GN_SUBSTITUTION_TYPE_H_
8 #include <vector>
10 class Err;
11 class ParseNode;
13 // Keep kSubstitutionNames, kSubstitutionNinjaNames and the
14 // IsValid*Substutition functions in sync if you change anything here.
15 enum SubstitutionType {
16 SUBSTITUTION_LITERAL = 0,
18 // The index of the first pattern. To loop overal all patterns, go from here
19 // until NUM_TYPES.
20 SUBSTITUTION_FIRST_PATTERN,
22 // These map to Ninja's {in} and {out} variables.
23 SUBSTITUTION_SOURCE = SUBSTITUTION_FIRST_PATTERN, // {{source}}
24 SUBSTITUTION_OUTPUT, // {{output}}
26 // Valid for all compiler tools.
27 SUBSTITUTION_SOURCE_NAME_PART, // {{source_name_part}}
28 SUBSTITUTION_SOURCE_FILE_PART, // {{source_file_part}}
29 SUBSTITUTION_SOURCE_DIR, // {{source_dir}}
30 SUBSTITUTION_SOURCE_ROOT_RELATIVE_DIR, // {{root_relative_dir}}
31 SUBSTITUTION_SOURCE_GEN_DIR, // {{source_gen_dir}}
32 SUBSTITUTION_SOURCE_OUT_DIR, // {{source_out_dir}}
34 // Valid for all compiler and linker tools. These depend on the target and
35 // no not vary on a per-file basis.
36 SUBSTITUTION_LABEL, // {{label}}
37 SUBSTITUTION_ROOT_GEN_DIR, // {{root_gen_dir}}
38 SUBSTITUTION_ROOT_OUT_DIR, // {{root_out_dir}}
39 SUBSTITUTION_TARGET_GEN_DIR, // {{target_gen_dir}}
40 SUBSTITUTION_TARGET_OUT_DIR, // {{target_out_dir}}
41 SUBSTITUTION_TARGET_OUTPUT_NAME, // {{target_output_name}}
43 // Valid for compiler tools.
44 SUBSTITUTION_CFLAGS, // {{cflags}}
45 SUBSTITUTION_CFLAGS_C, // {{cflags_c}}
46 SUBSTITUTION_CFLAGS_CC, // {{cflags_cc}}
47 SUBSTITUTION_CFLAGS_OBJC, // {{cflags_objc}}
48 SUBSTITUTION_CFLAGS_OBJCC, // {{cflags_objcc}}
49 SUBSTITUTION_DEFINES, // {{defines}}
50 SUBSTITUTION_INCLUDE_DIRS, // {{include_dirs}}
52 // Valid for linker tools.
53 SUBSTITUTION_LINKER_INPUTS, // {{inputs}}
54 SUBSTITUTION_LINKER_INPUTS_NEWLINE, // {{inputs_newline}}
55 SUBSTITUTION_LDFLAGS, // {{ldflags}}
56 SUBSTITUTION_LIBS, // {{libs}}
57 SUBSTITUTION_OUTPUT_EXTENSION, // {{output_extension}}
58 SUBSTITUTION_SOLIBS, // {{solibs}}
60 SUBSTITUTION_NUM_TYPES // Must be last.
63 // An array of size SUBSTITUTION_NUM_TYPES that lists the names of the
64 // substitution patterns, including the curly braces. So, for example,
65 // kSubstitutionNames[SUBSTITUTION_SOURCE] == "{{source}}".
66 extern const char* kSubstitutionNames[SUBSTITUTION_NUM_TYPES];
68 // Ninja variables corresponding to each substitution. These do not include
69 // the dollar sign.
70 extern const char* kSubstitutionNinjaNames[SUBSTITUTION_NUM_TYPES];
72 // A wrapper around an array if flags indicating whether a give substitution
73 // type is required in some context. By convention, the LITERAL type bit is
74 // not set.
75 struct SubstitutionBits {
76 SubstitutionBits();
78 // Merges any bits set in the given "other" to this one. This object will
79 // then be the union of all bits in the two lists.
80 void MergeFrom(const SubstitutionBits& other);
82 // Converts the substitution type bitfield (with a true set for each required
83 // item) to a vector of the types listed. Does not include LITERAL.
84 void FillVector(std::vector<SubstitutionType>* vect) const;
86 bool used[SUBSTITUTION_NUM_TYPES];
89 // Returns true if the given substitution pattern references the output
90 // directory. This is used to check strings that begin with a substitution to
91 // verify that the produce a file in the output directory.
92 bool SubstitutionIsInOutputDir(SubstitutionType type);
94 // Returns true if the given substitution is valid for the named purpose.
95 bool IsValidSourceSubstitution(SubstitutionType type);
96 // Both compiler and linker tools.
97 bool IsValidToolSubstutition(SubstitutionType type);
98 bool IsValidCompilerSubstitution(SubstitutionType type);
99 bool IsValidCompilerOutputsSubstitution(SubstitutionType type);
100 bool IsValidLinkerSubstitution(SubstitutionType type);
101 bool IsValidLinkerOutputsSubstitution(SubstitutionType type);
102 bool IsValidCopySubstitution(SubstitutionType type);
104 // Like the "IsValid..." version above but checks a list of types and sets a
105 // an error blaming the given source if the test fails.
106 bool EnsureValidSourcesSubstitutions(
107 const std::vector<SubstitutionType>& types,
108 const ParseNode* origin,
109 Err* err);
111 #endif // TOOLS_GN_SUBSTITUTION_TYPE_H_