OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python | |
2 | |
3 # Copyright 2016 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 | |
11 """Script for exporting iOS header files.""" | |
12 | |
13 import errno | |
14 import optparse | |
15 import os | |
16 import re | |
17 import shutil | |
18 import sys | |
19 | |
20 | |
21 def ExportHeaders(include_base_dir): | |
22 """Exports iOS header files. | |
23 | |
24 Creates an include directory and recreates the hierarchy for the header files | |
25 within the include directory. | |
26 | |
27 Args: | |
28 include_base_dir: directory where the include directory should be created | |
29 """ | |
30 header_dirs = ['webrtc/api/objc/', 'webrtc/base/objc/'] | |
31 # Individual header files that should also be exported. | |
32 include_headers = [] | |
33 # Individual header files that should not be exported. | |
34 exclude_headers = ['webrtc/api/objc/RTCNSGLVideoView.h'] | |
hjon_webrtc
2016/02/10 21:41:15
Should avfoundationvideocapturer.h be excluded?
| |
35 | |
36 include_dir_name = 'include' | |
37 include_path = os.path.join(include_base_dir, include_dir_name) | |
38 | |
39 script_path = sys.path[0] | |
40 webrtc_base_path = os.path.join(script_path, '../..') | |
41 | |
42 for directory in header_dirs: | |
43 full_dir_path = os.path.join(webrtc_base_path, directory) | |
44 filenames = os.listdir(full_dir_path) | |
45 for filename in filenames: | |
46 if filename.endswith('.h') and not filename.endswith('+Private.h'): | |
47 include_headers.append(os.path.join(directory, filename)) | |
48 | |
49 for header in exclude_headers: | |
50 include_headers.remove(header) | |
51 | |
52 for header_path in include_headers: | |
53 output_dir = os.path.join(include_path, os.path.dirname(header_path)) | |
54 # Create hierarchy for the header file within the include directory. | |
55 try: | |
56 os.makedirs(output_dir) | |
57 except OSError as exc: | |
58 if exc.errno != errno.EEXIST: | |
59 raise exc | |
60 current_path = os.path.join(webrtc_base_path, header_path) | |
61 new_path = os.path.join(include_path, header_path) | |
62 shutil.copy(current_path, new_path) | |
63 | |
64 def Main(): | |
65 parser = optparse.OptionParser() | |
66 _, args = parser.parse_args() | |
67 if len(args) != 1: | |
68 parser.error('Error: Exactly 1 argument required.') | |
69 include_base_dir = args[0] | |
70 ExportHeaders(include_base_dir) | |
71 | |
72 if __name__ == '__main__': | |
73 sys.exit(Main()) | |
OLD | NEW |