Created
March 1, 2016 21:52
-
-
Save snej/b572157521134de83fb4 to your computer and use it in GitHub Desktop.
Simple tool that scans an iOS library and checks the size of the bitcode segment for each included object file. It logs a warning for files with no bitcode or whose bitcode is less than 1Kbyte; or with the -v flag it logs the sizes of all bitcode segments.
This file contains hidden or 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
#! /usr/bin/env ruby | |
# By Jens Alfke. Do What Thou Wilt shall be the whole of the license. | |
def listBitcode(path, arch, verbose =false) | |
result = [] | |
filename = nil | |
section = nil | |
output = `otool -l -arch #{arch} "#{path}"` | |
output.each_line do |line| | |
if line =~ /\((.+)\):$/ then | |
result << "#{filename}(#{arch}):\t**NONE**" if filename != nil | |
filename = $1 | |
#puts $1+":" | |
elsif line =~ /sectname (\w+)/ | |
section = $1 | |
#puts "\t\tsectname #{$1}" | |
elsif line =~ /size 0x(\w+)/ | |
#puts "\t\tsize #{$1}" | |
if section == "__bitcode" | |
size = $1.to_i(16) | |
warning = (size < 1024) ? " **TINY?**" : "" | |
result << "#{filename}(#{arch}):\t#{size}#{warning}" if verbose || warning!="" | |
filename = nil | |
end | |
end | |
end | |
result << "#{filename}(#{arch}): **NONE**" if filename != nil | |
return result | |
end | |
verbose = false | |
path = ARGV[0] | |
if !path then | |
puts "usage: bitcodesize [-v] objectfilename.a" | |
puts " Finds object files missing bitcode in a static library." | |
exit(1) | |
elsif path == "-v" then | |
verbose = true | |
path = ARGV[1] | |
end | |
puts (listBitcode(path, "arm64", verbose) + listBitcode(path, "armv7", verbose)).sort! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment