Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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. | |
| 4 | |
| 5 #ifndef TOOLS_GN_INHERITED_LIBRARIES_H_ | |
| 6 #define TOOLS_GN_INHERITED_LIBRARIES_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <utility> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 | |
| 14 class Target; | |
| 15 | |
| 16 // Represents an ordered uniquified set of all shared/static libraries for | |
| 17 // a given target. These are pushed up the dependency tree. | |
|
Dirk Pranke
2015/04/15 19:31:38
why is ordered important?
| |
| 18 // | |
| 19 // Since this list is uniquified, appending to the list will not actually | |
| 20 // append a new item if the target already exists. However, the existing one | |
| 21 // may have its is_public flag updated. "Public" always wins, so is_public will | |
| 22 // be true if any dependency with that name has been set to public. | |
| 23 class InheritedLibraries { | |
| 24 public: | |
| 25 InheritedLibraries(); | |
| 26 ~InheritedLibraries(); | |
| 27 | |
| 28 // Returns the list of dependencies in order, optionally with the flag | |
| 29 // indicating whether the dependency is public. | |
| 30 std::vector<const Target*> GetOrdered() const; | |
| 31 std::vector<std::pair<const Target*, bool>> GetOrderedAndPublicFlag() const; | |
| 32 | |
| 33 // Adds a single dependency to the end of the list. See note on adding above. | |
| 34 void Append(const Target* target, bool is_public); | |
| 35 | |
| 36 // Appends all items from the "other" list to the current one. The is_public | |
| 37 // parameter indicates how the current target depends on the items in | |
| 38 // "other". If is_public is true, the existing public flags of the appended | |
| 39 // items will be preserved (propogating the public-ness up the dependency | |
| 40 // chain). If is_public is false, all deps will be added as private since | |
| 41 // the current target isn't forwarding them. | |
| 42 void AppendInherited(const InheritedLibraries& other, bool is_public); | |
| 43 | |
| 44 // Like AppendInherited but only appends the items in "other" that are of | |
| 45 // type SHARED_LIBRARY and only when they're marked public. This is used | |
| 46 // to push shared libraries up the dependency chain, following only public | |
| 47 // deps, to dependent targets that need to use them. | |
| 48 void AppendPublicSharedLibraries(const InheritedLibraries& other, | |
| 49 bool is_public); | |
| 50 | |
| 51 private: | |
| 52 struct Node { | |
| 53 Node() : index(static_cast<size_t>(-1)), is_public(false) {} | |
| 54 Node(size_t i, bool p) : index(i), is_public(p) {} | |
| 55 | |
| 56 size_t index; | |
| 57 bool is_public; | |
| 58 }; | |
| 59 | |
| 60 typedef std::map<const Target*, Node> LibraryMap; | |
| 61 LibraryMap map_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(InheritedLibraries); | |
| 64 }; | |
| 65 | |
| 66 #endif // TOOLS_GN_INHERITED_LIBRARIES_H_ | |
| OLD | NEW |