xref: /aosp_15_r20/external/angle/build/config/apple/compile_ib_files.py (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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
5import argparse
6import logging
7import os
8import re
9import subprocess
10import sys
11
12
13def 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
57if __name__ == '__main__':
58  sys.exit(main())
59