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

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

Issue 1155713006: GN: Make file/dir resolving return errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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/source_file.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/value_extractors.h" 5 #include "tools/gn/value_extractors.h"
6 6
7 #include "tools/gn/build_settings.h" 7 #include "tools/gn/build_settings.h"
8 #include "tools/gn/err.h" 8 #include "tools/gn/err.h"
9 #include "tools/gn/label.h" 9 #include "tools/gn/label.h"
10 #include "tools/gn/source_dir.h" 10 #include "tools/gn/source_dir.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return true; 58 return true;
59 } 59 }
60 60
61 struct RelativeFileConverter { 61 struct RelativeFileConverter {
62 RelativeFileConverter(const BuildSettings* build_settings_in, 62 RelativeFileConverter(const BuildSettings* build_settings_in,
63 const SourceDir& current_dir_in) 63 const SourceDir& current_dir_in)
64 : build_settings(build_settings_in), 64 : build_settings(build_settings_in),
65 current_dir(current_dir_in) { 65 current_dir(current_dir_in) {
66 } 66 }
67 bool operator()(const Value& v, SourceFile* out, Err* err) const { 67 bool operator()(const Value& v, SourceFile* out, Err* err) const {
68 if (!v.VerifyTypeIs(Value::STRING, err)) 68 *out = current_dir.ResolveRelativeFile(v, err,
69 return false;
70 *out = current_dir.ResolveRelativeFile(v.string_value(),
71 build_settings->root_path_utf8()); 69 build_settings->root_path_utf8());
72 return true; 70 return !err->has_error();
73 } 71 }
74 const BuildSettings* build_settings; 72 const BuildSettings* build_settings;
75 const SourceDir& current_dir; 73 const SourceDir& current_dir;
76 }; 74 };
77 75
78 struct RelativeDirConverter { 76 struct RelativeDirConverter {
79 RelativeDirConverter(const BuildSettings* build_settings_in, 77 RelativeDirConverter(const BuildSettings* build_settings_in,
80 const SourceDir& current_dir_in) 78 const SourceDir& current_dir_in)
81 : build_settings(build_settings_in), 79 : build_settings(build_settings_in),
82 current_dir(current_dir_in) { 80 current_dir(current_dir_in) {
83 } 81 }
84 bool operator()(const Value& v, SourceDir* out, Err* err) const { 82 bool operator()(const Value& v, SourceDir* out, Err* err) const {
85 if (!v.VerifyTypeIs(Value::STRING, err)) 83 *out = current_dir.ResolveRelativeDir(v, err,
86 return false;
87 *out = current_dir.ResolveRelativeDir(v.string_value(),
88 build_settings->root_path_utf8()); 84 build_settings->root_path_utf8());
89 return true; 85 return true;
90 } 86 }
91 const BuildSettings* build_settings; 87 const BuildSettings* build_settings;
92 const SourceDir& current_dir; 88 const SourceDir& current_dir;
93 }; 89 };
94 90
95 // Fills in a label. 91 // Fills in a label.
96 template<typename T> struct LabelResolver { 92 template<typename T> struct LabelResolver {
97 LabelResolver(const SourceDir& current_dir_in, 93 LabelResolver(const SourceDir& current_dir_in,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 197 }
202 198
203 bool ExtractRelativeFile(const BuildSettings* build_settings, 199 bool ExtractRelativeFile(const BuildSettings* build_settings,
204 const Value& value, 200 const Value& value,
205 const SourceDir& current_dir, 201 const SourceDir& current_dir,
206 SourceFile* file, 202 SourceFile* file,
207 Err* err) { 203 Err* err) {
208 RelativeFileConverter converter(build_settings, current_dir); 204 RelativeFileConverter converter(build_settings, current_dir);
209 return converter(value, file, err); 205 return converter(value, file, err);
210 } 206 }
OLDNEW
« no previous file with comments | « tools/gn/source_file.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698