OLD | NEW |
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/builder.h" | 5 #include "tools/gn/builder.h" |
6 | 6 |
7 #include "tools/gn/config.h" | 7 #include "tools/gn/config.h" |
8 #include "tools/gn/err.h" | 8 #include "tools/gn/err.h" |
9 #include "tools/gn/loader.h" | 9 #include "tools/gn/loader.h" |
10 #include "tools/gn/scheduler.h" | 10 #include "tools/gn/scheduler.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 244 } |
245 | 245 |
246 BuilderRecord* Builder::GetOrCreateRecordOfType(const Label& label, | 246 BuilderRecord* Builder::GetOrCreateRecordOfType(const Label& label, |
247 const ParseNode* request_from, | 247 const ParseNode* request_from, |
248 BuilderRecord::ItemType type, | 248 BuilderRecord::ItemType type, |
249 Err* err) { | 249 Err* err) { |
250 BuilderRecord* record = GetRecord(label); | 250 BuilderRecord* record = GetRecord(label); |
251 if (!record) { | 251 if (!record) { |
252 // Not seen this record yet, create a new one. | 252 // Not seen this record yet, create a new one. |
253 record = new BuilderRecord(type, label); | 253 record = new BuilderRecord(type, label); |
| 254 record->set_originally_referenced_from(request_from); |
254 records_[label] = record; | 255 records_[label] = record; |
255 return record; | 256 return record; |
256 } | 257 } |
257 | 258 |
258 // Check types. | 259 // Check types. |
259 if (record->type() != type) { | 260 if (record->type() != type) { |
260 *err = Err(request_from, "Item type does not match.", | 261 *err = Err(request_from, "Item type does not match.", |
261 "The item \"" + label.GetUserVisibleName(false) + | 262 "The item \"" + label.GetUserVisibleName(false) + |
262 "\" was expected\nto be a " + | 263 "\"\nwas expected to be a " + |
263 BuilderRecord::GetNameForType(type) + | 264 BuilderRecord::GetNameForType(type) + |
264 " but was previously\n referenced as a " + | 265 " but was previously referenced as a " + |
265 BuilderRecord::GetNameForType(record->type())); | 266 BuilderRecord::GetNameForType(record->type())); |
266 err->AppendSubErr(Err(record->originally_referenced_from(), | 267 if (record->originally_referenced_from()) { |
267 "The previous reference was here.")); | 268 err->AppendSubErr(Err(record->originally_referenced_from(), |
| 269 "The previous reference was here.")); |
| 270 } |
268 return NULL; | 271 return NULL; |
269 } | 272 } |
270 | 273 |
271 return record; | 274 return record; |
272 } | 275 } |
273 | 276 |
274 BuilderRecord* Builder::GetResolvedRecordOfType(const Label& label, | 277 BuilderRecord* Builder::GetResolvedRecordOfType(const Label& label, |
275 const ParseNode* origin, | 278 const ParseNode* origin, |
276 BuilderRecord::ItemType type, | 279 BuilderRecord::ItemType type, |
277 Err* err) { | 280 Err* err) { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 // Walk backwards since the dependency arrows point in the reverse direction. | 465 // Walk backwards since the dependency arrows point in the reverse direction. |
463 std::string ret; | 466 std::string ret; |
464 for (int i = static_cast<int>(cycle.size()) - 1; i >= 0; i--) { | 467 for (int i = static_cast<int>(cycle.size()) - 1; i >= 0; i--) { |
465 ret += " " + cycle[i]->label().GetUserVisibleName(false); | 468 ret += " " + cycle[i]->label().GetUserVisibleName(false); |
466 if (i != 0) | 469 if (i != 0) |
467 ret += " ->\n"; | 470 ret += " ->\n"; |
468 } | 471 } |
469 | 472 |
470 return ret; | 473 return ret; |
471 } | 474 } |
OLD | NEW |