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

Side by Side Diff: android_webview/tools/find_copyrights.pl

Issue 589143002: [Android WebView] Run license scanning in parallel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | android_webview/tools/find_files.pl » ('j') | android_webview/tools/find_files.pl » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/perl -w 1 #!/usr/bin/perl -w
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 # Use: find_copyrights.pl <start-from> [exclude-dir ...] 6 # Use: echo filename1.cc ... | find_copyrights.pl
7 # or: find_copyrights.pl list_file
8 # or: find_files.pl ... | find_copyrights.pl
7 9
8 use strict; 10 use strict;
9 use warnings; 11 use warnings;
10 use File::Basename; 12 use File::Basename;
11 13
12 sub check_is_generated_file($); 14 sub check_is_generated_file($);
13 sub start_copyright_parsing(); 15 sub start_copyright_parsing();
14 16
15 my $progname = basename($0); 17 my $progname = basename($0);
16 18
17 my $root_dir = shift @ARGV; 19 my $generated_file_scan_boundary = 25;
18 my @find_args = (); 20 while (<>) {
19 while (@ARGV) {
20 my $path = shift @ARGV;
21 push @find_args, qw'-not ( -path', "*/$path/*", qw'-prune )'
22 }
23 push @find_args, qw(-follow -type f -print);
24
25 open FIND, '-|', 'find', $root_dir, @find_args
26 or die "$progname: Couldn't exec find: $!\n";
27 my $check_regex = '\.(asm|c(c|pp|xx)?|h(h|pp|xx)?|p(l|m)|xs|sh|php|py(|x)' .
28 '|rb|idl|java|el|sc(i|e)|cs|pas|inc|js|pac|html|dtd|xsl|mod|mm?' .
29 '|tex|mli?)$';
30 my @files = ();
31 while (<FIND>) {
32 chomp; 21 chomp;
33 push @files, $_ unless (-z $_ || !m%$check_regex%); 22 my $file = $_;
34 }
35 close FIND;
36
37 my $generated_file_scan_boundary = 25;
38 while (@files) {
39 my $file = shift @files;
40 my $file_header = ''; 23 my $file_header = '';
41 my %copyrights; 24 my %copyrights;
42 open (F, "<$file") or die "$progname: Unable to access $file\n"; 25 open (F, "<$file") or die "$progname: Unable to access $file\n";
43 my $parse_copyright = start_copyright_parsing(); 26 my $parse_copyright = start_copyright_parsing();
44 while (<F>) { 27 while (<F>) {
45 $file_header .= $_ unless $. > $generated_file_scan_boundary; 28 $file_header .= $_ unless $. > $generated_file_scan_boundary;
46 my $copyright_match = $parse_copyright->($_, $.); 29 my $copyright_match = $parse_copyright->($_, $.);
47 if ($copyright_match) { 30 if ($copyright_match) {
48 $copyrights{lc("$copyright_match")} = "$copyright_match"; 31 $copyrights{lc("$copyright_match")} = "$copyright_match";
49 } 32 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 $match =~ s/^\s+//; 137 $match =~ s/^\s+//;
155 $match =~ s/\s{2,}/ /g; 138 $match =~ s/\s{2,}/ /g;
156 $match =~ s/\\@/@/g; 139 $match =~ s/\\@/@/g;
157 $copyright = $match; 140 $copyright = $match;
158 } 141 }
159 } 142 }
160 143
161 return $copyright; 144 return $copyright;
162 } 145 }
163 } 146 }
OLDNEW
« no previous file with comments | « no previous file | android_webview/tools/find_files.pl » ('j') | android_webview/tools/find_files.pl » ('J')

Powered by Google App Engine
This is Rietveld 408576698