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

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

Issue 1530183005: Special-case paths that appear in libs by not prefixing them with -l. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo in previous patch Created 4 years, 12 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/value_extractors.h ('k') | tools/gn/variables.cc » ('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 (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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 *out = current_dir.ResolveRelativeFile(v, err, 68 *out = current_dir.ResolveRelativeFile(v, err,
69 build_settings->root_path_utf8()); 69 build_settings->root_path_utf8());
70 return !err->has_error(); 70 return !err->has_error();
71 } 71 }
72 const BuildSettings* build_settings; 72 const BuildSettings* build_settings;
73 const SourceDir& current_dir; 73 const SourceDir& current_dir;
74 }; 74 };
75 75
76 struct LibFileConverter {
77 LibFileConverter(const BuildSettings* build_settings_in,
78 const SourceDir& current_dir_in)
79 : build_settings(build_settings_in),
80 current_dir(current_dir_in) {
81 }
82 bool operator()(const Value& v, LibFile* out, Err* err) const {
83 if (!v.VerifyTypeIs(Value::STRING, err))
84 return false;
85 if (v.string_value().find('/') == std::string::npos) {
86 *out = LibFile(v.string_value());
87 } else {
88 *out = LibFile(current_dir.ResolveRelativeFile(
89 v, err, build_settings->root_path_utf8()));
90 }
91 return !err->has_error();
92 }
93 const BuildSettings* build_settings;
94 const SourceDir& current_dir;
95 };
96
76 struct RelativeDirConverter { 97 struct RelativeDirConverter {
77 RelativeDirConverter(const BuildSettings* build_settings_in, 98 RelativeDirConverter(const BuildSettings* build_settings_in,
78 const SourceDir& current_dir_in) 99 const SourceDir& current_dir_in)
79 : build_settings(build_settings_in), 100 : build_settings(build_settings_in),
80 current_dir(current_dir_in) { 101 current_dir(current_dir_in) {
81 } 102 }
82 bool operator()(const Value& v, SourceDir* out, Err* err) const { 103 bool operator()(const Value& v, SourceDir* out, Err* err) const {
83 *out = current_dir.ResolveRelativeDir(v, err, 104 *out = current_dir.ResolveRelativeDir(v, err,
84 build_settings->root_path_utf8()); 105 build_settings->root_path_utf8());
85 return true; 106 return true;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 161
141 bool ExtractListOfRelativeFiles(const BuildSettings* build_settings, 162 bool ExtractListOfRelativeFiles(const BuildSettings* build_settings,
142 const Value& value, 163 const Value& value,
143 const SourceDir& current_dir, 164 const SourceDir& current_dir,
144 std::vector<SourceFile>* files, 165 std::vector<SourceFile>* files,
145 Err* err) { 166 Err* err) {
146 return ListValueExtractor(value, files, err, 167 return ListValueExtractor(value, files, err,
147 RelativeFileConverter(build_settings, current_dir)); 168 RelativeFileConverter(build_settings, current_dir));
148 } 169 }
149 170
171 bool ExtractListOfLibs(const BuildSettings* build_settings,
172 const Value& value,
173 const SourceDir& current_dir,
174 std::vector<LibFile>* libs,
175 Err* err) {
176 return ListValueExtractor(value, libs, err,
177 LibFileConverter(build_settings, current_dir));
178 }
179
150 bool ExtractListOfRelativeDirs(const BuildSettings* build_settings, 180 bool ExtractListOfRelativeDirs(const BuildSettings* build_settings,
151 const Value& value, 181 const Value& value,
152 const SourceDir& current_dir, 182 const SourceDir& current_dir,
153 std::vector<SourceDir>* dest, 183 std::vector<SourceDir>* dest,
154 Err* err) { 184 Err* err) {
155 return ListValueExtractor(value, dest, err, 185 return ListValueExtractor(value, dest, err,
156 RelativeDirConverter(build_settings, current_dir)); 186 RelativeDirConverter(build_settings, current_dir));
157 } 187 }
158 188
159 bool ExtractListOfLabels(const Value& value, 189 bool ExtractListOfLabels(const Value& value,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 227 }
198 228
199 bool ExtractRelativeFile(const BuildSettings* build_settings, 229 bool ExtractRelativeFile(const BuildSettings* build_settings,
200 const Value& value, 230 const Value& value,
201 const SourceDir& current_dir, 231 const SourceDir& current_dir,
202 SourceFile* file, 232 SourceFile* file,
203 Err* err) { 233 Err* err) {
204 RelativeFileConverter converter(build_settings, current_dir); 234 RelativeFileConverter converter(build_settings, current_dir);
205 return converter(value, file, err); 235 return converter(value, file, err);
206 } 236 }
OLDNEW
« no previous file with comments | « tools/gn/value_extractors.h ('k') | tools/gn/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698