Class: Pod::PrebuildInstaller
- Defined in:
- lib/cocoapods-binary-cache/pod-binary/prebuild.rb
Instance Method Summary collapse
- #clean_delta_file ⇒ Object
- #collect_metadata(target, output_path) ⇒ Object
-
#initialize(options) ⇒ PrebuildInstaller
constructor
A new instance of PrebuildInstaller.
-
#prebuild_frameworks! ⇒ Object
Build the needed framework files.
- #prebuild_output ⇒ Object
Methods inherited from Installer
#add_vendered_framework, #alter_spec, #alter_specs_for_prebuilt_pods, disable_install_complete_message, #empty_liscence, #empty_source_files, force_disable_integration, #prebuilt_pod_names, #prebuilt_pod_targets, #remove_target_files_if_needed, #should_integrate_prebuilt_pod?, #tweak_resources_for_resource_bundles, #tweak_resources_for_xib, #validate_every_pod_only_have_one_form
Constructor Details
#initialize(options) ⇒ PrebuildInstaller
Returns a new instance of PrebuildInstaller.
10 11 12 13 |
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 10 def initialize() super([:sandbox], [:podfile], [:lockfile]) @cache_validation = [:cache_validation] end |
Instance Method Details
#clean_delta_file ⇒ Object
194 195 196 |
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 194 def clean_delta_file prebuild_output.clean_delta_file end |
#collect_metadata(target, output_path) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 198 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 == Pod::Podfile::DSL.prebuild_config } .build_settings .save! end |
#prebuild_frameworks! ⇒ Object
Build the needed framework files
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 56 def prebuild_frameworks! UI.puts "Start prebuild_frameworks" # build options sandbox_path = sandbox.root existed_framework_folder = sandbox.generate_framework_path bitcode_enabled = Pod::Podfile::DSL.bitcode_enabled targets = [] if Pod::Podfile::DSL.prebuild_all_vendor_pods UI.puts "Rebuild all vendor frameworks" targets = pod_targets elsif !local_manifest.nil? UI.puts "Update some frameworks" changes = prebuild_pods_changes added = changes.added changed = changes.changed unchanged = changes.unchanged existed_framework_folder.mkdir unless existed_framework_folder.exist? exsited_framework_pod_names = sandbox.exsited_framework_pod_names # additions missing = unchanged.reject { |pod_name| exsited_framework_pod_names.include?(pod_name) } root_names_to_update = (added + changed + missing) root_names_to_update += PodPrebuild::StateStore.cache_validation.missed # transform names to targets cache = [] targets = root_names_to_update.map do |pod_name| tars = Pod.fast_get_targets_for_pod_name(pod_name, pod_targets, cache) || [] raise "There's no target named (#{pod_name}) in Pod.xcodeproj" if tars.empty? tars end.flatten # add the dendencies dependency_targets = targets.map(&:recursive_dependent_targets).flatten.uniq || [] targets = (targets + dependency_targets).uniq else UI.puts "Rebuild all frameworks" targets = pod_targets end targets = targets.reject { |pod_target| should_not_prebuild_vendor_pod(pod_target.name) } targets = targets.reject { |pod_target| sandbox.local?(pod_target.pod_name) } unless Podfile::DSL.dev_pods_enabled # build! Pod::UI.puts "Prebuild frameworks (total #{targets.count})" Pod::UI.puts targets.map(&:name) Pod::Prebuild.remove_build_dir(sandbox_path) targets.each do |target| unless target.should_build? Pod::UI.puts "Skip prebuilding #{target.label} because of no source files".yellow next end output_path = sandbox.framework_folder_path_for_target_name(target.name) output_path.mkpath unless output_path.exist? Pod::Prebuild.build( sandbox_path, target, Pod::Podfile::DSL.prebuild_config, output_path, bitcode_enabled, Pod::Podfile::DSL., Pod::Podfile::DSL. ) (target, output_path) end Pod::Prebuild.remove_build_dir(sandbox_path) # 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? Prebuild::Passer.target_names_to_skip_integration_framework << target.name 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| UI.puts "Remove: #{name}" path = sandbox.framework_folder_path_for_target_name(name) path.rmtree if path.exist? end if Podfile::DSL.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 updated_target_names = targets.map { |target| target.label.to_s } deleted_target_names = useless_target_names Pod::UI.puts "Targets to prebuild: #{updated_target_names}" Pod::UI.puts "Targets to cleanup: #{deleted_target_names}" prebuild_output.write_delta_file(updated_target_names, deleted_target_names) prebuild_output.process_prebuilt_dev_pods end |
#prebuild_output ⇒ Object
51 52 53 |
# File 'lib/cocoapods-binary-cache/pod-binary/prebuild.rb', line 51 def prebuild_output @prebuild_output ||= PodPrebuild::Output.new(sandbox) end |