Class: XcodeArchiveCache::BuildGraph::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/build_graph/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, native_target, is_root = false) ⇒ Node



41
42
43
44
45
46
47
48
# File 'lib/build_graph/node.rb', line 41

def initialize(name, native_target, is_root = false)
  @name = name
  @native_target = native_target
  @is_root = is_root
  @dependent = []
  @dependencies = []
  @state = :unknown
end

Instance Attribute Details

#build_settingsXcodeArchiveCache::BuildSettings::Container



35
36
37
# File 'lib/build_graph/node.rb', line 35

def build_settings
  @build_settings
end

#dependenciesArray<XcodeArchiveCache::BuildGraph::Node> (readonly)



27
28
29
# File 'lib/build_graph/node.rb', line 27

def dependencies
  @dependencies
end

#dependentArray<XcodeArchiveCache::BuildGraph::Node> (readonly)



23
24
25
# File 'lib/build_graph/node.rb', line 23

def dependent
  @dependent
end

#is_rootBoolean (readonly)



11
12
13
# File 'lib/build_graph/node.rb', line 11

def is_root
  @is_root
end

#nameString (readonly)



7
8
9
# File 'lib/build_graph/node.rb', line 7

def name
  @name
end

#native_targetXcodeproj::Project::Object::PBXNativeTarget (readonly)



31
32
33
# File 'lib/build_graph/node.rb', line 31

def native_target
  @native_target
end

#shaString



19
20
21
# File 'lib/build_graph/node.rb', line 19

def sha
  @sha
end

#stateSymbol



15
16
17
# File 'lib/build_graph/node.rb', line 15

def state
  @state
end

Instance Method Details

#==(other_node) ⇒ Object



113
114
115
# File 'lib/build_graph/node.rb', line 113

def ==(other_node)
  other_node && native_target.uuid == other_node.native_target.uuid && native_target.project == other_node.native_target.project
end

#all_dependent_nodesArray<Node>



97
98
99
# File 'lib/build_graph/node.rb', line 97

def all_dependent_nodes
  (dependent + dependent.map(&:all_dependent_nodes)).flatten.uniq
end

#dsym_file_nameString



88
89
90
91
92
# File 'lib/build_graph/node.rb', line 88

def dsym_file_name
  return nil unless build_settings

  build_settings[XcodeArchiveCache::BuildSettings::DWARF_DSYM_FILE_NAME_KEY]
end

#has_acceptable_product?Boolean



62
63
64
# File 'lib/build_graph/node.rb', line 62

def has_acceptable_product?
  ACCEPTABLE_PRODUCT_TYPES.include?(native_target.product_type)
end

#has_bundle_product?Boolean



58
59
60
# File 'lib/build_graph/node.rb', line 58

def has_bundle_product?
  native_target.product_type == Xcodeproj::Constants::PRODUCT_TYPE_UTI[:bundle]
end

#has_framework_product?Boolean



50
51
52
# File 'lib/build_graph/node.rb', line 50

def has_framework_product?
  native_target.product_type == Xcodeproj::Constants::PRODUCT_TYPE_UTI[:framework]
end

#has_static_library_product?Boolean



54
55
56
# File 'lib/build_graph/node.rb', line 54

def has_static_library_product?
  native_target.product_type == Xcodeproj::Constants::PRODUCT_TYPE_UTI[:static_library]
end

#product_file_nameString



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/build_graph/node.rb', line 68

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

#subgraphArray<Node>



103
104
105
# File 'lib/build_graph/node.rb', line 103

def subgraph
  ([self] + dependencies + dependencies.map(&:subgraph)).flatten.uniq
end

#to_sObject



117
118
119
120
121
122
# File 'lib/build_graph/node.rb', line 117

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_rebuildBool



109
110
111
# File 'lib/build_graph/node.rb', line 109

def waiting_for_rebuild
  state == :waiting_for_rebuild
end