Class: Fastlane::Helper::MachoInfo
- Inherits:
-
Object
- Object
- Fastlane::Helper::MachoInfo
- Defined in:
- lib/fastlane/plugin/store_sizer/helper/macho_info.rb
Instance Attribute Summary collapse
-
#encryption_segments ⇒ Object
Returns the value of attribute encryption_segments.
-
#min_os_versions ⇒ Object
Returns the value of attribute min_os_versions.
-
#text_segment_sizes ⇒ Object
Returns the value of attribute text_segment_sizes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(binary_path) ⇒ MachoInfo
constructor
A new instance of MachoInfo.
- #macho_add(macho, file_offset) ⇒ Object
- #sizes_info ⇒ Object
Constructor Details
#initialize(binary_path) ⇒ MachoInfo
Returns a new instance of MachoInfo.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fastlane/plugin/store_sizer/helper/macho_info.rb', line 10 def initialize(binary_path) self.min_os_versions = [] self.encryption_segments = [] self.text_segment_sizes = [] file = MachO.open(binary_path) if file.kind_of?(MachO::FatFile) file.fat_archs.each_index do |arch_index| macho_add(file.machos[arch_index], file.fat_archs[arch_index].offset) end elsif file.kind_of?(MachO::MachOFile) macho_add(file, 0) end end |
Instance Attribute Details
#encryption_segments ⇒ Object
Returns the value of attribute encryption_segments.
7 8 9 |
# File 'lib/fastlane/plugin/store_sizer/helper/macho_info.rb', line 7 def encryption_segments @encryption_segments end |
#min_os_versions ⇒ Object
Returns the value of attribute min_os_versions.
6 7 8 |
# File 'lib/fastlane/plugin/store_sizer/helper/macho_info.rb', line 6 def min_os_versions @min_os_versions end |
#text_segment_sizes ⇒ Object
Returns the value of attribute text_segment_sizes.
8 9 10 |
# File 'lib/fastlane/plugin/store_sizer/helper/macho_info.rb', line 8 def text_segment_sizes @text_segment_sizes end |
Class Method Details
.split_version(version) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/fastlane/plugin/store_sizer/helper/macho_info.rb', line 25 def self.split_version(version) binary = format("%032b", version) return [ binary[0..15], binary[16..23], binary[24..31] ].map { |s| s.to_i(2) } end |
Instance Method Details
#macho_add(macho, file_offset) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fastlane/plugin/store_sizer/helper/macho_info.rb', line 40 def macho_add(macho, file_offset) encryption_info = (macho.magic32? ? macho[:LC_ENCRYPTION_INFO] : macho[:LC_ENCRYPTION_INFO_64]).first self.encryption_segments.push([file_offset + encryption_info.cryptoff, encryption_info.cryptsize]) unless encryption_info.nil? min_version_info = macho[:LC_VERSION_MIN_IPHONEOS].first self.min_os_versions.push(MachoInfo.split_version(min_version_info.version)) unless min_version_info.nil? text_segments = macho.segments.select { |seg| seg.segname == "__TEXT" } self.text_segment_sizes.push(text_segments.map(&:filesize)) unless text_segments.nil? end |
#sizes_info ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/fastlane/plugin/store_sizer/helper/macho_info.rb', line 32 def sizes_info result = {} result["min_os_version"] = self.min_os_versions.first result["text_segments_size"] = self.text_segment_sizes.flatten.reduce(0, :+) result["text_max_slice_size"] = self.text_segment_sizes.flatten.max result end |