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

Unified Diff: ppapi/generate_ppapi_include_tests.py

Issue 5190004: This accomplishes a few things:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « no previous file | ppapi/ppapi.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/generate_ppapi_include_tests.py
===================================================================
--- ppapi/generate_ppapi_include_tests.py (revision 0)
+++ ppapi/generate_ppapi_include_tests.py (revision 0)
@@ -0,0 +1,116 @@
+#!/usr/bin/python
+
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import re
+import os
+import sys
+import posixpath
+
+source_file_re = re.compile('.+\.(cc|c|h)$')
+
+# TODO(dmichael): Put examples back in the build.
+# TODO(brettw): Put proxy in the build when it's ready.
+ignore_re = re.compile('.*(examples|GLES|proxy).*')
+
+# Open ppapi.gyp. Return a set containing all source files found.
+def get_gyp_sources(gyp_file_data):
David Springer 2010/11/18 21:21:42 I recommend taking a look at the Python style guid
dmichael(do not use this one) 2010/11/18 21:51:35 Looks like lowercase/underscores: http://google-s
David Springer 2010/11/19 00:14:21 Awesome - it turns out that the internal style gui
+ sources = set([])
+ for target in gyp_file_data['targets']:
+ source_list = [source for source in target['sources']
+ if not ignore_re.match(source)]
+ sources |= set(source_list)
+ return sources
+
+# Search the local directory and all its subdirectories for source files.
+# Return a set containing all the source files found.
+def get_file_sources():
+ file_set = set([])
+ for root, dirs, files in os.walk('.'):
+ if (not ignore_re.match(root)):
+ adjusted_root = root[2:]
+ sources = [posixpath.join(adjusted_root, src)
+ for src in files if source_file_re.match(src)]
+ file_set |= set(sources)
+ return file_set
+
+
+# Make sure all source files are in ppapi.gyp, and all files in ppapi.gyp exist.
+def verify_gyp_file(gyp_file_data):
+ gyp_sources = get_gyp_sources(gyp_file_data)
+ file_sources = get_file_sources()
+ in_gyp_not_file = gyp_sources - file_sources
+ in_file_not_gyp = file_sources - gyp_sources
+ if (len(in_gyp_not_file)):
+ print "Found source file(s) in ppapi.gyp but not in the directory:", \
+ in_gyp_not_file
+ if (len(in_file_not_gyp)):
+ print "Found source file(s) in the directory but not in ppapi.gyp:", \
+ in_file_not_gyp
+ error_count = len(in_gyp_not_file) + len(in_file_not_gyp)
+ if (error_count):
+ sys.exit(error_count)
+
+def writelines(filename, lines):
+ outfile = open(filename, 'w')
+ for line in lines:
+ outfile.write(line)
+ outfile.write("\n")
+
+copyright_string_c = \
+"/* Copyright (c) 2010 The Chromium Authors. All rights reserved.\n\
+ * Use of this source code is governed by a BSD-style license that can be\n\
+ * found in the LICENSE file.\n\
+ *\n\
+ * This test simply includes all the C headers to ensure they compile with a\n\
+ * C compiler. If it compiles, it passes.\n\
+ */\n"
+
+copyright_string_cc = \
+"// Copyright (c) 2010 The Chromium Authors. All rights reserved.\n\
+// Use of this source code is governed by a BSD-style license that can be\n\
+// found in the LICENSE file.\n\
+//\n\
+// This test simply includes all the C++ headers to ensure they compile with\n\
+// a C++ compiler. If it compiles, it passes.\n\
+//\n"
+
+def get_sources_for_target(target_name, gyp_file_data):
+ for target in gyp_file_data['targets']:
+ if target['target_name'] == target_name:
+ sources = target['sources']
+ sources.sort()
+ return sources
+ print "Warning: no target named ", target, " found."
+ return []
+
+# Generate test_c_includes.c, which is a test to ensure that all the headers in
+# ppapi/c can be compiled with a C compiler.
David Springer 2010/11/18 21:21:42 When you generate this, does test_c_includes.c go
dmichael(do not use this one) 2010/11/18 21:51:35 Currently it just goes in "tests" alongside non-ge
+def generate_test_c_includes(gyp_file_data):
+ c_sources = get_sources_for_target('ppapi_c', gyp_file_data)
+ lines = [copyright_string_c]
+ for source in c_sources:
+ lines.append("#include \"ppapi/" + source + "\"\n")
+ writelines('tests/test_c_includes.c', lines)
+
+# Generate test_cc_includes.cc, which is a test to ensure that all the headers
+# in ppapi/cpp can be compiled with a C++ compiler.
+def generate_test_cc_includes(gyp_file_data):
+ cc_sources = get_sources_for_target('ppapi_cpp_objects', gyp_file_data)
+ header_re = re.compile('.+\.h$')
+ lines = [copyright_string_cc]
+ for source in cc_sources:
+ if (header_re.match(source)):
+ lines.append("#include \"ppapi/" + source + "\"\n")
+ writelines('tests/test_cc_includes.cc', lines)
+
+if __name__ == "__main__":
David Springer 2010/11/18 21:21:42 From looking around at other .py files, it seems t
dmichael(do not use this one) 2010/11/18 21:51:35 Done.
+ gyp_file_contents = open("ppapi.gyp").read()
+ gyp_file_data = eval(gyp_file_contents)
+ verify_gyp_file(gyp_file_data)
+ generate_test_c_includes(gyp_file_data)
+ generate_test_cc_includes(gyp_file_data)
+
+# Generate test_c_includes.c, which is a test to ensure that all
David Springer 2010/11/18 21:21:42 This comment seems to be spurious - or the file go
dmichael(do not use this one) 2010/11/18 21:51:35 Oops, Done.
Property changes on: ppapi/generate_ppapi_include_tests.py
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « no previous file | ppapi/ppapi.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698