Chromium Code Reviews| 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..a914b41c88d5b5a3781dca1ca5c81ad78d4c7c59 100755 |
| --- a/android_webview/tools/webview_licenses.py |
| +++ b/android_webview/tools/webview_licenses.py |
| @@ -86,64 +86,45 @@ 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', |
| + '--check', '\.(c(c|pp|xx)?|h(h|pp|xx)?|p(l|m)|xs|sh|php|py(|x)|rb' \ |
|
Paweł Hajdan Jr.
2013/01/25 17:54:33
Do you need to use --check? Why?
mnaganov (inactive)
2013/01/28 14:51:54
Because the pattern in licensecheck.pl apparently
Paweł Hajdan Jr.
2013/01/28 16:28:29
Why not update the pattern in licensecheck.pl then
mnaganov (inactive)
2013/01/28 17:12:38
I was considering these additions to be Chromium-s
|
| + '|java|vala|el|sc(i|e)|cs|pas|inc|dtd|xsl|mod|m|tex|mli?|js|html' \ |
| + '|pac|mm|asm|idl)$', |
| + '--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) |