| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # This script should be run manually on occasion to make sure the gyp file and | 7 # This script should be run manually on occasion to make sure the gyp file and |
| 8 # the includes tests are up to date. | 8 # the includes tests are up to date. |
| 9 # It does the following: | 9 # It does the following: |
| 10 # - Verifies that all source code is in ppapi.gyp | 10 # - Verifies that all source code is in ppapi.gyp |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 | 86 |
| 87 def WriteLines(filename, lines): | 87 def WriteLines(filename, lines): |
| 88 outfile = open(filename, 'w') | 88 outfile = open(filename, 'w') |
| 89 for line in lines: | 89 for line in lines: |
| 90 outfile.write(line) | 90 outfile.write(line) |
| 91 outfile.write('\n') | 91 outfile.write('\n') |
| 92 | 92 |
| 93 | 93 |
| 94 COPYRIGHT_STRING_C = \ | 94 COPYRIGHT_STRING_C = \ |
| 95 """ | 95 """/* Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 96 /* Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 97 * Use of this source code is governed by a BSD-style license that can be | 96 * Use of this source code is governed by a BSD-style license that can be |
| 98 * found in the LICENSE file. | 97 * found in the LICENSE file. |
| 99 * | 98 * |
| 100 * This test simply includes all the C headers to ensure they compile with a C | 99 * This test simply includes all the C headers to ensure they compile with a C |
| 101 * compiler. If it compiles, it passes. | 100 * compiler. If it compiles, it passes. |
| 102 */ | 101 */ |
| 103 """ | 102 """ |
| 104 | 103 |
| 105 COPYRIGHT_STRING_CC = \ | 104 COPYRIGHT_STRING_CC = \ |
| 106 """ | 105 """// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 107 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 108 // Use of this source code is governed by a BSD-style license that can be | 106 // Use of this source code is governed by a BSD-style license that can be |
| 109 // found in the LICENSE file. | 107 // found in the LICENSE file. |
| 110 // | 108 // |
| 111 // This test simply includes all the C++ headers to ensure they compile with a | 109 // This test simply includes all the C++ headers to ensure they compile with a |
| 112 // C++ compiler. If it compiles, it passes. | 110 // C++ compiler. If it compiles, it passes. |
| 113 // | 111 // |
| 114 """ | 112 """ |
| 115 | 113 |
| 116 | 114 |
| 117 # Get the source file names out of the given gyp file data object (as evaluated | 115 # Get the source file names out of the given gyp file data object (as evaluated |
| 118 # from a gyp file) for the given target name. Return the string names in | 116 # from a gyp file) for the given target name. Return the string names in |
| 119 # sorted order. | 117 # sorted order. |
| 120 def GetSourcesForTarget(target_name, gyp_file_data): | 118 def GetSourcesForTarget(target_name, gyp_file_data): |
| 121 for target in gyp_file_data[GYP_TARGETS_KEY]: | 119 for target in gyp_file_data[GYP_TARGETS_KEY]: |
| 122 if target[GYP_TARGET_NAME_KEY] == target_name: | 120 if target[GYP_TARGET_NAME_KEY] == target_name: |
| 123 sources = target[GYP_SOURCES_KEY] | 121 sources = target[GYP_SOURCES_KEY] |
| 124 sources.sort() | 122 sources.sort() |
| 125 return sources | 123 return sources |
| 126 print 'Warning: no target named ', target, ' found.' | 124 print 'Warning: no target named ', target, ' found.' |
| 127 return [] | 125 return [] |
| 128 | 126 |
| 129 | 127 |
| 130 # Generate test_c_includes.c, which is a test to ensure that all the headers in | 128 # Generate all_c_includes.h, which includes all C headers. This is part of |
| 131 # ppapi/c can be compiled with a C compiler. | 129 # tests/test_c_sizes.c, which includes all C API files to ensure that all |
| 130 # the headers in ppapi/c can be compiled with a C compiler, and also asserts |
| 131 # (with compile-time assertions) that all structs and enums are a particular |
| 132 # size. |
| 132 def GenerateCIncludeTest(gyp_file_data): | 133 def GenerateCIncludeTest(gyp_file_data): |
| 133 c_sources = GetSourcesForTarget('ppapi_c', gyp_file_data) | 134 c_sources = GetSourcesForTarget('ppapi_c', gyp_file_data) |
| 134 lines = [COPYRIGHT_STRING_C] | 135 lines = [COPYRIGHT_STRING_C] |
| 135 for source in c_sources: | 136 for source in c_sources: |
| 136 lines.append('#include "ppapi/' + source + '"\n') | 137 lines.append('#include "ppapi/' + source + '"\n') |
| 137 WriteLines('tests/test_c_includes.c', lines) | 138 WriteLines('tests/all_c_includes.h', lines) |
| 138 | 139 |
| 139 | 140 |
| 140 # Generate test_cc_includes.cc, which is a test to ensure that all the headers | 141 # Generate test_cc_includes.cc, which is a test to ensure that all the headers |
| 141 # in ppapi/cpp can be compiled with a C++ compiler. | 142 # in ppapi/cpp can be compiled with a C++ compiler. |
| 142 def GenerateCCIncludeTest(gyp_file_data): | 143 def GenerateCCIncludeTest(gyp_file_data): |
| 143 cc_sources = GetSourcesForTarget('ppapi_cpp_objects', gyp_file_data) | 144 cc_sources = GetSourcesForTarget('ppapi_cpp_objects', gyp_file_data) |
| 144 header_re = re.compile('.+\.h$') | 145 header_re = re.compile('.+\.h$') |
| 145 lines = [COPYRIGHT_STRING_CC] | 146 lines = [COPYRIGHT_STRING_CC] |
| 146 for source in cc_sources: | 147 for source in cc_sources: |
| 147 if header_re.match(source): | 148 if header_re.match(source): |
| 148 lines.append('#include "ppapi/' + source + '"\n') | 149 lines.append('#include "ppapi/' + source + '"\n') |
| 149 WriteLines('tests/test_cc_includes.cc', lines) | 150 WriteLines('tests/all_cc_includes.h', lines) |
| 150 | 151 |
| 151 | 152 |
| 152 def main(): | 153 def main(): |
| 153 ppapi_gyp_file_name = 'ppapi.gyp' | 154 ppapi_gyp_file_name = 'ppapi.gyp' |
| 154 gyp_file_contents = open(ppapi_gyp_file_name).read() | 155 gyp_file_contents = open(ppapi_gyp_file_name).read() |
| 155 gyp_file_data = eval(gyp_file_contents) | 156 gyp_file_data = eval(gyp_file_contents) |
| 156 VerifyGypFile(gyp_file_data) | 157 VerifyGypFile(gyp_file_data) |
| 157 GenerateCIncludeTest(gyp_file_data) | 158 GenerateCIncludeTest(gyp_file_data) |
| 158 GenerateCCIncludeTest(gyp_file_data) | 159 GenerateCCIncludeTest(gyp_file_data) |
| 159 return 0 | 160 return 0 |
| 160 | 161 |
| 161 | 162 |
| 162 if __name__ == '__main__': | 163 if __name__ == '__main__': |
| 163 sys.exit(main()) | 164 sys.exit(main()) |
| 164 | 165 |
| OLD | NEW |