Module: MachO::Tools
- Defined in:
- lib/macho/tools.rb
Overview
A collection of convenient methods for common operations on Mach-O and Fat binaries.
Class Method Summary collapse
-
.add_rpath(filename, new_path, options = {}) ⇒ void
Add a runtime path to a Mach-O or Fat binary, overwriting the source file.
-
.change_dylib_id(filename, new_id, options = {}) ⇒ void
Changes the dylib ID of a Mach-O or Fat binary, overwriting the source file.
-
.change_install_name(filename, old_name, new_name, options = {}) ⇒ void
Changes a shared library install name in a Mach-O or Fat binary, overwriting the source file.
-
.change_rpath(filename, old_path, new_path, options = {}) ⇒ void
Changes a runtime path in a Mach-O or Fat binary, overwriting the source file.
-
.delete_rpath(filename, old_path, options = {}) ⇒ void
Delete a runtime path from a Mach-O or Fat binary, overwriting the source file.
-
.dylibs(filename) ⇒ Array<String>
An array of all dylibs linked to the binary.
-
.merge_machos(filename, *files, fat64: false) ⇒ void
Merge multiple Mach-Os into one universal (Fat) binary.
Class Method Details
.add_rpath(filename, new_path, options = {}) ⇒ void
This method returns an undefined value.
Add a runtime path to a Mach-O or Fat binary, overwriting the source file.
71 72 73 74 75 76 |
# File 'lib/macho/tools.rb', line 71 def self.add_rpath(filename, new_path, = {}) file = MachO.open(filename) file.add_rpath(new_path, ) file.write! end |
.change_dylib_id(filename, new_id, options = {}) ⇒ void
This method returns an undefined value.
Changes the dylib ID of a Mach-O or Fat binary, overwriting the source file.
23 24 25 26 27 28 |
# File 'lib/macho/tools.rb', line 23 def self.change_dylib_id(filename, new_id, = {}) file = MachO.open(filename) file.change_dylib_id(new_id, ) file.write! end |
.change_install_name(filename, old_name, new_name, options = {}) ⇒ void
This method returns an undefined value.
Changes a shared library install name in a Mach-O or Fat binary, overwriting the source file.
39 40 41 42 43 44 |
# File 'lib/macho/tools.rb', line 39 def self.change_install_name(filename, old_name, new_name, = {}) file = MachO.open(filename) file.change_install_name(old_name, new_name, ) file.write! end |
.change_rpath(filename, old_path, new_path, options = {}) ⇒ void
This method returns an undefined value.
Changes a runtime path in a Mach-O or Fat binary, overwriting the source file.
57 58 59 60 61 62 |
# File 'lib/macho/tools.rb', line 57 def self.change_rpath(filename, old_path, new_path, = {}) file = MachO.open(filename) file.change_rpath(old_path, new_path, ) file.write! end |
.delete_rpath(filename, old_path, options = {}) ⇒ void
This method returns an undefined value.
Delete a runtime path from a Mach-O or Fat binary, overwriting the source file.
88 89 90 91 92 93 |
# File 'lib/macho/tools.rb', line 88 def self.delete_rpath(filename, old_path, = {}) file = MachO.open(filename) file.delete_rpath(old_path, ) file.write! end |
.dylibs(filename) ⇒ Array<String>
Returns an array of all dylibs linked to the binary.
9 10 11 12 13 |
# File 'lib/macho/tools.rb', line 9 def self.dylibs(filename) file = MachO.open(filename) file.linked_dylibs end |
.merge_machos(filename, *files, fat64: false) ⇒ void
This method returns an undefined value.
Merge multiple Mach-Os into one universal (Fat) binary.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/macho/tools.rb', line 100 def self.merge_machos(filename, *files, fat64: false) machos = files.map do |file| macho = MachO.open(file) case macho when MachO::MachOFile macho else macho.machos end end.flatten fat_macho = MachO::FatFile.new_from_machos(*machos, :fat64 => fat64) fat_macho.write(filename) end |