1 // Copyright 2022 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_RESOLVED_TARGET_DATA_H_ 6 #define TOOLS_GN_RESOLVED_TARGET_DATA_H_ 7 8 #include <memory> 9 10 #include "gn/immutable_vector.h" 11 #include "gn/lib_file.h" 12 #include "gn/source_dir.h" 13 #include "gn/tagged_pointer.h" 14 #include "gn/target.h" 15 #include "gn/target_public_pair.h" 16 17 class Target; 18 19 // A list of (target_ptr, is_public_flag) pairs as returned by methods 20 // of ResolvedTargetData. 21 using TargetPublicPairList = ImmutableVectorView<TargetPublicPair>; 22 23 // A class used to compute data. 24 class ResolvedTargetData { 25 public: 26 ResolvedTargetData(); 27 ~ResolvedTargetData(); 28 29 // Move operations 30 ResolvedTargetData(ResolvedTargetData&&) noexcept; 31 ResolvedTargetData& operator=(ResolvedTargetData&&); 32 33 // Retrieve information about link-time libraries needed by this target. 34 struct LibInfo { 35 ImmutableVectorView<SourceDir> all_lib_dirs; 36 ImmutableVectorView<LibFile> all_libs; 37 }; 38 LibInfo GetLibInfo(const Target*) const; 39 40 ImmutableVectorView<SourceDir> all_lib_dirs(const Target* target) const; 41 42 ImmutableVectorView<LibFile> all_libs(const Target* target) const; 43 44 // Retrieve information about link-time OS X frameworks needed by this target. 45 struct FrameworkInfo { 46 ImmutableVector<SourceDir> all_framework_dirs; 47 ImmutableVector<std::string> all_frameworks; 48 ImmutableVector<std::string> all_weak_frameworks; 49 }; 50 FrameworkInfo GetFrameworkInfo(const Target* target) const; 51 52 ImmutableVectorView<SourceDir> all_framework_dirs(const Target* target) const; 53 54 ImmutableVectorView<std::string> all_frameworks(const Target* target) const; 55 56 ImmutableVectorView<std::string> all_weak_frameworks( 57 const Target* target) const; 58 59 // Retrieve a set of hard dependencies for this target. 60 TargetSet recursive_hard_deps(const Target* target) const; 61 62 // Retrieve an ordered list of (target, is_public) pairs for all link-time 63 // libraries inherited by this target. 64 TargetPublicPairList inherited_libraries(const Target* target) const; 65 66 // Retrieves an ordered list of (target, is_public) paris for all link-time 67 // libraries for Rust-specific binary targets. 68 TargetPublicPairList rust_transitive_inherited_libs( 69 const Target* target) const; 70 71 private: 72 class Impl; 73 74 Impl* GetImpl() const; 75 76 mutable std::unique_ptr<Impl> impl_; 77 }; 78 79 #endif // TOOLS_GN_RESOLVED_TARGET_DATA_H_ 80