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:



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_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:



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

def native_target
  @native_target
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

#stateSymbol

Returns should target be rebuilt.

Returns:

  • (Symbol)

    should target be rebuilt



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

def state
  @state
end

#targets_injected_toArray<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_nodesArray<Node>

Returns Direct + transitive dependents.

Returns:

  • (Array<Node>)

    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_nameString

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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_nameString

Returns:

  • (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_nameString

Returns:

  • (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_pathString

Returns:

  • (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_nameString

Returns:

  • (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_nameString

Returns:

  • (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

#subgraphArray<Node>

Returns:



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_fileString

Returns:

  • (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_sObject



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_rebuildBool

Returns:

  • (Bool)


157
158
159
# File 'lib/build_graph/node.rb', line 157

def waiting_for_rebuild
  state == :waiting_for_rebuild
end