Module: XCCache::SPM::Package::UmbrellaCachemapMixin

Included in:
Umbrella
Defined in:
lib/xccache/spm/pkg/umbrella/cachemap.rb

Instance Method Summary collapse

Instance Method Details

#sync_cachemap(sdks: []) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/xccache/spm/pkg/umbrella/cachemap.rb', line 5

def sync_cachemap(sdks: [])
  UI.section("Syncing cachemap (sdks: #{sdks.map(&:name)})")
  nodes, edges, parents = xccache_desc.traverse
  cache_data = gen_cache_data(nodes, parents, sdks)
  targets_data, macros_data, deps_data = {}, {}, {}
  xccache_desc.targets.each do |agg_target|
    targets, macros = [], []
    agg_target.direct_dependencies.each do |d|
      all_hit = d.recursive_targets.all? { |t| cache_data[t] == :hit }
      # If any associated targets is missed -> use original product form
      # Otherwise, replace with recursive targets' binaries
      deps_data[d.full_name] = d.recursive_targets.map(&:xccache_id)
      targets << (all_hit ? "#{d.full_name}.binary" : d.full_name)
      macros += d.recursive_targets.select(&:macro?).map(&:full_name) if all_hit
    end
    targets_data[agg_target.name] = targets.uniq.sort_by(&:downcase)
    macros_data[agg_target.name] = macros.uniq
  end

  config.cachemap.raw = {
    "manifest" => {
      "targets" => targets_data,
      "macros" => macros_data,
      "deps" => deps_data,
    },
    "cache" => cache_data.transform_keys(&:full_name),
    "depgraph" => {
      "nodes" => nodes.map { |x| target_to_cytoscape_node(x, cache_data) },
      "edges" => edges.map { |x, y| { :source => x.full_name, :target => y.full_name } },
    },
  }
  config.cachemap.save
  config.cachemap.print_stats
end