1#!/usr/bin/env vpython3 2 3# 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 16def _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 22 23 return '%s#import <WebRTC/%sRTC%s.h>%s' % (match.group(1), match.group(3), 24 match.group(4), match.group(5)) 25 26 27def 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") 32 33 34def main(): 35 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) 43 44 45if __name__ == '__main__': 46 sys.exit(main()) 47