Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: android_webview/tools/webview_licenses.py

Issue 133073008: Add an option to scan for incompatible folders to the WebView license tool. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
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 import known_issues 33 import known_issues
34 34
35 def GetIncompatibleDirectories(): 35 def GetIncompatibleDirectories():
36 """Gets a list of third-party directories which use licenses incompatible 36 """Gets a list of third-party directories which use licenses incompatible
37 with Android. This is used by the snapshot tool. 37 with Android. This is used by the snapshot tool and the AOSP bot.
38 Returns: 38 Returns:
39 A list of directories. 39 A list of directories.
40 """ 40 """
41 41
42 whitelist = [ 42 whitelist = [
43 'Apache( Version)? 2(\.0)?', 43 'Apache( Version)? 2(\.0)?',
44 '(New )?([23]-Clause )?BSD( [23]-Clause)?( with advertising clause)?', 44 '(New )?([23]-Clause )?BSD( [23]-Clause)?( with advertising clause)?',
45 'L?GPL ?v?2(\.[01])?( or later)?', 45 'L?GPL ?v?2(\.[01])?( or later)?',
46 'MIT(/X11)?(-like)?', 46 'MIT(/X11)?(-like)?',
47 'MPL 1\.1 ?/ ?GPL 2(\.0)? ?/ ?LGPL 2\.1', 47 'MPL 1\.1 ?/ ?GPL 2(\.0)? ?/ ?LGPL 2\.1',
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 def format_description(self, description): 275 def format_description(self, description):
276 paras = description.split('\n') 276 paras = description.split('\n')
277 formatted_paras = [textwrap.fill(para, self.width) for para in paras] 277 formatted_paras = [textwrap.fill(para, self.width) for para in paras]
278 return '\n'.join(formatted_paras) + '\n' 278 return '\n'.join(formatted_paras) + '\n'
279 279
280 parser = optparse.OptionParser(formatter=FormatterWithNewLines(), 280 parser = optparse.OptionParser(formatter=FormatterWithNewLines(),
281 usage='%prog [options]') 281 usage='%prog [options]')
282 parser.description = (__doc__ + 282 parser.description = (__doc__ +
283 '\nCommands:\n' \ 283 '\nCommands:\n' \
284 ' scan Check licenses.\n' \ 284 ' scan Check licenses.\n' \
285 ' notice Generate Android NOTICE file on stdout') 285 ' notice Generate Android NOTICE file on stdout. \n' \
286 (options, args) = parser.parse_args() 286 ' incompatible_directories Scan for incompatibly'
287 ' licensed directories.')
288 (_, args) = parser.parse_args()
287 if len(args) != 1: 289 if len(args) != 1:
288 parser.print_help() 290 parser.print_help()
289 return ScanResult.Errors 291 return ScanResult.Errors
290 292
291 if args[0] == 'scan': 293 if args[0] == 'scan':
292 scan_result = _Scan() 294 scan_result = _Scan()
293 if scan_result == ScanResult.Ok: 295 if scan_result == ScanResult.Ok:
294 print 'OK!' 296 print 'OK!'
295 return scan_result 297 return scan_result
296 elif args[0] == 'notice': 298 elif args[0] == 'notice':
297 print GenerateNoticeFile() 299 print GenerateNoticeFile()
298 return ScanResult.Ok 300 return ScanResult.Ok
301 elif args[0] == 'incompatible_directories':
302 incompatible_directories = GetIncompatibleDirectories()
303 if incompatible_directories:
304 print ("Incompatibly licensed directories found:" +
305 "\n".join(incompatible_directories))
306 return ScanResult.Errors
307 return ScanResult.Ok
299 308
300 parser.print_help() 309 parser.print_help()
301 return ScanResult.Errors 310 return ScanResult.Errors
302 311
303 if __name__ == '__main__': 312 if __name__ == '__main__':
304 sys.exit(main()) 313 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698