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