lib/cocoapods-ppbuild/Prebuild.rb in cocoapods-ppbuild-0.0.4 vs lib/cocoapods-ppbuild/Prebuild.rb in cocoapods-ppbuild-0.0.5

- old
+ new

@@ -60,12 +60,48 @@ # just print log self.sandbox.exsited_framework_target_names.each do |name| UI.puts "Using #{name}" end end + + def save_change_targets! + sandbox_path = sandbox.root + existed_framework_folder = sandbox.generate_framework_path + + if local_manifest != nil + changes = prebuild_pods_changes + added = changes.added + changed = changes.changed + unchanged = changes.unchanged + deleted = changes.deleted.to_a + existed_framework_folder.mkdir unless existed_framework_folder.exist? + exsited_framework_pod_names = sandbox.exsited_framework_pod_names + + # additions + missing = unchanged.select do |pod_name| + not exsited_framework_pod_names.include?(pod_name) + end + # 保存有改变的target列表 + root_names_to_update = (added + changed + missing).uniq + updates_target_names = (root_names_to_update + deleted).uniq + cache = [] + updates_targets = [] + updates_target_names.each do |pod_name| + tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache) + if tars.nil? || tars.empty? + Pod::UI.puts "There's no target named (#{pod_name}) in Pod.xcodeproj." if t.nil? + else + updates_targets = (updates_targets + tars).uniq + end + end + updates_dependency_targets = updates_targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || [] + Pod::Prebuild::Passer.prebuild_pod_targets_changes = (updates_targets + updates_dependency_targets).uniq + end + end + # Build the needed framework files def prebuild_frameworks! # build options sandbox_path = sandbox.root existed_framework_folder = sandbox.generate_framework_path @@ -85,26 +121,26 @@ # additions missing = unchanged.select do |pod_name| not exsited_framework_pod_names.include?(pod_name) end - - - root_names_to_update = (added + changed + missing) - - # transform names to targets + root_names_to_update = (added + changed + missing).uniq + # 生成预编译target cache = [] targets = root_names_to_update.map do |pod_name| tars = Pod.fast_get_targets_for_pod_name(pod_name, self.pod_targets, cache) if tars.nil? || tars.empty? raise "There's no target named (#{pod_name}) in Pod.xcodeproj.\n #{self.pod_targets.map(&:name)}" if t.nil? end tars end.flatten - # add the dendencies + # 添加依赖 dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || [] + dependency_targets = dependency_targets.select do |tar| + sandbox.existed_target_version_for_pod_name(tar.pod_name) != tar.version + end targets = (targets + dependency_targets).uniq else targets = self.pod_targets end @@ -226,14 +262,15 @@ end # patch the post install hook old_method2 = instance_method(:run_plugins_post_install_hooks) define_method(:run_plugins_post_install_hooks) do + if Pod::is_prebuild_stage + self.save_change_targets! + end old_method2.bind(self).() if Pod::is_prebuild_stage self.prebuild_frameworks! end end - - end end \ No newline at end of file