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 #ifndef TOOLS_GN_ITEM_H_
6 #define TOOLS_GN_ITEM_H_
10 #include "tools/gn/label.h"
11 #include "tools/gn/visibility.h"
19 // A named item (target, config, etc.) that participates in the dependency
23 Item(const Settings
* settings
, const Label
& label
);
26 const Settings
* settings() const { return settings_
; }
28 // This is guaranteed to never change after construction so this can be
29 // accessed from any thread with no locking once the item is constructed.
30 const Label
& label() const { return label_
; }
32 const ParseNode
* defined_from() const { return defined_from_
; }
33 void set_defined_from(const ParseNode
* df
) { defined_from_
= df
; }
35 Visibility
& visibility() { return visibility_
; }
36 const Visibility
& visibility() const { return visibility_
; }
39 virtual Config
* AsConfig();
40 virtual const Config
* AsConfig() const;
41 virtual Target
* AsTarget();
42 virtual const Target
* AsTarget() const;
43 virtual Toolchain
* AsToolchain();
44 virtual const Toolchain
* AsToolchain() const;
46 // Returns a name like "target" or "config" for the type of item this is, to
47 // be used in logging and error messages.
48 std::string
GetItemTypeName() const;
50 // Called when this item is resolved, meaning it and all of its dependents
51 // have no unresolved deps. Returns true on success. Sets the error and
52 // returns false on failure.
53 virtual bool OnResolved(Err
* err
);
56 const Settings
* settings_
;
58 const ParseNode
* defined_from_
;
60 Visibility visibility_
;
63 #endif // TOOLS_GN_ITEM_H_