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

Unified Diff: tools/gn/substitution_type.cc

Issue 2627703002: Validate GN substitutions in args and rsp files. (Closed)
Patch Set: Format Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/substitution_type.h ('k') | tools/gn/target_generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/substitution_type.cc
diff --git a/tools/gn/substitution_type.cc b/tools/gn/substitution_type.cc
index c6ea38597dd44c2118e9f5aa45bbc2e382b933eb..99b4e6802df7b49a250dffd4e812878b3ba69b6d 100644
--- a/tools/gn/substitution_type.cc
+++ b/tools/gn/substitution_type.cc
@@ -166,6 +166,11 @@ bool IsValidSourceSubstitution(SubstitutionType type) {
type == SUBSTITUTION_SOURCE_TARGET_RELATIVE;
}
+bool IsValidScriptArgsSubstitution(SubstitutionType type) {
+ return IsValidSourceSubstitution(type) ||
+ type == SUBSTITUTION_RSP_FILE_NAME;
+}
+
bool IsValidToolSubstitution(SubstitutionType type) {
return type == SUBSTITUTION_LITERAL ||
type == SUBSTITUTION_OUTPUT ||
@@ -236,14 +241,14 @@ bool IsValidCompileXCassetsSubstitution(SubstitutionType type) {
type == SUBSTITUTION_BUNDLE_PRODUCT_TYPE;
}
-bool EnsureValidSourcesSubstitutions(
- const std::vector<SubstitutionType>& types,
- const ParseNode* origin,
- Err* err) {
- for (size_t i = 0; i < types.size(); i++) {
- if (!IsValidSourceSubstitution(types[i])) {
+bool EnsureValidSubstitutions(const std::vector<SubstitutionType>& types,
+ bool (*is_valid_subst)(SubstitutionType),
+ const ParseNode* origin,
+ Err* err) {
+ for (SubstitutionType type : types) {
+ if (!is_valid_subst(type)) {
*err = Err(origin, "Invalid substitution type.",
- "The substitution " + std::string(kSubstitutionNames[types[i]]) +
+ "The substitution " + std::string(kSubstitutionNames[type]) +
" isn't valid for something\n"
"operating on a source file such as this.");
return false;
« no previous file with comments | « tools/gn/substitution_type.h ('k') | tools/gn/target_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698