diff options
author | mnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-10 12:44:09 +0000 |
---|---|---|
committer | mnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-10 12:44:09 +0000 |
commit | fd00e49adcf05f05a5cff215abed207e738c606c (patch) | |
tree | a53a61b29acbbe88db2179e3e919817872ed98cc /android_webview | |
parent | 0819558cee773646a70d92adb6ed2ca944677e0d (diff) | |
download | chromium_src-fd00e49adcf05f05a5cff215abed207e738c606c.zip chromium_src-fd00e49adcf05f05a5cff215abed207e738c606c.tar.gz chromium_src-fd00e49adcf05f05a5cff215abed207e738c606c.tar.bz2 |
Add checking for license formats to third_party/PRESUBMIT
Since we expect a certain format for the "License:" field, it's better to
check it earlier -- during the presubmit stage, so people won't get
surprises later.
Also, updated the license checking code to accept multiple licenses if
one of them is compatible with Android.
BUG=168324
R=dannyb@google.com, mkosiba@chromium.org
TBR=darin@chromium.org
Review URL: https://codereview.chromium.org/146803006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250068 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rwxr-xr-x | android_webview/tools/webview_licenses.py | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/android_webview/tools/webview_licenses.py b/android_webview/tools/webview_licenses.py index 40755da..d87c47b 100755 --- a/android_webview/tools/webview_licenses.py +++ b/android_webview/tools/webview_licenses.py @@ -17,6 +17,7 @@ aren't in a third-party directory with a README.chromium file. """ import glob +import imp import optparse import os import re @@ -28,11 +29,22 @@ import textwrap REPOSITORY_ROOT = os.path.abspath(os.path.join( os.path.dirname(__file__), '..', '..')) +# Import third_party/PRESUBMIT.py via imp to avoid importing a random +# PRESUBMIT.py from $PATH, also make sure we don't generate a .pyc file. +sys.dont_write_bytecode = True +third_party = \ + imp.load_source('PRESUBMIT', \ + os.path.join(REPOSITORY_ROOT, 'third_party', 'PRESUBMIT.py')) + sys.path.append(os.path.join(REPOSITORY_ROOT, 'tools')) import licenses import known_issues +class InputApi(object): + def __init__(self): + self.re = re + def GetIncompatibleDirectories(): """Gets a list of third-party directories which use licenses incompatible with Android. This is used by the snapshot tool. @@ -40,23 +52,6 @@ def GetIncompatibleDirectories(): A list of directories. """ - whitelist = [ - 'A(pple )?PSL 2(\.0)?', - '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', - ] - regex = '^(%s)$' % '|'.join(whitelist) result = [] for directory in _FindThirdPartyDirs(): if directory in known_issues.KNOWN_ISSUES: @@ -71,11 +66,8 @@ def GetIncompatibleDirectories(): if metadata.get('License Android Compatible', 'no').upper() == 'YES': continue license = re.split(' [Ll]icenses?$', metadata['License'])[0] - tokens = [x.strip() for x in re.split(' and |,', license) if len(x) > 0] - for token in tokens: - if not re.match(regex, token, re.IGNORECASE): - result.append(directory) - break + if not third_party.LicenseIsCompatibleWithAndroid(InputApi(), license): + result.append(directory) return result def GetUnknownIncompatibleDirectories(): |