Commit fc373229 authored by Samuel E. Giddins's avatar Samuel E. Giddins

[FileAccessor] Partition dynamic and static vendored artifacts

parent 338a8400
...@@ -53,7 +53,7 @@ module Pod ...@@ -53,7 +53,7 @@ module Pod
# #
def generate def generate
includes_static_libs = !target.requires_frameworks? includes_static_libs = !target.requires_frameworks?
includes_static_libs ||= pod_targets.flat_map(&:file_accessors).any? { |fa| !fa.vendored_libraries.empty? } includes_static_libs ||= pod_targets.flat_map(&:file_accessors).any? { |fa| !fa.vendored_static_libraries.empty? || !fa.vendored_static_frameworks.empty? }
config = { config = {
'OTHER_LDFLAGS' => '$(inherited) ' + XCConfigHelper.default_ld_flags(target, includes_static_libs), 'OTHER_LDFLAGS' => '$(inherited) ' + XCConfigHelper.default_ld_flags(target, includes_static_libs),
'PODS_ROOT' => target.relative_pods_root, 'PODS_ROOT' => target.relative_pods_root,
......
...@@ -418,8 +418,7 @@ module Pod ...@@ -418,8 +418,7 @@ module Pod
dependended_upon_targets = pod_targets.select { |t| dependencies.include?(t.pod_name) && !t.should_build? } dependended_upon_targets = pod_targets.select { |t| dependencies.include?(t.pod_name) && !t.should_build? }
static_libs = dependended_upon_targets.flat_map(&:file_accessors).flat_map do |fa| static_libs = dependended_upon_targets.flat_map(&:file_accessors).flat_map do |fa|
static_frameworks = fa.vendored_frameworks.reject { |fw| `file #{fw + fw.basename('.framework')} 2>&1` =~ /dynamically linked/ } fa.vendored_static_libraries + fa.vendored_static_frameworks
fa.vendored_libraries + static_frameworks
end end
unless static_libs.empty? unless static_libs.empty?
......
...@@ -152,6 +152,16 @@ module Pod ...@@ -152,6 +152,16 @@ module Pod
paths_for_attribute(:vendored_frameworks, true) paths_for_attribute(:vendored_frameworks, true)
end end
def vendored_dynamic_frameworks
vendored_frameworks.select do |framework|
dynamic_binary?(framework + framework.basename('.*'))
end
end
def vendored_static_frameworks
vendored_frameworks - vendored_dynamic_frameworks
end
# @param [Pathname] framework # @param [Pathname] framework
# The vendored framework to search into. # The vendored framework to search into.
# @return [Pathname] The path of the header directory of the # @return [Pathname] The path of the header directory of the
...@@ -187,6 +197,16 @@ module Pod ...@@ -187,6 +197,16 @@ module Pod
paths_for_attribute(:vendored_libraries) paths_for_attribute(:vendored_libraries)
end end
def vendored_dynamic_libraries
vendored_libraries.select do |library|
dynamic_binary?(library)
end
end
def vendored_static_libraries
vendored_libraries - vendored_dynamic_libraries
end
# @return [Hash{String => Array<Pathname>}] A hash that describes the # @return [Hash{String => Array<Pathname>}] A hash that describes the
# resource bundles of the Pod. The keys represent the name of # resource bundles of the Pod. The keys represent the name of
# the bundle while the values the path of the resources. # the bundle while the values the path of the resources.
...@@ -315,6 +335,11 @@ module Pod ...@@ -315,6 +335,11 @@ module Pod
result.flatten.compact.uniq result.flatten.compact.uniq
end end
def dynamic_binary?(binary)
return unless binary.file?
Executable.execute_command('file', [binary], false) =~ /dynamically linked/
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
end end
end end
......
...@@ -382,8 +382,8 @@ module Pod ...@@ -382,8 +382,8 @@ module Pod
deployment_target = spec.subspec_by_name(subspec_name).deployment_target(consumer.platform_name) deployment_target = spec.subspec_by_name(subspec_name).deployment_target(consumer.platform_name)
unless file_accessor.nil? unless file_accessor.nil?
dynamic_frameworks = file_accessor.vendored_frameworks.select { |fw| `file #{fw + fw.basename('.framework')} 2>&1` =~ /dynamically linked/ } dynamic_frameworks = file_accessor.vendored_dynamic_frameworks
dynamic_libraries = file_accessor.vendored_libraries.select { |lib| `file #{lib} 2>&1` =~ /dynamically linked/ } dynamic_libraries = file_accessor.vendored_dynamic_libraries
if (dynamic_frameworks.count > 0 || dynamic_libraries.count > 0) && consumer.platform_name == :ios && if (dynamic_frameworks.count > 0 || dynamic_libraries.count > 0) && consumer.platform_name == :ios &&
(deployment_target.nil? || Version.new(deployment_target).major < 8) (deployment_target.nil? || Version.new(deployment_target).major < 8)
error('dynamic', 'Dynamic frameworks and libraries are only supported on iOS 8.0 and onwards.') error('dynamic', 'Dynamic frameworks and libraries are only supported on iOS 8.0 and onwards.')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment