| #!/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 flattening iOS header structure.""" |
| |
| import optparse |
| import os |
| import shutil |
| import sys |
| |
| def FlattenHeaders(lib_base_dir, framework_base_dir): |
| """Flattens iOS header file directory structure.""" |
| include_dir = 'include' |
| unflattened_include_dir_path = os.path.join(lib_base_dir, include_dir) |
| flattened_include_dir_path = os.path.join(framework_base_dir, include_dir) |
| |
| # Create output directories. |
| if not os.path.exists(framework_base_dir): |
| os.mkdir(framework_base_dir) |
| if not os.path.exists(flattened_include_dir_path): |
| os.mkdir(flattened_include_dir_path) |
| |
| for dirpath, _, filenames in os.walk(unflattened_include_dir_path): |
| for filename in filenames: |
| current_path = os.path.join(dirpath, filename) |
| new_path = os.path.join(flattened_include_dir_path, filename) |
| 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.') |
| lib_base_dir = args[0] |
| framework_base_dir = args[1] |
| FlattenHeaders(lib_base_dir, framework_base_dir) |
| |
| if __name__ == '__main__': |
| sys.exit(Main()) |