Class: XcodeArchiveCache::BuildGraph::Node
- Inherits:
-
Object
- Object
- XcodeArchiveCache::BuildGraph::Node
- Defined in:
- lib/build_graph/node.rb
Instance Attribute Summary collapse
- #build_settings ⇒ XcodeArchiveCache::BuildSettings::Container
-
#dependencies ⇒ Array<XcodeArchiveCache::BuildGraph::Node>
readonly
Dependency nodes.
-
#dependent ⇒ Array<XcodeArchiveCache::BuildGraph::Node>
readonly
Dependent nodes.
- #is_root ⇒ Boolean readonly
-
#name ⇒ String
readonly
Native target display name.
-
#native_target ⇒ Xcodeproj::Project::Object::PBXNativeTarget
readonly
Corresponding native target.
-
#sha ⇒ String
Sha256 of (input files + build settings + dependency shas).
-
#state ⇒ Symbol
Should target be rebuilt.
- #targets_injected_to ⇒ Array<Xcodeproj::Project::Object::PBXNativeTarget> readonly
Instance Method Summary collapse
- #==(other_node) ⇒ Object
-
#all_dependent_nodes ⇒ Array<Node>
Direct + transitive dependents.
- #dsym_file_name ⇒ String
- #has_acceptable_product? ⇒ Boolean
- #has_bundle_product? ⇒ Boolean
- #has_framework_product? ⇒ Boolean
- #has_static_library_product? ⇒ Boolean
-
#initialize(name, native_target, is_root = false) ⇒ Node
constructor
A new instance of Node.
- #module_name ⇒ String
- #modulemap_file_name ⇒ String
- #original_modulemap_file_path ⇒ String
- #product_file_name ⇒ String
- #resulting_modulemap_file_name ⇒ String
- #subgraph ⇒ Array<Node>
- #swift_objc_interface_header_file ⇒ String
- #to_s ⇒ Object
- #waiting_for_rebuild ⇒ Bool
Constructor Details
#initialize(name, native_target, is_root = false) ⇒ Node
Returns a new instance of Node.
45 46 47 48 49 50 51 52 53 |
# File 'lib/build_graph/node.rb', line 45 def initialize(name, native_target, is_root = false) @name = name @native_target = native_target @is_root = is_root @dependent = [] @dependencies = [] @targets_injected_to = [] @state = :unknown end |
Instance Attribute Details
#build_settings ⇒ XcodeArchiveCache::BuildSettings::Container
35 36 37 |
# File 'lib/build_graph/node.rb', line 35 def build_settings @build_settings end |
#dependencies ⇒ Array<XcodeArchiveCache::BuildGraph::Node> (readonly)
Returns dependency nodes.
27 28 29 |
# File 'lib/build_graph/node.rb', line 27 def dependencies @dependencies end |
#dependent ⇒ Array<XcodeArchiveCache::BuildGraph::Node> (readonly)
Returns dependent nodes.
23 24 25 |
# File 'lib/build_graph/node.rb', line 23 def dependent @dependent end |
#is_root ⇒ Boolean (readonly)
11 12 13 |
# File 'lib/build_graph/node.rb', line 11 def is_root @is_root end |
#name ⇒ String (readonly)
Returns native target display name.
7 8 9 |
# File 'lib/build_graph/node.rb', line 7 def name @name end |
#native_target ⇒ Xcodeproj::Project::Object::PBXNativeTarget (readonly)
Returns corresponding native target.
31 32 33 |
# File 'lib/build_graph/node.rb', line 31 def native_target @native_target end |
#sha ⇒ String
Returns sha256 of (input files + build settings + dependency shas).
19 20 21 |
# File 'lib/build_graph/node.rb', line 19 def sha @sha end |
#state ⇒ Symbol
Returns should target be rebuilt.
15 16 17 |
# File 'lib/build_graph/node.rb', line 15 def state @state end |
#targets_injected_to ⇒ Array<Xcodeproj::Project::Object::PBXNativeTarget> (readonly)
39 40 41 |
# File 'lib/build_graph/node.rb', line 39 def targets_injected_to @targets_injected_to end |
Instance Method Details
#==(other_node) ⇒ Object
161 162 163 |
# File 'lib/build_graph/node.rb', line 161 def ==(other_node) other_node && native_target.uuid == other_node.native_target.uuid && native_target.project == other_node.native_target.project end |
#all_dependent_nodes ⇒ Array<Node>
Returns Direct + transitive dependents.
145 146 147 |
# File 'lib/build_graph/node.rb', line 145 def all_dependent_nodes (dependent + dependent.map(&:all_dependent_nodes)).flatten.uniq end |
#dsym_file_name ⇒ String
93 94 95 |
# File 'lib/build_graph/node.rb', line 93 def dsym_file_name build_settings ? build_settings[XcodeArchiveCache::BuildSettings::DWARF_DSYM_FILE_NAME_KEY] : nil end |
#has_acceptable_product? ⇒ Boolean
67 68 69 |
# File 'lib/build_graph/node.rb', line 67 def has_acceptable_product? ACCEPTABLE_PRODUCT_TYPES.include?(native_target.product_type) end |
#has_bundle_product? ⇒ Boolean
63 64 65 |
# File 'lib/build_graph/node.rb', line 63 def has_bundle_product? native_target.product_type == Xcodeproj::Constants::PRODUCT_TYPE_UTI[:bundle] end |
#has_framework_product? ⇒ Boolean
55 56 57 |
# File 'lib/build_graph/node.rb', line 55 def has_framework_product? native_target.product_type == Xcodeproj::Constants::PRODUCT_TYPE_UTI[:framework] end |
#has_static_library_product? ⇒ Boolean
59 60 61 |
# File 'lib/build_graph/node.rb', line 59 def has_static_library_product? native_target.product_type == Xcodeproj::Constants::PRODUCT_TYPE_UTI[:static_library] end |
#module_name ⇒ String
132 133 134 |
# File 'lib/build_graph/node.rb', line 132 def module_name build_settings[XcodeArchiveCache::BuildSettings::PRODUCT_MODULE_NAME_KEY] end |
#modulemap_file_name ⇒ String
138 139 140 |
# File 'lib/build_graph/node.rb', line 138 def modulemap_file_name build_settings[XcodeArchiveCache::BuildSettings::MODULEMAP_FILE_KEY] end |
#original_modulemap_file_path ⇒ String
99 100 101 102 103 104 |
# File 'lib/build_graph/node.rb', line 99 def original_modulemap_file_path modulemap_file = modulemap_file_name return unless modulemap_file Pathname.new(modulemap_file).absolute? ? modulemap_file : File.join(File.dirname(native_target.project.path), modulemap_file) end |
#product_file_name ⇒ String
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/build_graph/node.rb', line 73 def product_file_name return nil unless build_settings product_name = build_settings[XcodeArchiveCache::BuildSettings::FULL_PRODUCT_NAME_KEY] return product_name if product_name product_name = native_target.product_reference.name if has_framework_product? && product_name product_file_name = product_name end unless product_file_name product_file_name = File.basename(native_target.product_reference.real_path) end product_file_name end |
#resulting_modulemap_file_name ⇒ String
108 109 110 111 112 113 114 |
# File 'lib/build_graph/node.rb', line 108 def resulting_modulemap_file_name if module_name module_name + ".modulemap" else File.basename(modulemap_file_name) end end |
#subgraph ⇒ Array<Node>
151 152 153 |
# File 'lib/build_graph/node.rb', line 151 def subgraph ([self] + dependencies + dependencies.map(&:subgraph)).flatten.uniq end |
#swift_objc_interface_header_file ⇒ String
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/build_graph/node.rb', line 118 def swift_objc_interface_header_file header_file = build_settings[XcodeArchiveCache::BuildSettings::SWIFT_OBJC_INTERFACE_HEADER_NAME_KEY] if header_file == nil our_module_name = module_name return if our_module_name == nil header_file = our_module_name + "-Swift.h" end header_file end |
#to_s ⇒ Object
165 166 167 168 169 170 |
# File 'lib/build_graph/node.rb', line 165 def to_s sha_string = sha ? sha : "<none>" dependent_names = dependent.length > 0 ? dependent.map(&:name).join(", ") : "<none>" dependency_names = dependencies.length > 0 ? dependencies.map(&:name).join(", ") : "<none>" "#{name}\n\troot: #{is_root}\n\tproduct: #{product_file_name}\n\tsha: #{sha_string}\n\tstate: #{state}\n\tdependent: #{dependent_names}\n\tdependencies: #{dependency_names}" end |
#waiting_for_rebuild ⇒ Bool
157 158 159 |
# File 'lib/build_graph/node.rb', line 157 def waiting_for_rebuild state == :waiting_for_rebuild end |