lib/cocoapods-binaryhqp/Prebuild.rb in cocoapods-binaryhqp-0.5.2 vs lib/cocoapods-binaryhqp/Prebuild.rb in cocoapods-binaryhqp-0.5.3
- old
+ new
@@ -144,10 +144,15 @@
def install_when_cache_hit!
# just print log
self.sandbox.exsited_framework_target_names.each do |name|
UI.puts "Using #{name}" if config.verbose
end
+
+ self.resolve_dependencies
+ #处理资源文件
+ self.handle_static_framework_resouces
+
end
def delete_standard_sand_box_pod(standard_sanbox)
if lockfile
changes = lockfile.detect_changes_with_podfile(podfile)
@@ -171,10 +176,47 @@
Pod::UI.puts("删除 #{pod_path.to_s}") if config.verbose
pod_path.rmtree if pod_path.exist?
end
end
end
+ # 处理静态库资源
+ def handle_static_framework_resouces
+ all_static_framework_targets = pod_targets.reject{|pod_target| not pod_target.static_framework? or pod_target.resource_paths.empty? }
+ all_static_framework_targets.each do |target|
+ output_path = sandbox.framework_folder_path_for_target_name(target.name)
+ if target.static_framework? and !target.resource_paths.empty?
+ framework_path = output_path + target.framework_name
+ standard_sandbox_path = sandbox.standard_sanbox_path
+ resources = begin
+ if Pod::VERSION.start_with? "1.5"
+ target.resource_paths
+ else
+ # resource_paths is Hash{String=>Array<String>} on 1.6 and above
+ # (use AFNetworking to generate a demo data)
+ # https://github.com/leavez/cocoapods-binary/issues/50
+ target.resource_paths.values.flatten
+ end
+ end
+ raise "Wrong type: #{resources}" unless resources.kind_of? Array
+
+ path_objects = resources.map do |path|
+ prebuild_real_path = (path.gsub('${PODS_ROOT}', sandbox.root.to_s) if path.start_with? '${PODS_ROOT}')|| ""
+ real_file_path = framework_path + File.basename(path)
+ if Pathname.new(prebuild_real_path).exist? and not Pathname.new(real_file_path).exist?
+ # 静态库的resource,拷贝至framework目录下
+ FileUtils.cp_r(prebuild_real_path, real_file_path, :remove_destination => true)
+ end
+ object = Prebuild::Passer::ResourcePath.new
+ object.real_file_path = real_file_path
+ object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
+ object.target_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", standard_sandbox_path.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
+ object
+ end
+ Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
+ end
+ end
+ end
# Build the needed framework files
def prebuild_frameworks!(after_write_lock)
# build options
@@ -224,11 +266,10 @@
targets = self.pod_targets
end
targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
-
# build!
Pod::UI.puts "Prebuild frameworks (total #{targets.count})"
Pod::Prebuild.remove_build_dir(sandbox_path)
targets.each do |target|
if !target.should_build?
@@ -238,46 +279,15 @@
output_path = sandbox.framework_folder_path_for_target_name(target.name)
output_path.rmtree if output_path.exist?
output_path.mkpath unless output_path.exist?
Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
-
- # save the resource paths for later installing
- if target.static_framework? and !target.resource_paths.empty?
- framework_path = output_path + target.framework_name
- standard_sandbox_path = sandbox.standard_sanbox_path
-
- resources = begin
- if Pod::VERSION.start_with? "1.5"
- target.resource_paths
- else
- # resource_paths is Hash{String=>Array<String>} on 1.6 and above
- # (use AFNetworking to generate a demo data)
- # https://github.com/leavez/cocoapods-binary/issues/50
- target.resource_paths.values.flatten
- end
- end
- raise "Wrong type: #{resources}" unless resources.kind_of? Array
- # resource : ${PODS_ROOT}
- # resource_bundles : ${PODS_CONFIGURATION_BUILD_DIR},不做处理
- path_objects = resources.map do |path|
- prebuild_real_path = (path.gsub('${PODS_ROOT}', sandbox.root.to_s) if path.start_with? '${PODS_ROOT}')|| ""
- real_file_path = framework_path + File.basename(path)
- if Pathname.new(prebuild_real_path).exist?
- # 静态库的resource,拷贝至framework目录下
- FileUtils.cp_r(prebuild_real_path, real_file_path, :remove_destination => true)
- end
- object = Prebuild::Passer::ResourcePath.new
- object.real_file_path = real_file_path
- object.target_file_path = path.gsub('${PODS_ROOT}', standard_sandbox_path.to_s) if path.start_with? '${PODS_ROOT}'
- object.target_file_path = path.gsub("${PODS_CONFIGURATION_BUILD_DIR}", standard_sandbox_path.to_s) if path.start_with? "${PODS_CONFIGURATION_BUILD_DIR}"
- object
- end
- Prebuild::Passer.resources_to_copy_for_static_framework[target.name] = path_objects
- end
-
- end
+ end
+ # check static_framework resources
+ self.handle_static_framework_resouces
Pod::Prebuild.remove_build_dir(sandbox_path)
+
+
# copy vendored libraries and frameworks
targets.each do |target|
root_path = self.sandbox.pod_dir(target.name)
\ No newline at end of file