lib/cocoapods-binaryhqp/Prebuild.rb in cocoapods-binaryhqp-0.4.8 vs lib/cocoapods-binaryhqp/Prebuild.rb in cocoapods-binaryhqp-0.4.9
- old
+ new
@@ -31,47 +31,76 @@
unchanged_pod_names = changes[:unchanged]
changed_pod_names = changes[:changed]
unchanged_pod_names.reverse_each do |name|
mainfest_pod_version = local_manifest.version(name).to_s
already_prebuild_version = prebuilded_framework_version(name) || "未找到"
- if already_prebuild_version != mainfest_pod_version
+ if not compare_version(mainfest_pod_version, already_prebuild_version)
Pod::UI.puts("- #{name} 已编译版本 #{already_prebuild_version}, manifest中的版本: #{mainfest_pod_version}") if config.verbose
changed_pod_names = changed_pod_names.push(name)
unchanged_pod_names.delete(name)
end
end
changes[:changed] = changed_pod_names
changes[:unchanged] = unchanged_pod_names
- Pod::UI.puts("需要重编译的framework : #{changed_pod_names.to_s}") if config.verbose
+ Pod::UI.puts("Pre 需要重编译的framework : #{changed_pod_names.to_s}") if config.verbose
@prebuild_pods_changes = Analyzer::SpecsState.new(changes)
# save the chagnes info for later stage
Pod::Prebuild::Passer.prebuild_pods_changes = @prebuild_pods_changes
@prebuild_pods_changes
end
+
+ # compare version
+ # 1.2.0 == 1.2 => true
+ # 1.2.1 != 1.2.0 => false
+ def compare_version(first_version, second_version)
+ first_nums = first_version.split('.')
+ second_nums = second_version.split('.')
+
+ first_nums.pop until first_nums.last.to_i != 0
+ second_nums.pop until second_nums.last.to_i != 0
+
+ first_nums == second_nums
+ end
public
# pod update 之后 lockfile 文件更新,更新lockfile对象,再次检查与预编译的版本是否一致
def post_update_pods_changes
changes = lockfile.detect_changes_with_podfile(podfile)
unchanged_pod_names = changes[:unchanged]
changed_pod_names = changes[:changed]
+ add_pod_names = changes[:added]
+ removed_pod_names = changes[:removed]
+
+
unchanged_pod_names.reverse_each do |name|
mainfest_pod_version = lockfile.version(name).to_s
already_prebuild_version = prebuilded_framework_version(name) || "未找到"
- if already_prebuild_version != mainfest_pod_version
- Pod::UI.puts("- #{name} 已编译版本 #{already_prebuild_version}, manifest中的版本: #{mainfest_pod_version}") if config.verbose
+ if compare_version(mainfest_pod_version, already_prebuild_version)
+ # 已经编译了
+ removed_pod_names.delete(name) if removed_pod_names.include?(name)
+ add_pod_names.delete(name) if add_pod_names.include?(name)
+ changed_pod_names.delete(name) if changed_pod_names.include?(name)
+
+ else
+ # 未找到相对应的版本
+ if already_prebuild_version == "99999.99999.99999"
+ Pod::UI.puts("- #{name}: 未找到预编译文件, manifest中的版本: #{mainfest_pod_version}") if config.verbose
+ else
+ Pod::UI.puts("- #{name}: 已编译版 #{already_prebuild_version}, manifest中的版本: #{mainfest_pod_version}") if config.verbose
+ end
changed_pod_names = changed_pod_names.push(name)
- unchanged_pod_names.delete(name)
+ unchanged_pod_names.delete(name) if unchanged_pod_names.include?(name)
end
end
-
+ changes[:removed] = removed_pod_names
+ changes[:added] = add_pod_names
changes[:changed] = changed_pod_names
changes[:unchanged] = unchanged_pod_names
- Pod::UI.puts("需要重编译的framework : #{changed_pod_names.to_s}") if config.verbose
+ Pod::UI.puts("post 需要重编译的framework : #{(changed_pod_names + removed_pod_names + add_pod_names ).to_a}") if config.verbose
@prebuild_pods_changes = Analyzer::SpecsState.new(changes)
# save the chagnes info for later stage
Pod::Prebuild::Passer.prebuild_pods_changes = @prebuild_pods_changes
@prebuild_pods_changes
@@ -99,11 +128,11 @@
return needed.empty?
end
# 当前已编译的framework的版本
def prebuilded_framework_version(name)
path = self.sandbox.plist_path_for_target_name(name)
- framework_version = ""
+ framework_version = "99999.99999.99999"
if Pathname.new(path).exist?
plist_file = CFPropertyList::List.new(:file => path)
data = CFPropertyList.native_types(plist_file.value)
framework_version = data["CFBundleShortVersionString"]
end
@@ -113,14 +142,27 @@
# The install method when have completed cache
def install_when_cache_hit!
# just print log
self.sandbox.exsited_framework_target_names.each do |name|
- UI.puts "Using #{name}"
+ UI.puts "Using #{name}" if config.verbose
end
end
+
+ def delete_standard_sand_box_pod(standard_sanbox)
+ if lockfile
+ changes = lockfile.detect_changes_with_podfile(podfile)
+ need_update_pods = (changes[:added] + changes[:changed] + changes[:removed]).to_a
+ need_update_pods.each do |pod_name|
+ pod_path = Pathname.new(standard_sanbox.root.to_s + "/#{pod_name}")
+ Pod::UI.puts("删除 #{pod_path.to_s}")
+ pod_path.rmtree if pod_path.exist?
+ end
+ end
+ end
+
# Build the needed framework files
def prebuild_frameworks!(after_write_lock)
# build options
sandbox_path = sandbox.root
@@ -161,11 +203,11 @@
end
tars
end.flatten
# add the dendencies
- dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
- targets = (targets + dependency_targets).uniq
+ # dependency_targets = targets.map {|t| t.recursive_dependent_targets }.flatten.uniq || []
+ # targets = (targets + dependency_targets).uniq
else
targets = self.pod_targets
end
targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
\ No newline at end of file