Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: platform_tools/android/gyp_gen/gen_public_headers.py

Issue 198063002: Updates to Android.mk generation. (Closed) Base URL: https://skia.googlesource.com/skia.git@android_mk
Patch Set: Rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 = []
hal.canary 2014/03/27 12:30:15 More Pythonic: return sorted( os.path.join(
scroggo 2014/03/27 19:33:00 Thanks for the feedback! I'm actually removing thi
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')
OLDNEW
« no previous file with comments | « platform_tools/android/bin/gyp_to_android.py ('k') | platform_tools/android/gyp_gen/generate_user_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698