Class: Pod::PrebuildInstaller
- Defined in:
- lib/cocoapods-binary-ht/pod-binary/prebuild.rb
Overview
rubocop:disable Metrics/ClassLength
Instance Attribute Summary collapse
-
#lockfile_wrapper ⇒ Object
readonly
Returns the value of attribute lockfile_wrapper.
Instance Method Summary collapse
- #clean_delta_file ⇒ Object
- #collect_metadata(target, output_path) ⇒ Object
-
#initialize(options) ⇒ PrebuildInstaller
constructor
A new instance of PrebuildInstaller.
- #installation_options ⇒ Object
- #prebuild_frameworks! ⇒ Object
- #prebuild_output ⇒ Object
- #run_code_gen!(targets) ⇒ Object
- #targets_to_prebuild ⇒ Object
Methods inherited from Installer
#alter_specs_for_prebuilt_pods, #create_pod_installer, #original_create_pod_installer, #prebuilt_pod_names, #prebuilt_pod_targets, #validate_every_pod_only_have_one_form
Constructor Details
#initialize(options) ⇒ PrebuildInstaller
Returns a new instance of PrebuildInstaller.
11 12 13 14 15 |
# File 'lib/cocoapods-binary-ht/pod-binary/prebuild.rb', line 11 def initialize() super([:sandbox], [:podfile], [:lockfile]) @cache_validation = [:cache_validation] @lockfile_wrapper = lockfile && PodPrebuild::Lockfile.new(lockfile) end |
Instance Attribute Details
#lockfile_wrapper ⇒ Object (readonly)
Returns the value of attribute lockfile_wrapper.
9 10 11 |
# File 'lib/cocoapods-binary-ht/pod-binary/prebuild.rb', line 9 def lockfile_wrapper @lockfile_wrapper end |
Instance Method Details
#clean_delta_file ⇒ Object
130 131 132 |
# File 'lib/cocoapods-binary-ht/pod-binary/prebuild.rb', line 130 def clean_delta_file prebuild_output.clean_delta_file end |
#collect_metadata(target, output_path) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/cocoapods-binary-ht/pod-binary/prebuild.rb', line 134 def (target, output_path) = PodPrebuild::Metadata.in_dir(output_path) .framework_name = target.framework_name .static_framework = target.static_framework? resource_paths = target.resource_paths .resources = resource_paths.is_a?(Hash) ? resource_paths.values.flatten : resource_paths .resource_bundles = target .file_accessors .map { |f| f.resource_bundles.keys } .flatten .map { |name| "#{name}.bundle" } .build_settings = pods_project.targets .detect { |native_target| native_target.name == target.name } .build_configurations .detect { |config| config.name == PodPrebuild.config.prebuild_config } .build_settings .source_hash = @lockfile_wrapper && @lockfile_wrapper.dev_pod_hash(target.name) # Store root path for code-coverage support later # TODO: update driver code-coverage logic to use path stored here project_root = PathUtils.remove_last_path_component(@sandbox.standard_sanbox_path.to_s) .project_root = project_root .save! end |
#installation_options ⇒ Object
17 18 19 20 21 22 |
# File 'lib/cocoapods-binary-ht/pod-binary/prebuild.rb', line 17 def # Skip integrating user targets for prebuild Pods project. @installation_options ||= Pod::Installer::InstallationOptions.new( super.to_h.merge(:integrate_targets => false) ) end |
#prebuild_frameworks! ⇒ Object
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/cocoapods-binary-ht/pod-binary/prebuild.rb', line 44 def prebuild_frameworks! existed_framework_folder = sandbox.generate_framework_path sandbox_path = sandbox.root targets = targets_to_prebuild Pod::UI.puts "Prebuild frameworks (total #{targets.count}): #{targets.map(&:name)}".magenta run_code_gen!(targets) PodPrebuild.remove_build_dir(sandbox_path) PodPrebuild.build( sandbox: sandbox_path, targets: targets, configuration: PodPrebuild.config.prebuild_config, output_path: sandbox.generate_framework_path, bitcode_enabled: PodPrebuild.config.bitcode_enabled?, device_build_enabled: PodPrebuild.config.device_build_enabled?, disable_dsym: PodPrebuild.config.disable_dsym?, log_path: PodPrebuild.config.xcodebuild_log_path, args: PodPrebuild.config.build_args ) PodPrebuild.remove_build_dir(sandbox_path) targets.each do |target| (target, sandbox.framework_folder_path_for_target_name(target.name)) end # copy vendored libraries and frameworks targets.each do |target| root_path = sandbox.pod_dir(target.name) target_folder = sandbox.framework_folder_path_for_target_name(target.name) # If target shouldn't build, we copy all the original files # This is for target with only .a and .h files unless target.should_build? FileUtils.cp_r(root_path, target_folder, :remove_destination => true) next end target.spec_consumers.each do |consumer| file_accessor = Sandbox::FileAccessor.new(root_path, consumer) lib_paths = file_accessor.vendored_frameworks || [] lib_paths += file_accessor.vendored_libraries # @TODO dSYM files lib_paths.each do |lib_path| relative = lib_path.relative_path_from(root_path) destination = target_folder + relative destination.dirname.mkpath unless destination.dirname.exist? FileUtils.cp_r(lib_path, destination, :remove_destination => true) end end end # save the pod_name for prebuild framwork in sandbox targets.each do |target| sandbox.save_pod_name_for_target target end # Remove useless files # remove useless pods all_needed_names = pod_targets.map(&:name).uniq useless_target_names = sandbox.exsited_framework_target_names.reject do |name| all_needed_names.include? name end useless_target_names.each do |name| Pod::UI. "Remove: #{name}" path = sandbox.framework_folder_path_for_target_name(name) path.rmtree if path.exist? end if PodPrebuild.config.dont_remove_source_code? # just remove the tmp files path = sandbox.root + "Manifest.lock.tmp" path.rmtree if path.exist? else # only keep manifest.lock and framework folder in _Prebuild to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)] to_delete_files = sandbox_path.children.reject { |file| to_remain_files.include?(File.basename(file)) } to_delete_files.each { |file| file.rmtree if file.exist? } end prebuild_output.write_delta_file( updated: targets.map { |target| target.label.to_s }, deleted: useless_target_names ) end |
#prebuild_output ⇒ Object
32 33 34 |
# File 'lib/cocoapods-binary-ht/pod-binary/prebuild.rb', line 32 def prebuild_output @prebuild_output ||= PodPrebuild::Output.new(sandbox) end |
#run_code_gen!(targets) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/cocoapods-binary-ht/pod-binary/prebuild.rb', line 24 def run_code_gen!(targets) return if PodPrebuild.config.prebuild_code_gen.nil? Pod::UI.title("Running code generation...") do PodPrebuild.config.prebuild_code_gen.call(self, targets) end end |
#targets_to_prebuild ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/cocoapods-binary-ht/pod-binary/prebuild.rb', line 36 def targets_to_prebuild to_build = PodPrebuild.config.targets_to_prebuild_from_cli if to_build.empty? to_build = PodPrebuild.config.prebuild_all_pods? ? @cache_validation.all : @cache_validation.missed end pod_targets.select { |target| to_build.include?(target.name) } end |