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

Returns a new instance of Node.

Parameters:

  • name (String)
  • native_target (Xcodeproj::Project::Object::PBXNativeTarget)
  • is_root (Boolean) (defaults to: false)


41
42
43
44
45
46
47
# 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 = []
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)

Returns dependency nodes.

Returns:



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

def dependencies
  @dependencies
end

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

Returns dependent nodes.

Returns:



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

def dependent
  @dependent
end

#is_rootBoolean (readonly)

Returns:

  • (Boolean)


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

def is_root
  @is_root
end

#nameString (readonly)

Returns native target display name.

Returns:

  • (String)

    native target display name



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

def name
  @name
end

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

Returns corresponding native target.

Returns:

  • (Xcodeproj::Project::Object::PBXNativeTarget)

    corresponding native target



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

def native_target
  @native_target
end

#rebuildBool

Returns should target be rebuilt.

Returns:

  • (Bool)

    should target be rebuilt



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

def rebuild
  @rebuild
end

#shaString

Returns sha256 of (input files + build settings + dependency shas).

Returns:

  • (String)

    sha256 of (input files + build settings + dependency shas)



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

def sha
  @sha
end

Instance Method Details

#==(other_node) ⇒ Object



92
93
94
# File 'lib/build_graph/node.rb', line 92

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>

Returns Direct + transitive dependents.

Returns:

  • (Array<Node>)

    Direct + transitive dependents



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

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

#dsym_file_nameString

Returns:

  • (String)


79
80
81
82
83
# File 'lib/build_graph/node.rb', line 79

def dsym_file_name
  return nil unless build_settings

  build_settings[XcodeArchiveCache::BuildSettings::DWARF_DSYM_FILE_NAME_KEY]
end

#has_framework_product?Boolean

Returns:

  • (Boolean)


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

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

#has_static_library_product?Boolean

Returns:

  • (Boolean)


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

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

#product_file_nameString

Returns:

  • (String)


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/build_graph/node.rb', line 59

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

#to_sObject



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

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\trebuild: #{rebuild}\n\tdependent: #{dependent_names}\n\tdependencies: #{dependency_names}"
end