Commit a951feef authored by Danielle Tomlinson's avatar Danielle Tomlinson Committed by GitHub

Merge pull request #6434 from hailstorm350/kenw/cache-macho-dynamic-query-results

Cache results of dynamic_binary?
parents 8b02913f 3604c644
...@@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Orta Therox](https://github.com/orta) [Orta Therox](https://github.com/orta)
[xcodeproj#463](https://github.com/CocoaPods/Xcodeproj/pull/463) [xcodeproj#463](https://github.com/CocoaPods/Xcodeproj/pull/463)
* Cache results of dynamic_binary?
[Ken Wigginton](https://github.com/hailstorm350)
[#6434](https://github.com/CocoaPods/CocoaPods/pull/6434)
##### Bug Fixes ##### Bug Fixes
* Correctly handle `OTHER_LDFLAGS` for targets with inherit search paths and source pods. * Correctly handle `OTHER_LDFLAGS` for targets with inherit search paths and source pods.
......
...@@ -372,10 +372,13 @@ module Pod ...@@ -372,10 +372,13 @@ module Pod
# @return [Boolean] Whether `binary` can be dynamically linked. # @return [Boolean] Whether `binary` can be dynamically linked.
# #
def dynamic_binary?(binary) def dynamic_binary?(binary)
return unless binary.file? @cached_dynamic_binary_results ||= {}
MachO.open(binary).dylib? return @cached_dynamic_binary_results[binary] unless @cached_dynamic_binary_results[binary].nil?
return false unless binary.file?
@cached_dynamic_binary_results[binary] = MachO.open(binary).dylib?
rescue MachO::MachOError rescue MachO::MachOError
false @cached_dynamic_binary_results[binary] = false
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -265,6 +265,21 @@ module Pod ...@@ -265,6 +265,21 @@ module Pod
@accessor.send(:paths_for_attribute, :source_files) @accessor.send(:paths_for_attribute, :source_files)
end end
end end
describe '#dynamic_binary?' do
it 'not a dynamic binary if its not a file' do
binary = stub(:file? => false)
@accessor.send(:dynamic_binary?, binary).should.be.false
end
it 'uses the cache after the first time' do
binary = stub(:file? => true)
macho_file = stub(:dylib? => true)
MachO.stubs(:open).once.returns(macho_file)
@accessor.send(:dynamic_binary?, binary).should.be.true
@accessor.send(:dynamic_binary?, binary).should.be.true
end
end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
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