| Index: android_webview/tools/webview_licenses.py
|
| diff --git a/android_webview/tools/webview_licenses.py b/android_webview/tools/webview_licenses.py
|
| index 0d2a7af9186baf90181f2f400cf369eee396d85b..28124a45e674522a496d244e1112d291f1a2ba32 100755
|
| --- a/android_webview/tools/webview_licenses.py
|
| +++ b/android_webview/tools/webview_licenses.py
|
| @@ -86,64 +86,42 @@ def _CheckLicenseHeaders(directory_list, whitelisted_files):
|
| whitelist contains no stale entries, otherwise false.
|
| """
|
|
|
| - # Matches one of ...
|
| - # - '[Cc]opyright', but not when followed by
|
| - # ' 20[0-9][0-9] The Chromium Authors.', with optional (c) and date range
|
| - # - '([Cc]) (19|20)[0-9][0-9]', but not when preceeded by the word copyright,
|
| - # as this is handled above
|
| - regex = '[Cc]opyright(?!( \(c\))? 20[0-9][0-9](-20[0-9][0-9])? ' \
|
| - 'The Chromium Authors\. All rights reserved\.)' \
|
| - '|' \
|
| - '(?<!(pyright |opyright))\([Cc]\) (19|20)[0-9][0-9]'
|
| -
|
| - args = ['grep',
|
| - '-rPlI',
|
| - '--exclude', '*.orig',
|
| - '--exclude', '*.rej',
|
| - '--exclude-dir', 'third_party',
|
| - '--exclude-dir', 'out',
|
| - '--exclude-dir', '.git',
|
| - '--exclude-dir', '.svn',
|
| - regex,
|
| + directory_list = [d for d in directory_list if not 'third_party' in d]
|
| + # This makes the ignore regexp shorter
|
| + directory_list.append('third_party')
|
| + # 'Copyright' appears in license agreements
|
| + directory_list.append('chrome/app/resources')
|
| + # Arm sysroot tools, doesn't exist in the snapshot
|
| + directory_list.append('arm-sysroot')
|
| +
|
| + ignore_patterns = []
|
| + for d in directory_list:
|
| + ignore_patterns.append('(?:/' + d.replace('+', '\+') + '/)')
|
| +
|
| + args = ['third_party/devscripts/licensecheck.pl',
|
| + '--lines', '99',
|
| + '--copyright',
|
| + '--machine',
|
| + '--recursive',
|
| + '--ignore', '|'.join(ignore_patterns),
|
| '.']
|
| p = subprocess.Popen(args=args, cwd=REPOSITORY_ROOT, stdout=subprocess.PIPE)
|
| - files = p.communicate()[0].splitlines()
|
| -
|
| - directory_list = directory_list[:]
|
| - # Ignore these tools.
|
| - directory_list.append('android_webview/tools/')
|
| - # This is a build intermediate directory.
|
| - directory_list.append('chrome/app/theme/google_chrome/')
|
| - # This is tests directory, doesn't exist in the snapshot
|
| - directory_list.append('content/test/data/')
|
| - # This is a test output directory.
|
| - directory_list.append('data/dom_perf/')
|
| - # This is a test output directory.
|
| - directory_list.append('data/page_cycler/')
|
| - # 'Copyright' appears in strings.
|
| - directory_list.append('chrome/app/resources/')
|
| - # This is a Chrome on Linux reference build, doesn't exist in the snapshot
|
| - directory_list.append('chrome/tools/test/reference_build/chrome_linux/')
|
| - # Remoting internal tools, doesn't exist in the snapshot
|
| - directory_list.append('remoting/appengine/')
|
| - # Histogram tools, doesn't exist in the snapshot
|
| - directory_list.append('tools/histograms/')
|
| - # Arm sysroot tools, doesn't exist in the snapshot
|
| - directory_list.append('arm-sysroot/')
|
| - # Windows-only
|
| - directory_list.append('tools/win/toolchain/7z/')
|
| + lines = p.communicate()[0].splitlines()
|
|
|
| - # Exclude files under listed directories and some known offenders.
|
| offending_files = []
|
| - for x in files:
|
| - x = os.path.normpath(x)
|
| - is_in_listed_directory = False
|
| - for y in directory_list:
|
| - if x.startswith(y):
|
| - is_in_listed_directory = True
|
| + allowed_copyrights = '^(?:\*No copyright\*' \
|
| + '|20[0-9][0-9](?:-20[0-9][0-9])? The Chromium Authors\. ' \
|
| + 'All rights reserved.*)$'
|
| + allowed_copyrights_re = re.compile(allowed_copyrights)
|
| + for l in lines:
|
| + entries = l.split('\t')
|
| + if entries[1] == "GENERATED FILE":
|
| + continue
|
| + copyrights = entries[2].split(' / ')
|
| + for c in copyrights:
|
| + if c and not allowed_copyrights_re.match(c):
|
| + offending_files.append(os.path.normpath(entries[0]))
|
| break
|
| - if not is_in_listed_directory:
|
| - offending_files.append(x)
|
|
|
| all_files_valid = True
|
| unknown = set(offending_files) - set(whitelisted_files)
|
|
|