Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright 2016 The WebRTC project authors. All Rights Reserved. | 3 # Copyright 2016 The WebRTC project authors. All Rights Reserved. |
| 4 # | 4 # |
| 5 # Use of this source code is governed by a BSD-style license | 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 | 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 | 7 # tree. An additional intellectual property rights grant can be found |
| 8 # in the file PATENTS. All contributing project authors may | 8 # in the file PATENTS. All contributing project authors may |
| 9 # be found in the AUTHORS file in the root of the source tree. | 9 # be found in the AUTHORS file in the root of the source tree. |
| 10 | 10 |
| 11 """Script for exporting iOS header files.""" | 11 """Script for exporting iOS header files.""" |
| 12 | 12 |
| 13 import errno | 13 import errno |
| 14 import optparse | 14 import optparse |
| 15 import os | 15 import os |
| 16 import re | |
| 17 import shutil | 16 import shutil |
| 18 import sys | 17 import sys |
| 19 | 18 |
| 20 LEGACY_HEADER_DIRS = ['talk/app/webrtc/objc/public', 'webrtc/base/objc/'] | 19 LEGACY_HEADER_DIRS = ['talk/app/webrtc/objc/public', 'webrtc/base/objc/'] |
| 21 HEADER_DIRS = ['webrtc/api/objc/', 'webrtc/base/objc/', | 20 HEADER_DIRS = ['webrtc/api/objc/', 'webrtc/base/objc/', |
| 22 'webrtc/modules/audio_device/ios/objc'] | 21 'webrtc/modules/audio_device/ios/objc'] |
| 23 # Individual header files that should also be exported. | 22 # Individual header files that should also be exported. |
| 24 LEGACY_HEADER_INCLUDES = [] | 23 LEGACY_HEADER_INCLUDES = [] |
| 25 HEADER_INCLUDES = [] | 24 HEADER_INCLUDES = [] |
| 26 # Individual header files that should not be exported. | 25 # Individual header files that should not be exported. |
| 27 LEGACY_HEADER_EXCLUDES = ['talk/app/webrtc/objc/public/RTCNSGLVideoView.h'] | 26 LEGACY_HEADER_EXCLUDES = ['talk/app/webrtc/objc/public/RTCNSGLVideoView.h'] |
| 28 HEADER_EXCLUDES = [ | 27 HEADER_EXCLUDES = [ |
| 29 'webrtc/api/objc/avfoundationvideocapturer.h', | 28 'webrtc/api/objc/avfoundationvideocapturer.h', |
| 30 'webrtc/api/objc/RTCNSGLVideoView.h', | 29 'webrtc/api/objc/RTCNSGLVideoView.h', |
| 30 'webrtc/api/objc/RTCVideoRendererAdapter.h', | |
| 31 'webrtc/base/objc/NSString+StdString.h', | 31 'webrtc/base/objc/NSString+StdString.h', |
| 32 'webrtc/base/objc/RTCUIApplication.h', | 32 'webrtc/base/objc/RTCUIApplication.h', |
| 33 'webrtc/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h', | 33 'webrtc/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h', |
| 34 ] | 34 ] |
| 35 | 35 |
| 36 def ExportHeaders(include_base_dir, use_legacy_headers): | 36 def ExportHeaders(include_base_dir, use_legacy_headers): |
| 37 """Exports iOS header files. | 37 """Exports iOS header files. |
| 38 | 38 |
| 39 Creates an include directory and recreates the hierarchy for the header files | 39 Creates an include directory and recreates the hierarchy for the header files |
| 40 within the include directory. | 40 within the include directory. |
| 41 | 41 |
| 42 Args: | 42 Args: |
| 43 include_base_dir: directory where the include directory should be created | 43 include_base_dir: directory where the include directory should be created |
| 44 """ | 44 """ |
| 45 | 45 |
| 46 include_dir_name = 'include' | 46 include_dir_name = 'include' |
| 47 include_path = os.path.join(include_base_dir, include_dir_name) | 47 include_path = os.path.join(include_base_dir, include_dir_name) |
| 48 # Remove existing directory first in case files change. | 48 # Remove existing directory first in case files change. |
| 49 if (os.path.exists(include_path)): | 49 if os.path.exists(include_path): |
|
kjellander_webrtc
2016/04/15 04:59:41
Aha! With the .py extension you couldn't escape th
tkchin_webrtc
2016/04/16 00:34:18
Indeed! I'm glad I decided to rename it :)
| |
| 50 shutil.rmtree(include_path) | 50 shutil.rmtree(include_path) |
| 51 | 51 |
| 52 script_path = sys.path[0] | 52 script_path = sys.path[0] |
| 53 webrtc_base_path = os.path.join(script_path, '../../..') | 53 webrtc_base_path = os.path.join(script_path, '../../..') |
| 54 | 54 |
| 55 header_dirs = HEADER_DIRS | 55 header_dirs = HEADER_DIRS |
| 56 include_headers = HEADER_INCLUDES | 56 include_headers = HEADER_INCLUDES |
| 57 exclude_headers = HEADER_EXCLUDES | 57 exclude_headers = HEADER_EXCLUDES |
| 58 if use_legacy_headers: | 58 if use_legacy_headers: |
| 59 header_dirs = LEGACY_HEADER_DIRS | 59 header_dirs = LEGACY_HEADER_DIRS |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 74 output_dir = os.path.join(include_path, os.path.dirname(header_path)) | 74 output_dir = os.path.join(include_path, os.path.dirname(header_path)) |
| 75 # Create hierarchy for the header file within the include directory. | 75 # Create hierarchy for the header file within the include directory. |
| 76 try: | 76 try: |
| 77 os.makedirs(output_dir) | 77 os.makedirs(output_dir) |
| 78 except OSError as exc: | 78 except OSError as exc: |
| 79 if exc.errno != errno.EEXIST: | 79 if exc.errno != errno.EEXIST: |
| 80 raise exc | 80 raise exc |
| 81 current_path = os.path.join(webrtc_base_path, header_path) | 81 current_path = os.path.join(webrtc_base_path, header_path) |
| 82 new_path = os.path.join(include_path, header_path) | 82 new_path = os.path.join(include_path, header_path) |
| 83 shutil.copy(current_path, new_path) | 83 shutil.copy(current_path, new_path) |
| 84 | 84 |
|
kjellander_webrtc
2016/04/15 04:59:41
nit: +1 blank line before top-level definition
htt
tkchin_webrtc
2016/04/16 00:34:19
Done.
| |
| 85 def Main(): | 85 def Main(): |
| 86 parser = optparse.OptionParser() | 86 parser = optparse.OptionParser() |
| 87 _, args = parser.parse_args() | 87 _, args = parser.parse_args() |
|
kjellander_webrtc
2016/04/15 04:59:41
If you're only using positional arguments you migh
tkchin_webrtc
2016/04/16 00:34:18
Done.
| |
| 88 if len(args) != 2: | 88 if len(args) != 2: |
| 89 parser.error('Error: Exactly 2 arguments required.') | 89 parser.error('Error: Exactly 2 arguments required.') |
| 90 include_base_dir = args[0] | 90 include_base_dir = args[0] |
| 91 use_legacy_headers = False if int(args[1]) == 0 else True | 91 use_legacy_headers = False if int(args[1]) == 0 else True |
| 92 ExportHeaders(include_base_dir, use_legacy_headers) | 92 ExportHeaders(include_base_dir, use_legacy_headers) |
| 93 | 93 |
| 94 if __name__ == '__main__': | 94 if __name__ == '__main__': |
| 95 sys.exit(Main()) | 95 sys.exit(Main()) |
| OLD | NEW |