Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Checks third-party licenses for the purposes of the Android WebView build. | 6 """Checks third-party licenses for the purposes of the Android WebView build. |
| 7 | 7 |
| 8 The Android tree includes a snapshot of Chromium in order to power the system | 8 The Android tree includes a snapshot of Chromium in order to power the system |
| 9 WebView. This tool checks that all code uses open-source licenses compatible | 9 WebView. This tool checks that all code uses open-source licenses compatible |
| 10 with Android, and that we meet the requirements of those licenses. It can also | 10 with Android, and that we meet the requirements of those licenses. It can also |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 import textwrap | 24 import textwrap |
| 25 | 25 |
| 26 | 26 |
| 27 REPOSITORY_ROOT = os.path.abspath(os.path.join( | 27 REPOSITORY_ROOT = os.path.abspath(os.path.join( |
| 28 os.path.dirname(__file__), '..', '..')) | 28 os.path.dirname(__file__), '..', '..')) |
| 29 | 29 |
| 30 sys.path.append(os.path.join(REPOSITORY_ROOT, 'tools')) | 30 sys.path.append(os.path.join(REPOSITORY_ROOT, 'tools')) |
| 31 import licenses | 31 import licenses |
| 32 | 32 |
| 33 | 33 |
| 34 def GetIncompatibleDirectories(): | |
| 35 """Gets a list of third-party directories which use licenses incompatible | |
| 36 with Android. This is used by the snapshot tool. | |
| 37 Returns: | |
| 38 A list of directories. | |
| 39 """ | |
| 40 | |
| 41 whitelist = [ | |
| 42 'Apache( Version)? 2(\.0)?', | |
| 43 '(New )?BSD( 3-Clause)?( with advertising clause)?', | |
| 44 'L?GPL ?v?2(\.[01])?( or later)?', | |
|
Nico
2012/08/10 00:36:48
You're whitelisting GPL?
Steve Block
2012/08/10 07:55:22
GPL v2, yes. While we can't include GPL v2 code in
| |
| 45 'MIT(/X11)?(-like)?', | |
| 46 'MPL 1\.1 ?/ ?GPL 2(\.0)? ?/ ?LGPL 2\.1', | |
| 47 'Microsoft Limited Public License', | |
| 48 'Microsoft Permissive License', | |
| 49 'Public Domain', | |
| 50 'SGI Free Software License B', | |
| 51 'X11', | |
| 52 ] | |
| 53 regex = '^(%s)$' % '|'.join(whitelist) | |
| 54 result = [] | |
| 55 for directory in _FindThirdPartyDirs(): | |
| 56 metadata = licenses.ParseDir(directory) | |
| 57 if metadata.get('Android Compatibility', 'no') == 'yes': | |
|
Nico
2012/08/10 16:42:16
nit: "Android Compatibility: yes" reads weird to m
| |
| 58 continue | |
| 59 license = re.split(' [Ll]icenses?$', metadata['License'])[0] | |
| 60 tokens = [x.strip() for x in re.split(' and |,', license) if len(x) > 0] | |
| 61 for token in tokens: | |
| 62 if not re.match(regex, token, re.IGNORECASE): | |
| 63 result.append(directory) | |
| 64 break | |
| 65 return result | |
| 66 | |
| 67 | |
| 34 def _CheckLicenseHeaders(directory_list, whitelisted_files): | 68 def _CheckLicenseHeaders(directory_list, whitelisted_files): |
| 35 """Checks that all files which are not in a listed third-party directory, | 69 """Checks that all files which are not in a listed third-party directory, |
| 36 and which do not use the standard Chromium license, are whitelisted. | 70 and which do not use the standard Chromium license, are whitelisted. |
| 37 Args: | 71 Args: |
| 38 directory_list: The list of directories. | 72 directory_list: The list of directories. |
| 39 whitelisted_files: The whitelist of files. | 73 whitelisted_files: The whitelist of files. |
| 40 Returns: | 74 Returns: |
| 41 True if all files with non-standard license headers are whitelisted and the | 75 True if all files with non-standard license headers are whitelisted and the |
| 42 whitelist contains no stale entries, otherwise false. | 76 whitelist contains no stale entries, otherwise false. |
| 43 """ | 77 """ |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 return 1 | 246 return 1 |
| 213 elif args[0] == 'notice': | 247 elif args[0] == 'notice': |
| 214 print _GenerateNoticeFile(print_warnings=False) | 248 print _GenerateNoticeFile(print_warnings=False) |
| 215 return 0 | 249 return 0 |
| 216 | 250 |
| 217 parser.print_help() | 251 parser.print_help() |
| 218 return 1 | 252 return 1 |
| 219 | 253 |
| 220 if __name__ == '__main__': | 254 if __name__ == '__main__': |
| 221 sys.exit(main()) | 255 sys.exit(main()) |
| OLD | NEW |