@@ -0,0 +1,2423 @@
+#!/usr/bin/python%0A# Copyright 2018 gRPC authors.%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#     http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0A# This script analyzes link map file generated by Xcode. It calculates and%0A# prints out the sizes of each dependent library and the total sizes of the%0A# symbols.%0A# The script takes one parameter, which is the path to the link map file.%0A%0Aimport sys%0Aimport re%0A%0Atable_tag = %7B%7D%0Astate = %22start%22%0A%0Atable_stats_symbol = %7B%7D%0Atable_stats_dead = %7B%7D%0Asection_total_size = 0%0Asymbol_total_size = 0%0A%0A%0Afile_import = sys.argv%5B1%5D%0Alines = list(open(file_import))%0Afor line in lines:%0A  line_stripped = line%5B:-1%5D%0A  if %22# Object files:%22 == line_stripped:%0A    state = %22object%22%0A    continue%0A  elif %22# Sections:%22 == line_stripped:%0A    state = %22section%22%0A    continue%0A  elif %22# Symbols:%22 == line_stripped:%0A    state = %22symbol%22%0A    continue%0A  elif %22# Dead Stripped Symbols:%22 == line_stripped:%0A    state = %22dead%22%0A    continue%0A%0A  if state == %22object%22:%0A    segs = re.search('(%5C%5B *%5B0-9%5D*%5C%5D) (.*)', line_stripped)%0A    table_tag%5Bsegs.group(1)%5D = segs.group(2)%0A%0A  if state == %22section%22:%0A    if len(line_stripped) == 0 or line_stripped%5B0%5D == '#':%0A      continue%0A    segs = re.search('%5E(.+?)%5Cs+(.+?)%5Cs+.*', line_stripped)%0A    section_total_size += int(segs.group(2), 16)%0A%0A  if state == %22symbol%22:%0A    if len(line_stripped) == 0 or line_stripped%5B0%5D == '#':%0A      continue%0A    segs = re.search('%5E.+?%5Cs+(.+?)%5Cs+(%5C%5B.+?%5C%5D).*', line_stripped)%0A    target = table_tag%5Bsegs.group(2)%5D%0A    target_stripped = re.search('%5E(.*?)(%5C(.+?%5C))?$', target).group(1)%0A    size = int(segs.group(1), 16)%0A    if not target_stripped in table_stats_symbol:%0A      table_stats_symbol%5Btarget_stripped%5D = 0%0A    table_stats_symbol%5Btarget_stripped%5D += size%0A%0Aprint(%22Sections total size: %25d%22 %25 section_total_size)%0A%0Afor target in table_stats_symbol:%0A  print(target)%0A  print(table_stats_symbol%5Btarget%5D)%0A  symbol_total_size += table_stats_symbol%5Btarget%5D%0A%0Aprint(%22Symbols total size: %25d%22 %25 symbol_total_size)%0A

Add Xcode link map analyzer