Retry fdbff0e3b60139805609f643eb40:
[chromium-blink-merge.git] / tools / gn / builder_record.cc
blob842dbc4c556716ff23a19792f760804475e2f722
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
3 // found in the LICENSE file.
5 #include "tools/gn/builder_record.h"
7 #include "tools/gn/item.h"
9 BuilderRecord::BuilderRecord(ItemType type, const Label& label)
10 : type_(type),
11 label_(label),
12 originally_referenced_from_(nullptr),
13 should_generate_(false),
14 resolved_(false) {
17 BuilderRecord::~BuilderRecord() {
20 // static
21 const char* BuilderRecord::GetNameForType(ItemType type) {
22 switch (type) {
23 case ITEM_TARGET:
24 return "target";
25 case ITEM_CONFIG:
26 return "config";
27 case ITEM_TOOLCHAIN:
28 return "toolchain";
29 case ITEM_UNKNOWN:
30 default:
31 return "unknown";
35 // static
36 bool BuilderRecord::IsItemOfType(const Item* item, ItemType type) {
37 switch (type) {
38 case ITEM_TARGET:
39 return !!item->AsTarget();
40 case ITEM_CONFIG:
41 return !!item->AsConfig();
42 case ITEM_TOOLCHAIN:
43 return !!item->AsToolchain();
44 case ITEM_UNKNOWN:
45 default:
46 return false;
50 // static
51 BuilderRecord::ItemType BuilderRecord::TypeOfItem(const Item* item) {
52 if (item->AsTarget())
53 return ITEM_TARGET;
54 if (item->AsConfig())
55 return ITEM_CONFIG;
56 if (item->AsToolchain())
57 return ITEM_TOOLCHAIN;
59 NOTREACHED();
60 return ITEM_UNKNOWN;
63 void BuilderRecord::AddDep(BuilderRecord* record) {
64 all_deps_.insert(record);
65 if (!record->resolved()) {
66 unresolved_deps_.insert(record);
67 record->waiting_on_resolution_.insert(this);