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

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

Issue 1750283003: Minor fixes to tools/gn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix last reference to IsValidToolSubstutition. Created 4 years, 9 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
« no previous file with comments | « tools/gn/substitution_type.h ('k') | tools/gn/substitution_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "tools/gn/substitution_type.h" 5 #include "tools/gn/substitution_type.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "tools/gn/err.h" 10 #include "tools/gn/err.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return type == SUBSTITUTION_LITERAL || 120 return type == SUBSTITUTION_LITERAL ||
121 type == SUBSTITUTION_SOURCE || 121 type == SUBSTITUTION_SOURCE ||
122 type == SUBSTITUTION_SOURCE_NAME_PART || 122 type == SUBSTITUTION_SOURCE_NAME_PART ||
123 type == SUBSTITUTION_SOURCE_FILE_PART || 123 type == SUBSTITUTION_SOURCE_FILE_PART ||
124 type == SUBSTITUTION_SOURCE_DIR || 124 type == SUBSTITUTION_SOURCE_DIR ||
125 type == SUBSTITUTION_SOURCE_ROOT_RELATIVE_DIR || 125 type == SUBSTITUTION_SOURCE_ROOT_RELATIVE_DIR ||
126 type == SUBSTITUTION_SOURCE_GEN_DIR || 126 type == SUBSTITUTION_SOURCE_GEN_DIR ||
127 type == SUBSTITUTION_SOURCE_OUT_DIR; 127 type == SUBSTITUTION_SOURCE_OUT_DIR;
128 } 128 }
129 129
130 bool IsValidToolSubstutition(SubstitutionType type) { 130 bool IsValidToolSubstitution(SubstitutionType type) {
brettw 2016/03/03 19:09:00 Wow, this is some awesome copy-and-paste thing I h
131 return type == SUBSTITUTION_LITERAL || 131 return type == SUBSTITUTION_LITERAL ||
132 type == SUBSTITUTION_OUTPUT || 132 type == SUBSTITUTION_OUTPUT ||
133 type == SUBSTITUTION_LABEL || 133 type == SUBSTITUTION_LABEL ||
134 type == SUBSTITUTION_LABEL_NAME || 134 type == SUBSTITUTION_LABEL_NAME ||
135 type == SUBSTITUTION_ROOT_GEN_DIR || 135 type == SUBSTITUTION_ROOT_GEN_DIR ||
136 type == SUBSTITUTION_ROOT_OUT_DIR || 136 type == SUBSTITUTION_ROOT_OUT_DIR ||
137 type == SUBSTITUTION_TARGET_GEN_DIR || 137 type == SUBSTITUTION_TARGET_GEN_DIR ||
138 type == SUBSTITUTION_TARGET_OUT_DIR || 138 type == SUBSTITUTION_TARGET_OUT_DIR ||
139 type == SUBSTITUTION_TARGET_OUTPUT_NAME; 139 type == SUBSTITUTION_TARGET_OUTPUT_NAME;
140 } 140 }
141 141
142 bool IsValidCompilerSubstitution(SubstitutionType type) { 142 bool IsValidCompilerSubstitution(SubstitutionType type) {
143 return IsValidToolSubstutition(type) || 143 return IsValidToolSubstitution(type) ||
144 IsValidSourceSubstitution(type) || 144 IsValidSourceSubstitution(type) ||
145 type == SUBSTITUTION_SOURCE || 145 type == SUBSTITUTION_SOURCE ||
146 type == SUBSTITUTION_ASMFLAGS || 146 type == SUBSTITUTION_ASMFLAGS ||
147 type == SUBSTITUTION_CFLAGS || 147 type == SUBSTITUTION_CFLAGS ||
148 type == SUBSTITUTION_CFLAGS_C || 148 type == SUBSTITUTION_CFLAGS_C ||
149 type == SUBSTITUTION_CFLAGS_CC || 149 type == SUBSTITUTION_CFLAGS_CC ||
150 type == SUBSTITUTION_CFLAGS_OBJC || 150 type == SUBSTITUTION_CFLAGS_OBJC ||
151 type == SUBSTITUTION_CFLAGS_OBJCC || 151 type == SUBSTITUTION_CFLAGS_OBJCC ||
152 type == SUBSTITUTION_DEFINES || 152 type == SUBSTITUTION_DEFINES ||
153 type == SUBSTITUTION_INCLUDE_DIRS; 153 type == SUBSTITUTION_INCLUDE_DIRS;
154 } 154 }
155 155
156 bool IsValidCompilerOutputsSubstitution(SubstitutionType type) { 156 bool IsValidCompilerOutputsSubstitution(SubstitutionType type) {
157 // All tool types except "output" (which would be infinitely recursive). 157 // All tool types except "output" (which would be infinitely recursive).
158 return (IsValidToolSubstutition(type) && type != SUBSTITUTION_OUTPUT) || 158 return (IsValidToolSubstitution(type) && type != SUBSTITUTION_OUTPUT) ||
159 IsValidSourceSubstitution(type); 159 IsValidSourceSubstitution(type);
160 } 160 }
161 161
162 bool IsValidLinkerSubstitution(SubstitutionType type) { 162 bool IsValidLinkerSubstitution(SubstitutionType type) {
163 return IsValidToolSubstutition(type) || 163 return IsValidToolSubstitution(type) ||
164 type == SUBSTITUTION_LINKER_INPUTS || 164 type == SUBSTITUTION_LINKER_INPUTS ||
165 type == SUBSTITUTION_LINKER_INPUTS_NEWLINE || 165 type == SUBSTITUTION_LINKER_INPUTS_NEWLINE ||
166 type == SUBSTITUTION_LDFLAGS || 166 type == SUBSTITUTION_LDFLAGS ||
167 type == SUBSTITUTION_LIBS || 167 type == SUBSTITUTION_LIBS ||
168 type == SUBSTITUTION_OUTPUT_EXTENSION || 168 type == SUBSTITUTION_OUTPUT_EXTENSION ||
169 type == SUBSTITUTION_SOLIBS; 169 type == SUBSTITUTION_SOLIBS;
170 } 170 }
171 171
172 bool IsValidLinkerOutputsSubstitution(SubstitutionType type) { 172 bool IsValidLinkerOutputsSubstitution(SubstitutionType type) {
173 // All valid compiler outputs plus the output extension. 173 // All valid compiler outputs plus the output extension.
174 return IsValidCompilerOutputsSubstitution(type) || 174 return IsValidCompilerOutputsSubstitution(type) ||
175 type == SUBSTITUTION_OUTPUT_EXTENSION; 175 type == SUBSTITUTION_OUTPUT_EXTENSION;
176 } 176 }
177 177
178 bool IsValidCopySubstitution(SubstitutionType type) { 178 bool IsValidCopySubstitution(SubstitutionType type) {
179 return IsValidToolSubstutition(type) || 179 return IsValidToolSubstitution(type) ||
180 type == SUBSTITUTION_SOURCE; 180 type == SUBSTITUTION_SOURCE;
181 } 181 }
182 182
183 bool EnsureValidSourcesSubstitutions( 183 bool EnsureValidSourcesSubstitutions(
184 const std::vector<SubstitutionType>& types, 184 const std::vector<SubstitutionType>& types,
185 const ParseNode* origin, 185 const ParseNode* origin,
186 Err* err) { 186 Err* err) {
187 for (size_t i = 0; i < types.size(); i++) { 187 for (size_t i = 0; i < types.size(); i++) {
188 if (!IsValidSourceSubstitution(types[i])) { 188 if (!IsValidSourceSubstitution(types[i])) {
189 *err = Err(origin, "Invalid substitution type.", 189 *err = Err(origin, "Invalid substitution type.",
190 "The substitution " + std::string(kSubstitutionNames[i]) + 190 "The substitution " + std::string(kSubstitutionNames[types[i]]) +
191 " isn't valid for something\n" 191 " isn't valid for something\n"
192 "operating on a source file such as this."); 192 "operating on a source file such as this.");
193 return false; 193 return false;
194 } 194 }
195 } 195 }
196 return true; 196 return true;
197 } 197 }
OLDNEW
« no previous file with comments | « tools/gn/substitution_type.h ('k') | tools/gn/substitution_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698