os/mac/*: style corrections
Signed-off-by: botantony <antonsm21@gmail.com> Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
0adf85970d
commit
bc2c12c742
@ -2,13 +2,20 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Keg
|
class Keg
|
||||||
|
sig { params(path: Pathname).void }
|
||||||
|
def initialize(path)
|
||||||
|
super
|
||||||
|
|
||||||
|
@require_relocation = T.let(nil, T.nilable(T::Boolean))
|
||||||
|
end
|
||||||
|
|
||||||
sig { params(id: String, file: Pathname).returns(T::Boolean) }
|
sig { params(id: String, file: Pathname).returns(T::Boolean) }
|
||||||
def change_dylib_id(id, file)
|
def change_dylib_id(id, file)
|
||||||
return false if file.dylib_id == id
|
return false if file.dylib_id == id
|
||||||
|
|
||||||
@require_relocation = T.let(true, T.nilable(T::Boolean))
|
@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, strict: false)
|
file.change_dylib_id(id)
|
||||||
true
|
true
|
||||||
rescue MachO::MachOError
|
rescue MachO::MachOError
|
||||||
onoe <<~EOS
|
onoe <<~EOS
|
||||||
@ -23,9 +30,9 @@ class Keg
|
|||||||
def change_install_name(old, new, file)
|
def change_install_name(old, new, file)
|
||||||
return false if old == new
|
return false if old == new
|
||||||
|
|
||||||
@require_relocation = T.let(true, T.nilable(T::Boolean))
|
@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, strict: false)
|
file.change_install_name(old, new)
|
||||||
true
|
true
|
||||||
rescue MachO::MachOError
|
rescue MachO::MachOError
|
||||||
onoe <<~EOS
|
onoe <<~EOS
|
||||||
@ -40,9 +47,9 @@ class Keg
|
|||||||
def change_rpath(old, new, file)
|
def change_rpath(old, new, file)
|
||||||
return false if old == new
|
return false if old == new
|
||||||
|
|
||||||
@require_relocation = T.let(true, T.nilable(T::Boolean))
|
@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, strict: false)
|
file.change_rpath(old, new)
|
||||||
true
|
true
|
||||||
rescue MachO::MachOError
|
rescue MachO::MachOError
|
||||||
onoe <<~EOS
|
onoe <<~EOS
|
||||||
@ -56,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, strict: false)
|
file.delete_rpath(rpath)
|
||||||
true
|
true
|
||||||
rescue MachO::MachOError
|
rescue MachO::MachOError
|
||||||
onoe <<~EOS
|
onoe <<~EOS
|
||||||
|
@ -70,35 +70,34 @@ 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, options: T::Boolean).void }
|
sig { params(rpath: String).void }
|
||||||
def delete_rpath(rpath, **options)
|
def delete_rpath(rpath)
|
||||||
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
|
||||||
|
|
||||||
# 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
|
||||||
options[:last] = true
|
|
||||||
|
|
||||||
macho.delete_rpath(rpath_to_delete, options)
|
macho.delete_rpath(rpath_to_delete, { last: true })
|
||||||
macho.write!
|
macho.write!
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(old: String, new: String, options: T::Boolean).void }
|
sig { params(old: String, new: String, uniq: T::Boolean, last: T::Boolean).void }
|
||||||
def change_rpath(old, new, **options)
|
def change_rpath(old, new, uniq: false, last: false)
|
||||||
macho.change_rpath(old, new, options)
|
macho.change_rpath(old, new, { uniq: uniq, last: last })
|
||||||
macho.write!
|
macho.write!
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(id: String, options: T::Boolean).void }
|
sig { params(id: String).void }
|
||||||
def change_dylib_id(id, **options)
|
def change_dylib_id(id)
|
||||||
macho.change_dylib_id(id, options)
|
macho.change_dylib_id(id)
|
||||||
macho.write!
|
macho.write!
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(old: String, new: String, options: T::Boolean).void }
|
sig { params(old: String, new: String).void }
|
||||||
def change_install_name(old, new, **options)
|
def change_install_name(old, new)
|
||||||
macho.change_install_name(old, new, options)
|
macho.change_install_name(old, new)
|
||||||
macho.write!
|
macho.write!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module OS
|
|||||||
sig { params(version: MacOSVersion, path: T.any(String, Pathname), source: Symbol).void }
|
sig { params(version: MacOSVersion, path: T.any(String, Pathname), source: Symbol).void }
|
||||||
def initialize(version, path, source)
|
def initialize(version, path, source)
|
||||||
@version = version
|
@version = version
|
||||||
@path = T.let(Pathname.new(path), Pathname)
|
@path = T.let(Pathname(path), Pathname)
|
||||||
@source = source
|
@source = source
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -39,6 +39,7 @@ module OS
|
|||||||
sig { void }
|
sig { void }
|
||||||
def initialize
|
def initialize
|
||||||
@all_sdks = T.let([], T::Array[SDK])
|
@all_sdks = T.let([], T::Array[SDK])
|
||||||
|
@sdk_prefix = T.let(nil, T.nilable(String))
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(version: MacOSVersion).returns(SDK) }
|
sig { params(version: MacOSVersion).returns(SDK) }
|
||||||
@ -150,7 +151,7 @@ module OS
|
|||||||
|
|
||||||
sig { override.returns(String) }
|
sig { override.returns(String) }
|
||||||
def sdk_prefix
|
def sdk_prefix
|
||||||
@sdk_prefix ||= T.let(begin
|
@sdk_prefix ||= begin
|
||||||
# Xcode.prefix is pretty smart, so let's look inside to find the sdk
|
# Xcode.prefix is pretty smart, so let's look inside to find the sdk
|
||||||
sdk_prefix = "#{Xcode.prefix}/Platforms/MacOSX.platform/Developer/SDKs"
|
sdk_prefix = "#{Xcode.prefix}/Platforms/MacOSX.platform/Developer/SDKs"
|
||||||
# Finally query Xcode itself (this is slow, so check it last)
|
# Finally query Xcode itself (this is slow, so check it last)
|
||||||
@ -158,7 +159,7 @@ module OS
|
|||||||
sdk_prefix = File.join(sdk_platform_path, "Developer", "SDKs") unless File.directory? sdk_prefix
|
sdk_prefix = File.join(sdk_platform_path, "Developer", "SDKs") unless File.directory? sdk_prefix
|
||||||
|
|
||||||
sdk_prefix
|
sdk_prefix
|
||||||
end, T.nilable(String))
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -180,11 +181,11 @@ module OS
|
|||||||
# return `nil` SDKs for Xcode 9 and older.
|
# return `nil` SDKs for Xcode 9 and older.
|
||||||
sig { override.returns(String) }
|
sig { override.returns(String) }
|
||||||
def sdk_prefix
|
def sdk_prefix
|
||||||
@sdk_prefix ||= T.let(if CLT.provides_sdk?
|
@sdk_prefix ||= if CLT.provides_sdk?
|
||||||
"#{CLT::PKG_PATH}/SDKs"
|
"#{CLT::PKG_PATH}/SDKs"
|
||||||
else
|
else
|
||||||
""
|
""
|
||||||
end, T.nilable(String))
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user