Class: PodPrebuild::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary-cache/prebuild_output/output.rb

Instance Method Summary collapse

Constructor Details

#initialize(prebuild_sandbox) ⇒ Output

Returns a new instance of Output.



6
7
8
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 6

def initialize(prebuild_sandbox)
  @sandbox = prebuild_sandbox
end

Instance Method Details

#clean_delta_fileObject



19
20
21
22
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 19

def clean_delta_file
  puts "Clean delta file: #{delta_file_path}"
  FileUtils.rm_rf(delta_file_path)
end

#create_dir_if_needed(dir) ⇒ Object



24
25
26
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 24

def create_dir_if_needed(dir)
  FileUtils.mkdir_p dir unless File.directory?(dir)
end

#delta_dirObject



10
11
12
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 10

def delta_dir
  @delta_dir ||= File.expand_path("#{@sandbox.root}/../_Prebuild_delta")
end

#delta_file_pathObject



14
15
16
17
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 14

def delta_file_path
  # TODO (thuyen): Unify this path with PodPrebuild::Config#delta_file_path
  "#{delta_dir}/changes.json"
end

#process_prebuilt_dev_podsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 43

def process_prebuilt_dev_pods
  devpod_output_path = "#{delta_dir}/devpod_prebuild_output/"
  create_dir_if_needed(devpod_output_path)
  Pod::UI.puts "Copy prebuilt devpod frameworks to output dir: #{devpod_output_path}"

  # Inject project path (where the framework is built) to support generating code coverage later
  project_root = PathUtils.remove_last_path_component(@sandbox.standard_sanbox_path.to_s)
  template_file_path = devpod_output_path + "prebuilt_map"
  File.open(template_file_path, "w") do |file|
    file.write(project_root)
  end

  # FIXME (thuyen): Revise usage of cache_miss_dev_pods_dic
  # The behavior of processing outputs of dev pods and non-dev pods should be very SIMILAR
  cache_miss_dev_pods_dic = {}

  cache_miss_dev_pods_dic.each do |name, hash|
    Pod::UI.puts "Output dev pod lib: #{name} hash: #{hash}"
    built_lib_path = @sandbox.framework_folder_path_for_target_name(name)
    next unless File.directory?(built_lib_path)

    FileUtils.cp(template_file_path, "#{built_lib_path}/#{name}.framework")
    target_dir = "#{devpod_output_path}#{name}_#{hash}"
    Pod::UI.puts "From: #{built_lib_path} -> #{target_dir}"
    FileUtils.cp_r(built_lib_path, target_dir)
  end
end

#write_delta_file(updated, deleted) ⇒ Object

Input 2 arrays of library names



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 29

def write_delta_file(updated, deleted)
  if updated.empty? && deleted.empty?
    Pod::UI.puts "No changes in prebuild"
    return
  end

  Pod::UI.puts "Write prebuild changes to: #{delta_file_path}"
  create_dir_if_needed(delta_dir)
  changes = PodPrebuild::JSONFile.new(delta_file_path)
  changes["updated"] = updated
  changes["deleted"] = deleted
  changes.save!
end