Index: talk/build/export_headers |
diff --git a/talk/build/export_headers b/talk/build/export_headers |
new file mode 100755 |
index 0000000000000000000000000000000000000000..580e68fb55ea928b10116696b2a2cc39d0eedc44 |
--- /dev/null |
+++ b/talk/build/export_headers |
@@ -0,0 +1,86 @@ |
+#!/usr/bin/python |
+ |
+# Copyright 2016 The WebRTC project authors. All Rights Reserved. |
+# |
+# Use of this source code is governed by a BSD-style license |
+# that can be found in the LICENSE file in the root of the source |
+# tree. An additional intellectual property rights grant can be found |
+# in the file PATENTS. All contributing project authors may |
+# be found in the AUTHORS file in the root of the source tree. |
+ |
+"""Script for exporting iOS header files.""" |
+ |
+import errno |
+import optparse |
+import os |
+import re |
+import shutil |
+import sys |
+ |
+old_header_dirs = ['talk/app/webrtc/objc/public'] |
tkchin_webrtc
2016/02/17 22:15:58
these should be constants, so all caps
hjon_webrtc
2016/02/18 19:26:41
Done.
|
+new_header_dirs = ['webrtc/api/objc/', 'webrtc/base/objc/'] |
tkchin_webrtc
2016/02/17 22:15:58
nit: suggest
legacy_header_dirs
header_dirs
so no
hjon_webrtc
2016/02/18 19:26:41
Done.
|
+# Individual header files that should also be exported. |
+old_include_headers = [] |
tkchin_webrtc
2016/02/17 22:15:58
nit: header_includes
header_excludes
hjon_webrtc
2016/02/18 19:26:41
Done.
|
+new_include_headers = [] |
+# Individual header files that should not be exported. |
+old_exclude_headers = ['talk/app/webrtc/objc/public/RTCNSGLVideoView.h'] |
+new_exclude_headers = ['webrtc/api/objc/avfoundationvideocapturer.h', |
+ 'webrtc/api/objc/RTCNSGLVideoView.h'] |
+ |
+def ExportHeaders(include_base_dir, use_new_headers): |
+ """Exports iOS header files. |
+ |
+ Creates an include directory and recreates the hierarchy for the header files |
+ within the include directory. |
+ |
+ Args: |
+ include_base_dir: directory where the include directory should be created |
+ """ |
+ |
+ include_dir_name = 'include' |
+ include_path = os.path.join(include_base_dir, include_dir_name) |
+ |
+ script_path = sys.path[0] |
+ webrtc_base_path = os.path.join(script_path, '../..') |
+ |
+ header_dirs = old_header_dirs |
+ include_headers = old_include_headers |
+ exclude_headers = old_exclude_headers |
+ if int(use_new_headers): |
+ header_dirs = new_header_dirs |
+ include_headers = new_include_headers |
+ exclude_headers = new_exclude_headers |
+ |
+ for directory in header_dirs: |
+ full_dir_path = os.path.join(webrtc_base_path, directory) |
+ filenames = os.listdir(full_dir_path) |
+ for filename in filenames: |
+ if filename.endswith('.h') and not filename.endswith('+Private.h'): |
+ include_headers.append(os.path.join(directory, filename)) |
+ |
+ for header in exclude_headers: |
+ include_headers.remove(header) |
+ |
+ for header_path in include_headers: |
+ output_dir = os.path.join(include_path, os.path.dirname(header_path)) |
+ # Create hierarchy for the header file within the include directory. |
+ try: |
+ os.makedirs(output_dir) |
+ except OSError as exc: |
+ if exc.errno != errno.EEXIST: |
+ raise exc |
+ current_path = os.path.join(webrtc_base_path, header_path) |
+ new_path = os.path.join(include_path, header_path) |
+ shutil.copy(current_path, new_path) |
+ |
+def Main(): |
+ parser = optparse.OptionParser() |
+ _, args = parser.parse_args() |
+ if len(args) != 2: |
+ parser.error('Error: Exactly 2 arguments required.') |
+ include_base_dir = args[0] |
+ use_new_headers = args[1] |
+ ExportHeaders(include_base_dir, use_new_headers) |
+ |
+if __name__ == '__main__': |
+ sys.exit(Main()) |