| Index: platform_tools/android/gyp_gen/gen_public_headers.py
|
| diff --git a/platform_tools/android/gyp_gen/gen_public_headers.py b/platform_tools/android/gyp_gen/gen_public_headers.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..182f7fe9f4d617bfc65659237ef42b2429ef31e8
|
| --- /dev/null
|
| +++ b/platform_tools/android/gyp_gen/gen_public_headers.py
|
| @@ -0,0 +1,70 @@
|
| +#!/usr/bin/python
|
| +
|
| +# Copyright 2014 Google Inc.
|
| +#
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +"""Function for generating public_headers.gypi."""
|
| +
|
| +import os
|
| +
|
| +
|
| +AUTOGEN_WARNING = (
|
| +"""
|
| +###############################################################################
|
| +#
|
| +# THIS FILE IS AUTOGENERATED BY GYP_TO_ANDROID.PY. DO NOT EDIT.
|
| +#
|
| +# Include this gypi to include all public header files that exist in the
|
| +# include directory.
|
| +
|
| +###############################################################################
|
| +
|
| +"""
|
| +)
|
| +
|
| +
|
| +def find_header_files(top_dir):
|
| + """Return a list of all '.h' files in top_dir.
|
| +
|
| + Args:
|
| + top_dir: Path to a directory within which to recursively search for
|
| + files ending in '.h'
|
| +
|
| + Returns:
|
| + A list of all the files inside top_dir that end in '.h', relative to
|
| + top_dir.
|
| + """
|
| + headers = []
|
| + for filename in os.listdir(top_dir):
|
| + full_path = os.path.join(top_dir, filename)
|
| + if os.path.isdir(full_path):
|
| + nested_headers = find_header_files(full_path)
|
| + for nested_header in nested_headers:
|
| + headers.append(os.path.join(filename, nested_header))
|
| + else:
|
| + if filename.endswith('.h'):
|
| + headers.append(filename)
|
| + return headers
|
| +
|
| +
|
| +def generate_public_headers(dst, top_dir):
|
| + """Create a file listing all the header files in top_dir.
|
| +
|
| + Args:
|
| + dst: Path to new file to be written.
|
| + top_dir: Path to a directory within which to recursively search for
|
| + files ending in '.h'
|
| + """
|
| + with open(dst, 'w') as f:
|
| + f.write(AUTOGEN_WARNING)
|
| +
|
| + f.write('{\n')
|
| + f.write(' \'variables\': {\n')
|
| + f.write(' \'header_filenames\': [\n')
|
| + for header in sorted(find_header_files(top_dir)):
|
| + f.write(' \'%s\',\n' % header)
|
| + f.write(' ],\n')
|
| + f.write(' },\n')
|
| + f.write('}\n')
|
|
|