Class: XcodeArchiveCache::Runner

Inherits:
Object
  • Object
show all
Includes:
Logs
Defined in:
lib/runner/runner.rb

Instance Method Summary collapse

Methods included from Logs

#debug, #error, #info, #set_log_level

Constructor Details

#initialize(config) ⇒ Runner

Returns a new instance of Runner.

Parameters:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/runner/runner.rb', line 8

def initialize(config)
  @config = config

  projects = list_projects
  @native_target_finder = XcodeArchiveCache::BuildGraph::NativeTargetFinder.new(projects, config.active_configuration.build_configuration)

  storage_path = File.absolute_path(config.storage.path)
  @cache_storage = XcodeArchiveCache::ArtifactCache::LocalStorage.new(storage_path)
  @rebuild_evaluator = XcodeArchiveCache::BuildGraph::RebuildEvaluator.new(@cache_storage)

  @artifact_extractor = XcodeArchiveCache::ArtifactCache::ArtifactExtractor.new(@cache_storage)

  derived_data_path = File.absolute_path(config.settings.derived_data_path)
  @product_extractor = XcodeArchiveCache::Build::ProductExtractor.new(config.active_configuration.build_configuration, derived_data_path)

  unpacked_artifacts_dir = File.absolute_path(File.join(derived_data_path, "cached"))
  @injection_storage = XcodeArchiveCache::Injection::Storage.new(unpacked_artifacts_dir)
  @injector = XcodeArchiveCache::Injection::Injector.new(config.active_configuration.build_configuration, @injection_storage)
end

Instance Method Details

#list_projectsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/runner/runner.rb', line 28

def list_projects
  file_path = File.absolute_path(config.file_path)

  if config.is_a?(XcodeArchiveCache::Config::Project)
    return [Xcodeproj::Project.open(file_path)]
  elsif config.is_a?(XcodeArchiveCache::Config::Workspace)
    workspace = Xcodeproj::Workspace.new_from_xcworkspace(file_path)
    workspace_dir = File.expand_path("..", file_path)

    return workspace.file_references.map {|file_reference| Xcodeproj::Project.open(file_reference.absolute_path(workspace_dir))}
  end

  raise XcodeArchiveCache::Informative, "Configuration misses entry point -- must have either a project or a workspace"
end

#perform_cleanupObject



51
52
53
54
55
# File 'lib/runner/runner.rb', line 51

def perform_cleanup
  if File.exist?(config.settings.derived_data_path)
    FileUtils.rm_rf(config.settings.derived_data_path)
  end
end

#runObject



43
44
45
46
47
48
49
# File 'lib/runner/runner.rb', line 43

def run
  perform_cleanup

  config.targets.each do |target_config|
    handle_target(target_config)
  end
end