blob: 3574a67d2a243d4f95217b0a9e855f08b437c739 [file] [log] [blame]
Christoffer Jansson4e8a7732022-02-08 09:01:12 +01001#!/usr/bin/env vpython3
2
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +09003# Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
4#
5# Use of this source code is governed by a BSD-style license
6# that can be found in the LICENSE file in the root of the source
7# tree. An additional intellectual property rights grant can be found
8# in the file PATENTS. All contributing project authors may
9# be found in the AUTHORS file in the root of the source tree.
10
11import argparse
12import re
13import sys
14
15
Christoffer Jansson4e8a7732022-02-08 09:01:12 +010016def _ReplaceDoubleQuote(line):
17 re_rtc_import = re.compile(r'(\s*)#import\s+"(\S+/|)(\w+\+|)RTC(\w+)\.h"(.*)',
18 re.DOTALL)
19 match = re_rtc_import.match(line)
20 if not match:
21 return line
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +090022
Christoffer Jansson4e8a7732022-02-08 09:01:12 +010023 return '%s#import <WebRTC/%sRTC%s.h>%s' % (match.group(1), match.group(3),
24 match.group(4), match.group(5))
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +090025
26
Christoffer Jansson4e8a7732022-02-08 09:01:12 +010027def Process(input_file, output_file):
28 with open(input_file, 'rb') as fb, open(output_file, 'wb') as fw:
29 for line in fb.read().decode('UTF-8').splitlines():
30 fw.write(_ReplaceDoubleQuote(line).encode('UTF-8'))
31 fw.write(b"\n")
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +090032
33
34def main():
Christoffer Jansson4e8a7732022-02-08 09:01:12 +010035 parser = argparse.ArgumentParser(
36 description=
37 "Copy headers of framework and replace double-quoted includes to" +
38 " angle-bracketed respectively.")
39 parser.add_argument('--input', help='Input header files to copy.', type=str)
40 parser.add_argument('--output', help='Output file.', type=str)
41 parsed_args = parser.parse_args()
42 return Process(parsed_args.input, parsed_args.output)
Daniel.L (Byoungchan Lee)32026ed2020-10-17 07:49:28 +090043
44
45if __name__ == '__main__':
Christoffer Jansson4e8a7732022-02-08 09:01:12 +010046 sys.exit(main())