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

Unified 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 side-by-side diff with in-line comments
Download patch
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 = []
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
+ 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')
« 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