1 | #!/usr/bin/perl -w
|
---|
2 | use strict;
|
---|
3 | use constant NO_DUP_ARGS => qw(-source -target -d -encoding);
|
---|
4 | use constant STRIP_ARGS => qw(-Werror -implicit:none);
|
---|
5 |
|
---|
6 | my $ECJ_WARNINGS="-warn:-unused,-serial";
|
---|
7 | my $JAVAC_WARNINGS="-Xlint:all,-serial";
|
---|
8 |
|
---|
9 | my @bcoption;
|
---|
10 | push @bcoption, '-bootclasspath', glob '@abs_top_builddir@/bootstrap/jdk1.6.0/jre/lib/rt.jar'
|
---|
11 | unless grep {$_ eq '-bootclasspath'} @ARGV;
|
---|
12 | my @ecj_parms = ($ECJ_WARNINGS, @bcoption);
|
---|
13 |
|
---|
14 | # Work around ecj's inability to handle duplicate command-line
|
---|
15 | # options and unknown javac options.
|
---|
16 | sub gen_ecj_opts
|
---|
17 | {
|
---|
18 | my @new_args = @{$_[0]};
|
---|
19 |
|
---|
20 | for my $opt (NO_DUP_ARGS)
|
---|
21 | {
|
---|
22 | my @indices = reverse grep {$new_args[$_] eq $opt} 0..$#new_args;
|
---|
23 | if (@indices > 1) {
|
---|
24 | shift @indices; # keep last instance only
|
---|
25 | splice @new_args, $_, 2 for @indices;
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | for my $opt (STRIP_ARGS)
|
---|
30 | {
|
---|
31 | my @indices = reverse grep {$new_args[$_] eq $opt} 0..$#new_args;
|
---|
32 | splice @new_args, $_, 1 for @indices;
|
---|
33 | }
|
---|
34 |
|
---|
35 | return @new_args;
|
---|
36 | }
|
---|
37 |
|
---|
38 | if ( -e "@abs_top_builddir@/native-ecj" )
|
---|
39 | {
|
---|
40 | my @ecj_args = gen_ecj_opts( \@ARGV );
|
---|
41 | exec '@abs_top_builddir@/native-ecj', @ecj_parms, @ecj_args ;
|
---|
42 | }
|
---|
43 | elsif ( -e "@JAVAC@" )
|
---|
44 | {
|
---|
45 | if ("@USING_ECJ@" eq "yes")
|
---|
46 | {
|
---|
47 | my @ecj_args = gen_ecj_opts( \@ARGV );
|
---|
48 | exec '@JAVAC@', @ecj_parms, @ecj_args ;
|
---|
49 | }
|
---|
50 | else
|
---|
51 | {
|
---|
52 | exec '@JAVAC@', $JAVAC_WARNINGS, @ARGV ;
|
---|
53 | }
|
---|
54 | }
|
---|
55 | else
|
---|
56 | {
|
---|
57 | my @ecj_args = gen_ecj_opts( \@ARGV );
|
---|
58 | my @CLASSPATH = ('@ECJ_JAR@');
|
---|
59 | push @CLASSPATH, split /:/, $ENV{"CLASSPATH"} if exists $ENV{"CLASSPATH"};
|
---|
60 | $ENV{"CLASSPATH"} = join ':', @CLASSPATH;
|
---|
61 | exec '@JAVA@', 'org.eclipse.jdt.internal.compiler.batch.Main', @ecj_parms, @ecj_args;
|
---|
62 | }
|
---|