Module: XCCache::SPM::Package::UmbrellaBuildMixin

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

Instance Method Summary collapse

Instance Method Details

#build(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/xccache/spm/pkg/umbrella/build.rb', line 5

def build(options = {})
  to_build = targets_to_build(options)
  return UI.warn("Detected no targets to build among cache-missed targets") if to_build.empty?

  UI.info("-> Targets to build: #{to_build.to_s.bold}")
  super(options.merge(:targets => to_build))
  sync_cachemap(sdks: options[:sdks])
end

#targets_to_build(options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/xccache/spm/pkg/umbrella/build.rb', line 14

def targets_to_build(options)
  items = options[:targets] || []
  items = config.cachemap.missed.map { |x| File.basename(x) } if items.empty?
  targets = @descs.flat_map(&:targets).select { |t| items.include?(t.name) }
  if options[:recursive]
    UI.message("Will include cache-missed recursive targets")
    targets += targets.flat_map do |t|
      t.recursive_targets.select { |x| config.cachemap.missed?(x.full_name) }
    end
  end
  # TODO: Sort by number of dependents
  targets.map(&:full_name).uniq
end