OLD | NEW |
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 #include "tools/gn/substitution_type.h" | 5 #include "tools/gn/substitution_type.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "tools/gn/err.h" | 9 #include "tools/gn/err.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 "{{source_gen_dir}}", // SUBSTITUTION_SOURCE_GEN_DIR | 21 "{{source_gen_dir}}", // SUBSTITUTION_SOURCE_GEN_DIR |
22 "{{source_out_dir}}", // SUBSTITUTION_SOURCE_OUT_DIR | 22 "{{source_out_dir}}", // SUBSTITUTION_SOURCE_OUT_DIR |
23 | 23 |
24 "{{label}}", // SUBSTITUTION_LABEL | 24 "{{label}}", // SUBSTITUTION_LABEL |
25 "{{root_gen_dir}}", // SUBSTITUTION_ROOT_GEN_DIR | 25 "{{root_gen_dir}}", // SUBSTITUTION_ROOT_GEN_DIR |
26 "{{root_out_dir}}", // SUBSTITUTION_ROOT_OUT_DIR | 26 "{{root_out_dir}}", // SUBSTITUTION_ROOT_OUT_DIR |
27 "{{target_gen_dir}}", // SUBSTITUTION_TARGET_GEN_DIR | 27 "{{target_gen_dir}}", // SUBSTITUTION_TARGET_GEN_DIR |
28 "{{target_out_dir}}", // SUBSTITUTION_TARGET_OUT_DIR | 28 "{{target_out_dir}}", // SUBSTITUTION_TARGET_OUT_DIR |
29 "{{target_output_name}}", // SUBSTITUTION_TARGET_OUTPUT_NAME | 29 "{{target_output_name}}", // SUBSTITUTION_TARGET_OUTPUT_NAME |
30 | 30 |
| 31 "{{arflags}}", // SUBSTITUTION_ARFLAGS |
31 "{{cflags}}", // SUBSTITUTION_CFLAGS | 32 "{{cflags}}", // SUBSTITUTION_CFLAGS |
32 "{{cflags_c}}", // SUBSTITUTION_CFLAGS_C | 33 "{{cflags_c}}", // SUBSTITUTION_CFLAGS_C |
33 "{{cflags_cc}}", // SUBSTITUTION_CFLAGS_CC | 34 "{{cflags_cc}}", // SUBSTITUTION_CFLAGS_CC |
34 "{{cflags_objc}}", // SUBSTITUTION_CFLAGS_OBJC | 35 "{{cflags_objc}}", // SUBSTITUTION_CFLAGS_OBJC |
35 "{{cflags_objcc}}", // SUBSTITUTION_CFLAGS_OBJCC | 36 "{{cflags_objcc}}", // SUBSTITUTION_CFLAGS_OBJCC |
36 "{{defines}}", // SUBSTITUTION_DEFINES | 37 "{{defines}}", // SUBSTITUTION_DEFINES |
37 "{{include_dirs}}", // SUBSTITUTION_INCLUDE_DIRS | 38 "{{include_dirs}}", // SUBSTITUTION_INCLUDE_DIRS |
38 | 39 |
39 "{{inputs}}", // SUBSTITUTION_LINKER_INPUTS | 40 "{{inputs}}", // SUBSTITUTION_LINKER_INPUTS |
40 "{{inputs_newline}}", // SUBSTITUTION_LINKER_INPUTS_NEWLINE | 41 "{{inputs_newline}}", // SUBSTITUTION_LINKER_INPUTS_NEWLINE |
(...skipping 16 matching lines...) Expand all Loading... |
57 "source_gen_dir", // SUBSTITUTION_SOURCE_GEN_DIR | 58 "source_gen_dir", // SUBSTITUTION_SOURCE_GEN_DIR |
58 "source_out_dir", // SUBSTITUTION_SOURCE_OUT_DIR | 59 "source_out_dir", // SUBSTITUTION_SOURCE_OUT_DIR |
59 | 60 |
60 "label", // SUBSTITUTION_LABEL | 61 "label", // SUBSTITUTION_LABEL |
61 "root_gen_dir", // SUBSTITUTION_ROOT_GEN_DIR | 62 "root_gen_dir", // SUBSTITUTION_ROOT_GEN_DIR |
62 "root_out_dir", // SUBSTITUTION_ROOT_OUT_DIR | 63 "root_out_dir", // SUBSTITUTION_ROOT_OUT_DIR |
63 "target_gen_dir", // SUBSTITUTION_TARGET_GEN_DIR | 64 "target_gen_dir", // SUBSTITUTION_TARGET_GEN_DIR |
64 "target_out_dir", // SUBSTITUTION_TARGET_OUT_DIR | 65 "target_out_dir", // SUBSTITUTION_TARGET_OUT_DIR |
65 "target_output_name", // SUBSTITUTION_TARGET_OUTPUT_NAME | 66 "target_output_name", // SUBSTITUTION_TARGET_OUTPUT_NAME |
66 | 67 |
| 68 "arflags", // SUBSTITUTION_ARFLAGS |
67 "cflags", // SUBSTITUTION_CFLAGS | 69 "cflags", // SUBSTITUTION_CFLAGS |
68 "cflags_c", // SUBSTITUTION_CFLAGS_C | 70 "cflags_c", // SUBSTITUTION_CFLAGS_C |
69 "cflags_cc", // SUBSTITUTION_CFLAGS_CC | 71 "cflags_cc", // SUBSTITUTION_CFLAGS_CC |
70 "cflags_objc", // SUBSTITUTION_CFLAGS_OBJC | 72 "cflags_objc", // SUBSTITUTION_CFLAGS_OBJC |
71 "cflags_objcc", // SUBSTITUTION_CFLAGS_OBJCC | 73 "cflags_objcc", // SUBSTITUTION_CFLAGS_OBJCC |
72 "defines", // SUBSTITUTION_DEFINES | 74 "defines", // SUBSTITUTION_DEFINES |
73 "include_dirs", // SUBSTITUTION_INCLUDE_DIRS | 75 "include_dirs", // SUBSTITUTION_INCLUDE_DIRS |
74 | 76 |
75 // LINKER_INPUTS expands to the same Ninja var as SUBSTITUTION_SOURCE. These | 77 // LINKER_INPUTS expands to the same Ninja var as SUBSTITUTION_SOURCE. These |
76 // are used in different contexts and are named differently to keep things | 78 // are used in different contexts and are named differently to keep things |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 bool IsValidCompilerOutputsSubstitution(SubstitutionType type) { | 147 bool IsValidCompilerOutputsSubstitution(SubstitutionType type) { |
146 // All tool types except "output" (which would be infinitely recursive). | 148 // All tool types except "output" (which would be infinitely recursive). |
147 return (IsValidToolSubstutition(type) && type != SUBSTITUTION_OUTPUT) || | 149 return (IsValidToolSubstutition(type) && type != SUBSTITUTION_OUTPUT) || |
148 IsValidSourceSubstitution(type); | 150 IsValidSourceSubstitution(type); |
149 } | 151 } |
150 | 152 |
151 bool IsValidLinkerSubstitution(SubstitutionType type) { | 153 bool IsValidLinkerSubstitution(SubstitutionType type) { |
152 return IsValidToolSubstutition(type) || | 154 return IsValidToolSubstutition(type) || |
153 type == SUBSTITUTION_LINKER_INPUTS || | 155 type == SUBSTITUTION_LINKER_INPUTS || |
154 type == SUBSTITUTION_LINKER_INPUTS_NEWLINE || | 156 type == SUBSTITUTION_LINKER_INPUTS_NEWLINE || |
| 157 type == SUBSTITUTION_ARFLAGS || |
155 type == SUBSTITUTION_LDFLAGS || | 158 type == SUBSTITUTION_LDFLAGS || |
156 type == SUBSTITUTION_LIBS || | 159 type == SUBSTITUTION_LIBS || |
157 type == SUBSTITUTION_OUTPUT_EXTENSION || | 160 type == SUBSTITUTION_OUTPUT_EXTENSION || |
158 type == SUBSTITUTION_SOLIBS; | 161 type == SUBSTITUTION_SOLIBS; |
159 } | 162 } |
160 | 163 |
161 bool IsValidLinkerOutputsSubstitution(SubstitutionType type) { | 164 bool IsValidLinkerOutputsSubstitution(SubstitutionType type) { |
162 // All valid compiler outputs plus the output extension. | 165 // All valid compiler outputs plus the output extension. |
163 return IsValidCompilerOutputsSubstitution(type) || | 166 return IsValidCompilerOutputsSubstitution(type) || |
164 type == SUBSTITUTION_OUTPUT_EXTENSION; | 167 type == SUBSTITUTION_OUTPUT_EXTENSION; |
(...skipping 12 matching lines...) Expand all Loading... |
177 if (!IsValidSourceSubstitution(types[i])) { | 180 if (!IsValidSourceSubstitution(types[i])) { |
178 *err = Err(origin, "Invalid substitution type.", | 181 *err = Err(origin, "Invalid substitution type.", |
179 "The substitution " + std::string(kSubstitutionNames[i]) + | 182 "The substitution " + std::string(kSubstitutionNames[i]) + |
180 " isn't valid for something\n" | 183 " isn't valid for something\n" |
181 "operating on a source file such as this."); | 184 "operating on a source file such as this."); |
182 return false; | 185 return false; |
183 } | 186 } |
184 } | 187 } |
185 return true; | 188 return true; |
186 } | 189 } |
OLD | NEW |