-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dSYM parser can dump multi dSYM in one zip file
- Loading branch information
Showing
10 changed files
with
415 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'app_info/dsym/macho' | ||
|
||
module AppInfo | ||
class DSYM < File | ||
# DSYM Debug Information Format Struct | ||
class DebugInfo | ||
attr_reader :path | ||
|
||
def initialize(path) | ||
@path = path | ||
end | ||
|
||
def object | ||
@object ||= ::File.basename(bin_path) | ||
end | ||
|
||
def macho_type | ||
@macho_type ||= ::MachO.open(bin_path) | ||
end | ||
|
||
def machos | ||
@machos ||= case macho_type | ||
when ::MachO::MachOFile | ||
[MachO.new(macho_type, ::File.size(bin_path))] | ||
else | ||
size = macho_type.fat_archs.each_with_object([]) do |arch, obj| | ||
obj << arch.size | ||
end | ||
|
||
machos = [] | ||
macho_type.machos.each_with_index do |file, i| | ||
machos << MachO.new(file, size[i]) | ||
end | ||
machos | ||
end | ||
end | ||
|
||
def release_version | ||
info.try(:[], 'CFBundleShortVersionString') | ||
end | ||
|
||
def build_version | ||
info.try(:[], 'CFBundleVersion') | ||
end | ||
|
||
def identifier | ||
info.try(:[], 'CFBundleIdentifier').sub('com.apple.xcode.dsym.', '') | ||
end | ||
alias bundle_id identifier | ||
|
||
def info | ||
return nil unless ::File.exist?(info_path) | ||
|
||
@info ||= CFPropertyList.native_types(CFPropertyList::List.new(file: info_path).value) | ||
end | ||
|
||
def info_path | ||
@info_path ||= ::File.join(path, 'Contents', 'Info.plist') | ||
end | ||
|
||
def bin_path | ||
@bin_path ||= lambda { | ||
dwarf_path = ::File.join(path, 'Contents', 'Resources', 'DWARF') | ||
name = Dir.children(dwarf_path)[0] | ||
::File.join(dwarf_path, name) | ||
}.call | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'macho' | ||
|
||
module AppInfo | ||
class DSYM < File | ||
# Mach-O Struct | ||
class MachO | ||
include Helper::HumanFileSize | ||
|
||
def initialize(file, size = 0) | ||
@file = file | ||
@size = size | ||
end | ||
|
||
def cpu_name | ||
@file.cpusubtype | ||
end | ||
|
||
def cpu_type | ||
@file.cputype | ||
end | ||
|
||
def type | ||
@file.filetype | ||
end | ||
|
||
def size(human_size: false) | ||
return number_to_human_size(@size) if human_size | ||
|
||
@size | ||
end | ||
|
||
def uuid | ||
@file[:LC_UUID][0].uuid_string | ||
end | ||
alias debug_id uuid | ||
|
||
def header | ||
@header ||= @file.header | ||
end | ||
|
||
def to_h | ||
{ | ||
uuid: uuid, | ||
type: type, | ||
cpu_name: cpu_name, | ||
cpu_type: cpu_type, | ||
size: size, | ||
human_size: size(human_size: true) | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.