Chromium Code Reviews| Index: third_party/PRESUBMIT.py |
| diff --git a/third_party/PRESUBMIT.py b/third_party/PRESUBMIT.py |
| index 4a6cba81e640304285cd986d166f5d97f82b22bc..38d59c3a2c0c2318b779b0e43e6dbb9d64a09ce7 100644 |
| --- a/third_party/PRESUBMIT.py |
| +++ b/third_party/PRESUBMIT.py |
| @@ -2,6 +2,33 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +ANDROID_WHITELISTED_LICENSES = [ |
| + 'Apache( Version)? 2(\.0)?', |
| + '(New )?([23]-Clause )?BSD( [23]-Clause)?( with advertising clause)?', |
| + 'L?GPL ?v?2(\.[01])?( or later)?', |
| + 'MIT(/X11)?(-like)?', |
| + 'MPL 1\.1 ?/ ?GPL 2(\.0)? ?/ ?LGPL 2\.1', |
| + 'MPL 2(\.0)?', |
| + 'Microsoft Limited Public License', |
| + 'Microsoft Permissive License', |
| + 'Public Domain', |
| + 'Python', |
| + 'SGI Free Software License B', |
| + 'University of Illinois\/NCSA Open Source', |
| + 'X11', |
| +] |
| + |
| +def LicenseIsCompatibleWithAndroid(input_api, license): |
| + regex = '^(%s)$' % '|'.join(ANDROID_WHITELISTED_LICENSES) |
| + tokens = \ |
| + [x.strip() for x in input_api.re.split(' and |,', license) if len(x) > 0] |
| + has_compatible_license = False |
| + for token in tokens: |
| + if input_api.re.match(regex, token, input_api.re.IGNORECASE): |
| + has_compatible_license = True |
| + break |
| + return has_compatible_license |
| + |
| def _CheckThirdPartyReadmesUpdated(input_api, output_api): |
| """ |
| Checks to make sure that README.chromium files are properly updated |
| @@ -39,7 +66,10 @@ def _CheckThirdPartyReadmesUpdated(input_api, output_api): |
| r'^Security Critical: (yes)|(no)\r?$', |
| input_api.re.IGNORECASE | input_api.re.MULTILINE) |
| license_pattern = input_api.re.compile( |
| - r'^License: .+\r?$', |
| + r'^License: (.+)\r?$', |
| + input_api.re.IGNORECASE | input_api.re.MULTILINE) |
| + license_android_compatible_pattern = input_api.re.compile( |
| + r'^License Android Compatible: (yes)|(no)\r?$', |
| input_api.re.IGNORECASE | input_api.re.MULTILINE) |
| for f in readmes: |
| @@ -68,12 +98,21 @@ def _CheckThirdPartyReadmesUpdated(input_api, output_api): |
| 'field. This field specifies whether the package is built with\n' |
| 'Chromium. Check README.chromium.template for details.', |
| [f])) |
| - if not license_pattern.search(contents): |
| + license_match = license_pattern.search(contents) |
| + if not license_match: |
| errors.append(output_api.PresubmitError( |
| 'Third party README files should contain a \'License\' field.\n' |
| 'This field specifies the license used by the package. Check\n' |
| 'README.chromium.template for details.', |
| [f])) |
| + elif not LicenseIsCompatibleWithAndroid(input_api, license_match.group(1)) \ |
| + and not license_android_compatible_pattern.search(contents): |
| + errors.append(output_api.PresubmitError( |
| + 'The license specified does not seem to be allowed in\n' + |
|
mkosiba (inactive)
2014/01/31 17:47:38
I guess this should be something like
'Cannot det
mnaganov (inactive)
2014/02/03 10:00:26
Yes, you are right. Fixed the text.
Also, I have
mkosiba (inactive)
2014/02/03 10:30:55
Makes sense. I guess that once I add the other bit
|
| + 'the Android tree. Please check that the license name is spelled\n' + |
| + 'according to third_party/PRESUBMIT.py. Please see\n' + |
| + 'README.chromium.template for details.', |
| + [f])) |
| return errors |