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. 4from __future__ import print_function 5from __future__ import absolute_import 6import argparse 7import logging 8import os 9import re 10import subprocess 11import sys 12 13 14def main(): 15 parser = argparse.ArgumentParser( 16 description='A script to compile xib and storyboard.', 17 fromfile_prefix_chars='@') 18 parser.add_argument( 19 '-o', '--output', required=True, help='Path to output bundle.') 20 parser.add_argument( 21 '-i', '--input', required=True, help='Path to input xib or storyboard.') 22 parser.add_argument('--developer_dir', required=False, help='Path to Xcode.') 23 args, unknown_args = parser.parse_known_args() 24 if args.developer_dir: 25 os.environ['DEVELOPER_DIR'] = args.developer_dir 26 ibtool_args = [ 27 'xcrun', 'ibtool', '--errors', '--warnings', '--notices', 28 '--output-format', 'human-readable-text' 29 ] 30 ibtool_args += unknown_args 31 ibtool_args += [ 32 '--compile', 33 os.path.abspath(args.output), 34 os.path.abspath(args.input) 35 ] 36 ibtool_section_re = re.compile(rb'/\*.*\*/') 37 ibtool_re = re.compile(rb'.*note:.*is clipping its content') 38 try: 39 stdout = subprocess.check_output(ibtool_args) 40 except subprocess.CalledProcessError as e: 41 print(e.output) 42 raise 43 current_section_header = None 44 for line in stdout.splitlines(): 45 if ibtool_section_re.match(line): 46 current_section_header = line 47 elif not ibtool_re.match(line): 48 if current_section_header: 49 print(current_section_header) 50 current_section_header = None 51 print(line) 52 return 0 53 54 55if __name__ == '__main__': 56 sys.exit(main()) 57