tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

compile_ib_files.py (1607B)


      1 # Copyright 2016 The Chromium Authors
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import argparse
      6 import logging
      7 import os
      8 import re
      9 import subprocess
     10 import sys
     11 
     12 
     13 def main():
     14  parser = argparse.ArgumentParser(
     15      description='A script to compile xib and storyboard.',
     16      fromfile_prefix_chars='@')
     17  parser.add_argument('-o',
     18                      '--output',
     19                      required=True,
     20                      help='Path to output bundle.')
     21  parser.add_argument('-i',
     22                      '--input',
     23                      required=True,
     24                      help='Path to input xib or storyboard.')
     25  args, unknown_args = parser.parse_known_args()
     26 
     27  ibtool_args = [
     28      'xcrun', 'ibtool', '--errors', '--warnings', '--notices',
     29      '--output-format', 'human-readable-text'
     30  ]
     31  ibtool_args += unknown_args
     32  ibtool_args += [
     33      '--compile',
     34      os.path.abspath(args.output),
     35      os.path.abspath(args.input)
     36  ]
     37 
     38  ibtool_section_re = re.compile(r'/\*.*\*/')
     39  ibtool_re = re.compile(r'.*note:.*is clipping its content')
     40  try:
     41    stdout = subprocess.check_output(ibtool_args)
     42  except subprocess.CalledProcessError as e:
     43    print(e.output)
     44    raise
     45  current_section_header = None
     46  for line in stdout.splitlines():
     47    if ibtool_section_re.match(line):
     48      current_section_header = line
     49    elif not ibtool_re.match(line):
     50      if current_section_header:
     51        print(current_section_header)
     52        current_section_header = None
     53      print(line)
     54  return 0
     55 
     56 
     57 if __name__ == '__main__':
     58  sys.exit(main())