Document MachOShim.

This commit is contained in:
Markus Reiter 2020-08-25 00:28:26 +02:00
parent f7cb6a95b6
commit 390deeb5ac

View File

@ -3,19 +3,21 @@
require "macho"
require "os/mac/architecture_list"
# {Pathname} extension for dealing with Mach-O files.
#
# @api private
module MachOShim
extend Forwardable
delegate [:dylib_id, :rpaths, :delete_rpath] => :macho
# @private
def macho
@macho ||= begin
MachO.open(to_s)
end
end
private :macho
# @private
def mach_data
@mach_data ||= begin
machos = []
@ -55,6 +57,7 @@ module MachOShim
[]
end
end
private :mach_data
def dynamically_linked_libraries(except: :none)
lcs = macho.dylib_load_commands.reject { |lc| lc.type == except }
@ -94,19 +97,16 @@ module MachOShim
arch == :ppc64
end
# @private
def dylib?
mach_data.any? { |m| m.fetch(:type) == :dylib }
end
# @private
def mach_o_executable?
mach_data.any? { |m| m.fetch(:type) == :executable }
end
alias binary_executable? mach_o_executable?
# @private
def mach_o_bundle?
mach_data.any? { |m| m.fetch(:type) == :bundle }
end