OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 |
| 3 # Copyright 2014 Google Inc. |
| 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. |
| 7 |
| 8 """Function for generating public_headers.gypi.""" |
| 9 |
| 10 import os |
| 11 |
| 12 |
| 13 AUTOGEN_WARNING = ( |
| 14 """ |
| 15 ############################################################################### |
| 16 # |
| 17 # THIS FILE IS AUTOGENERATED BY GYP_TO_ANDROID.PY. DO NOT EDIT. |
| 18 # |
| 19 # Include this gypi to include all public header files that exist in the |
| 20 # include directory. |
| 21 |
| 22 ############################################################################### |
| 23 |
| 24 """ |
| 25 ) |
| 26 |
| 27 |
| 28 def find_header_files(top_dir): |
| 29 """Return a list of all '.h' files in top_dir. |
| 30 |
| 31 Args: |
| 32 top_dir: Path to a directory within which to recursively search for |
| 33 files ending in '.h' |
| 34 |
| 35 Returns: |
| 36 A list of all the files inside top_dir that end in '.h', relative to |
| 37 top_dir. |
| 38 """ |
| 39 headers = [] |
| 40 for filename in os.listdir(top_dir): |
| 41 full_path = os.path.join(top_dir, filename) |
| 42 if os.path.isdir(full_path): |
| 43 nested_headers = find_header_files(full_path) |
| 44 for nested_header in nested_headers: |
| 45 headers.append(os.path.join(filename, nested_header)) |
| 46 else: |
| 47 if filename.endswith('.h'): |
| 48 headers.append(filename) |
| 49 return headers |
| 50 |
| 51 |
| 52 def generate_public_headers(dst, top_dir): |
| 53 """Create a file listing all the header files in top_dir. |
| 54 |
| 55 Args: |
| 56 dst: Path to new file to be written. |
| 57 top_dir: Path to a directory within which to recursively search for |
| 58 files ending in '.h' |
| 59 """ |
| 60 with open(dst, 'w') as f: |
| 61 f.write(AUTOGEN_WARNING) |
| 62 |
| 63 f.write('{\n') |
| 64 f.write(' \'variables\': {\n') |
| 65 f.write(' \'header_filenames\': [\n') |
| 66 for header in sorted(find_header_files(top_dir)): |
| 67 f.write(' \'%s\',\n' % header) |
| 68 f.write(' ],\n') |
| 69 f.write(' },\n') |
| 70 f.write('}\n') |
OLD | NEW |