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

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

Issue 429423002: Refactor GN source expansions. (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
« no previous file with comments | « tools/gn/substitution_pattern_unittest.cc ('k') | tools/gn/substitution_type.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 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.
4
5 #ifndef TOOLS_GN_SUBSTITUTION_TYPE_H_
6 #define TOOLS_GN_SUBSTITUTION_TYPE_H_
7
8 #include <vector>
9
10 class Err;
11 class ParseNode;
12
13 // Keep kSubstitutionNames, kSubstitutionNinjaNames and the
14 // IsValid*Substutition functions in sync if you change anything here.
15 enum SubstitutionType {
16 SUBSTITUTION_LITERAL = 0,
17
18 // The index of the first pattern. To loop overal all patterns, go from here
19 // until NUM_TYPES.
20 SUBSTITUTION_FIRST_PATTERN,
21
22 SUBSTITUTION_SOURCE = SUBSTITUTION_FIRST_PATTERN, // {{source}}
23 SUBSTITUTION_SOURCE_NAME_PART, // {{source_name_part}}
24 SUBSTITUTION_SOURCE_FILE_PART, // {{source_file_part}}
25 SUBSTITUTION_SOURCE_DIR, // {{source_dir}}
26 SUBSTITUTION_SOURCE_ROOT_RELATIVE_DIR, // {{root_relative_dir}}
27 SUBSTITUTION_SOURCE_GEN_DIR, // {{source_gen_dir}}
28 SUBSTITUTION_SOURCE_OUT_DIR, // {{source_out_dir}}
29
30 // Valid for all compiler and linker tools (depends on target).
31 SUBSTITUTION_OUTPUT, // {{output}}
32 SUBSTITUTION_ROOT_GEN_DIR, // {{root_gen_dir}}
33 SUBSTITUTION_ROOT_OUT_DIR, // {{root_out_dir}}
34 SUBSTITUTION_TARGET_GEN_DIR, // {{target_gen_dir}}
35 SUBSTITUTION_TARGET_OUT_DIR, // {{target_out_dir}}
36 SUBSTITUTION_TARGET_OUTPUT_NAME, // {{target_output_name}}
37
38 // Valid for compiler tools.
39 SUBSTITUTION_CFLAGS, // {{cflags}}
40 SUBSTITUTION_CFLAGS_C, // {{cflags_c}}
41 SUBSTITUTION_CFLAGS_CC, // {{cflags_cc}}
42 SUBSTITUTION_CFLAGS_OBJC, // {{cflags_objc}}
43 SUBSTITUTION_CFLAGS_OBJCC, // {{cflags_objcc}}
44 SUBSTITUTION_DEFINES, // {{defines}}
45 SUBSTITUTION_INCLUDE_DIRS, // {{include_dirs}}
46
47 // Valid for linker tools.
48 SUBSTITUTION_LINKER_INPUTS, // {{inputs}}
49 SUBSTITUTION_LDFLAGS, // {{ldflags}}
50 SUBSTITUTION_LIBS, // {{libs}}
51 SUBSTITUTION_OUTPUT_EXTENSION, // {{output_extension}}
52 SUBSTITUTION_SOLIBS, // {{solibs}}
53
54 SUBSTITUTION_NUM_TYPES // Must be last.
55 };
56
57 // An array of size SUBSTITUTION_NUM_TYPES that lists the names of the
58 // substitution patterns, including the curly braces. So, for example,
59 // kSubstitutionNames[SUBSTITUTION_SOURCE] == "{{source}}".
60 extern const char* kSubstitutionNames[SUBSTITUTION_NUM_TYPES];
61
62 // Ninja variables corresponding to each substitution. These do not include
63 // the dollar sign.
64 extern const char* kSubstitutionNinjaNames[SUBSTITUTION_NUM_TYPES];
65
66 // Returns true if the given substitution pattern references the output
67 // directory. This is used to check strings that begin with a substitution to
68 // verify that the produce a file in the output directory.
69 bool SubstitutionIsInOutputDir(SubstitutionType type);
70
71 // Returns true if the given substitution is valid for the named purpose.
72 bool IsValidSourceSubstitution(SubstitutionType type);
73 // Both compiler and linker tools.
74 bool IsValidToolSubstutition(SubstitutionType type);
75 bool IsValidCompilerSubstitution(SubstitutionType type);
76 bool IsValidCompilerOutputsSubstitution(SubstitutionType type);
77 bool IsValidLinkerSubstitution(SubstitutionType type);
78 bool IsValidLinkerOutputsSubstitution(SubstitutionType type);
79
80 // Like the "IsValid..." version above but checks a list of types and sets a
81 // an error blaming the given source if the test fails.
82 bool EnsureValidSourcesSubstitutions(
83 const std::vector<SubstitutionType>& types,
84 const ParseNode* origin,
85 Err* err);
86
87 #endif // TOOLS_GN_SUBSTITUTION_TYPE_H_
OLDNEW
« no previous file with comments | « tools/gn/substitution_pattern_unittest.cc ('k') | tools/gn/substitution_type.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698