os/mac/*: more style corrections
Signed-off-by: botantony <antonsm21@gmail.com> Co-authored-by: Bo Anderson <mail@boanderson.me>
This commit is contained in:
parent
bc2c12c742
commit
843fc7c97a
@ -6,7 +6,7 @@ class Keg
|
|||||||
def initialize(path)
|
def initialize(path)
|
||||||
super
|
super
|
||||||
|
|
||||||
@require_relocation = T.let(nil, T.nilable(T::Boolean))
|
@require_relocation = T.let(false, T::Boolean)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(id: String, file: Pathname).returns(T::Boolean) }
|
sig { params(id: String, file: Pathname).returns(T::Boolean) }
|
||||||
@ -15,7 +15,7 @@ class Keg
|
|||||||
|
|
||||||
@require_relocation = true
|
@require_relocation = true
|
||||||
odebug "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}"
|
odebug "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}"
|
||||||
file.change_dylib_id(id)
|
file.change_dylib_id(id, strict: false)
|
||||||
true
|
true
|
||||||
rescue MachO::MachOError
|
rescue MachO::MachOError
|
||||||
onoe <<~EOS
|
onoe <<~EOS
|
||||||
@ -32,7 +32,7 @@ class Keg
|
|||||||
|
|
||||||
@require_relocation = true
|
@require_relocation = true
|
||||||
odebug "Changing install name in #{file}\n from #{old}\n to #{new}"
|
odebug "Changing install name in #{file}\n from #{old}\n to #{new}"
|
||||||
file.change_install_name(old, new)
|
file.change_install_name(old, new, strict: false)
|
||||||
true
|
true
|
||||||
rescue MachO::MachOError
|
rescue MachO::MachOError
|
||||||
onoe <<~EOS
|
onoe <<~EOS
|
||||||
@ -49,7 +49,7 @@ class Keg
|
|||||||
|
|
||||||
@require_relocation = true
|
@require_relocation = true
|
||||||
odebug "Changing rpath in #{file}\n from #{old}\n to #{new}"
|
odebug "Changing rpath in #{file}\n from #{old}\n to #{new}"
|
||||||
file.change_rpath(old, new)
|
file.change_rpath(old, new, strict: false)
|
||||||
true
|
true
|
||||||
rescue MachO::MachOError
|
rescue MachO::MachOError
|
||||||
onoe <<~EOS
|
onoe <<~EOS
|
||||||
@ -63,7 +63,7 @@ class Keg
|
|||||||
sig { params(rpath: String, file: MachOShim).returns(T::Boolean) }
|
sig { params(rpath: String, file: MachOShim).returns(T::Boolean) }
|
||||||
def delete_rpath(rpath, file)
|
def delete_rpath(rpath, file)
|
||||||
odebug "Deleting rpath #{rpath} in #{file}"
|
odebug "Deleting rpath #{rpath} in #{file}"
|
||||||
file.delete_rpath(rpath)
|
file.delete_rpath(rpath, strict: false)
|
||||||
true
|
true
|
||||||
rescue MachO::MachOError
|
rescue MachO::MachOError
|
||||||
onoe <<~EOS
|
onoe <<~EOS
|
||||||
|
@ -32,8 +32,9 @@ module MachOShim
|
|||||||
machos = []
|
machos = []
|
||||||
mach_data = []
|
mach_data = []
|
||||||
|
|
||||||
if macho.is_a?(MachO::FatFile)
|
case (macho = self.macho)
|
||||||
machos = T.cast(macho, MachO::FatFile).machos
|
when MachO::FatFile
|
||||||
|
machos = macho.machos
|
||||||
else
|
else
|
||||||
machos << macho
|
machos << macho
|
||||||
end
|
end
|
||||||
@ -70,8 +71,8 @@ module MachOShim
|
|||||||
|
|
||||||
# TODO: See if the `#write!` call can be delayed until
|
# TODO: See if the `#write!` call can be delayed until
|
||||||
# we know we're not making any changes to the rpaths.
|
# we know we're not making any changes to the rpaths.
|
||||||
sig { params(rpath: String).void }
|
sig { params(rpath: String, strict: T::Boolean).void }
|
||||||
def delete_rpath(rpath)
|
def delete_rpath(rpath, strict: true)
|
||||||
candidates = rpaths(resolve_variable_references: false).select do |r|
|
candidates = rpaths(resolve_variable_references: false).select do |r|
|
||||||
resolve_variable_name(r) == resolve_variable_name(rpath)
|
resolve_variable_name(r) == resolve_variable_name(rpath)
|
||||||
end
|
end
|
||||||
@ -79,25 +80,25 @@ module MachOShim
|
|||||||
# Delete the last instance to avoid changing the order in which rpaths are searched.
|
# Delete the last instance to avoid changing the order in which rpaths are searched.
|
||||||
rpath_to_delete = candidates.last
|
rpath_to_delete = candidates.last
|
||||||
|
|
||||||
macho.delete_rpath(rpath_to_delete, { last: true })
|
macho.delete_rpath(rpath_to_delete, { last: true, strict: })
|
||||||
macho.write!
|
macho.write!
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(old: String, new: String, uniq: T::Boolean, last: T::Boolean).void }
|
sig { params(old: String, new: String, uniq: T::Boolean, last: T::Boolean, strict: T::Boolean).void }
|
||||||
def change_rpath(old, new, uniq: false, last: false)
|
def change_rpath(old, new, uniq: false, last: false, strict: true)
|
||||||
macho.change_rpath(old, new, { uniq: uniq, last: last })
|
macho.change_rpath(old, new, { uniq:, last:, strict: })
|
||||||
macho.write!
|
macho.write!
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(id: String).void }
|
sig { params(id: String, strict: T::Boolean).void }
|
||||||
def change_dylib_id(id)
|
def change_dylib_id(id, strict: true)
|
||||||
macho.change_dylib_id(id)
|
macho.change_dylib_id(id, { strict: })
|
||||||
macho.write!
|
macho.write!
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(old: String, new: String).void }
|
sig { params(old: String, new: String, strict: T::Boolean).void }
|
||||||
def change_install_name(old, new)
|
def change_install_name(old, new, strict: true)
|
||||||
macho.change_install_name(old, new)
|
macho.change_install_name(old, new, { strict: })
|
||||||
macho.write!
|
macho.write!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ module OS
|
|||||||
|
|
||||||
sig { void }
|
sig { void }
|
||||||
def initialize
|
def initialize
|
||||||
@all_sdks = T.let([], T::Array[SDK])
|
@all_sdks = T.let(nil, T.nilable(T::Array[SDK]))
|
||||||
@sdk_prefix = T.let(nil, T.nilable(String))
|
@sdk_prefix = T.let(nil, T.nilable(String))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -52,7 +52,9 @@ module OS
|
|||||||
|
|
||||||
sig { returns(T::Array[SDK]) }
|
sig { returns(T::Array[SDK]) }
|
||||||
def all_sdks
|
def all_sdks
|
||||||
return @all_sdks unless @all_sdks.empty?
|
return @all_sdks if @all_sdks
|
||||||
|
|
||||||
|
@all_sdks = []
|
||||||
|
|
||||||
# Bail out if there is no SDK prefix at all
|
# Bail out if there is no SDK prefix at all
|
||||||
return @all_sdks unless File.directory? sdk_prefix
|
return @all_sdks unless File.directory? sdk_prefix
|
||||||
|
Loading…
x
Reference in New Issue
Block a user