-
Notifications
You must be signed in to change notification settings - Fork 2
/
shadeit.pl
67 lines (57 loc) · 2.66 KB
/
shadeit.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use strict;
use warnings;
use File::Path;
mkdirs("java/core/src");
mkdirs("java/util/src");
mkdir "java/util/src/main/java/com/github/os72/protobuf351/util";
mkdir "java/util/src/test/java/com/github/os72/protobuf351/util";
mkdir "java/util/src/test/proto/com/github/os72/protobuf351/util";
shadeit("src/google/protobuf", "src/google/protobuf", ".proto");
shadeit("src/google/protobuf/compiler", "src/google/protobuf/compiler", ".proto");
shadeit("src/google/protobuf/testdata", "src/google/protobuf/testdata", ".proto");
shadeit("src/google/protobuf/util", "src/google/protobuf/util", ".proto");
shadeit("java/core/src/main/java/com/google/protobuf", "java/core/src/main/java/com/github/os72/protobuf351", ".java");
shadeit("java/core/src/test/java/com/google/protobuf", "java/core/src/test/java/com/github/os72/protobuf351", ".java");
shadeit("java/core/src/test/proto/com/google/protobuf", "java/core/src/test/proto/com/github/os72/protobuf351", ".proto");
shadeit("java/util/src/main/java/com/google/protobuf/util", "java/util/src/main/java/com/github/os72/protobuf351/util", ".java");
shadeit("java/util/src/test/java/com/google/protobuf/util", "java/util/src/test/java/com/github/os72/protobuf351/util", ".java");
shadeit("java/util/src/test/proto/com/google/protobuf/util", "java/util/src/test/proto/com/github/os72/protobuf351/util", ".proto");
rmtree "java/core/src/main/java/com/google" or die $!;
rmtree "java/core/src/test/java/com/google" or die $!;
rmtree "java/core/src/test/proto/com/google" or die $!;
rmtree "java/util/src/main/java/com/google" or die $!;
rmtree "java/util/src/test/java/com/google" or die $!;
rmtree "java/util/src/test/proto/com/google" or die $!;
sub shadeit
{
my($dir_in, $dir_out, $suffix) = @_;
opendir(DIR, $dir_in) or die $!;
while (my $file = readdir(DIR)) {
next unless ($file =~ m/$suffix$/);
print "$dir_in/$file\n";
open(FIN, "<$dir_in/$file");
open(FOUT, ">$dir_out/$file.tmp");
while (my $line = <FIN>) {
$line =~ s/com\.google\.protobuf/com.github.os72.protobuf351/g;
$line =~ s/com\/google\/protobuf/com\/github\/os72\/protobuf351/g;
print FOUT $line;
}
close(FIN);
close(FOUT);
rename "$dir_out/$file.tmp", "$dir_out/$file" or die $!;
}
closedir(DIR);
}
sub mkdirs
{
my($dir_out) = @_;
mkdir "$dir_out/main/java/com/github";
mkdir "$dir_out/main/java/com/github/os72";
mkdir "$dir_out/main/java/com/github/os72/protobuf351";
mkdir "$dir_out/test/java/com/github";
mkdir "$dir_out/test/java/com/github/os72";
mkdir "$dir_out/test/java/com/github/os72/protobuf351";
mkdir "$dir_out/test/proto/com/github";
mkdir "$dir_out/test/proto/com/github/os72";
mkdir "$dir_out/test/proto/com/github/os72/protobuf351";
}