aboutsummaryrefslogtreecommitdiff
path: root/javac.in
blob: 3e41b6792f9a1a0cbadc13f674ad6fd07fef9573 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/perl -w
use strict;
use constant NO_DUP_ARGS => qw(-source -target -d -encoding);
use constant STRIP_ARGS_1 => qw(-Werror -implicit:none);
use constant STRIP_ARGS_2 => qw(-Xmaxwarns);

my ($ECJ_WARNINGS, $JAVAC_WARNINGS);

if ("@ENABLE_WARNINGS@" eq "yes")
{
    $ECJ_WARNINGS="-warn:-deprecation,serial,unused,warningToken";
    $JAVAC_WARNINGS="-Xlint:unchecked,cast,divzero,empty,finally,overrides";
}
else
{
    $ECJ_WARNINGS="-nowarn";
    $JAVAC_WARNINGS="-nowarn";
}

my @bcoption;
push @bcoption, '-bootclasspath', glob '@abs_top_builddir@/bootstrap/jdk1.6.0/jre/lib/rt.jar'
    unless grep {$_ eq '-bootclasspath'} @ARGV;
my @ecj_parms = ($ECJ_WARNINGS, @bcoption);
my @javac_parms = ($JAVAC_WARNINGS, '-Xprefer:source',
		   '-XDignore.symbol.file=true', '-J-Xmx1024m');

# Work around ecj's inability to handle duplicate command-line
# options and unknown javac options.
sub gen_ecj_opts
{
    my @new_args = @{$_[0]};

    for my $opt (NO_DUP_ARGS) 
    {
	my @indices = reverse grep {$new_args[$_] eq $opt} 0..$#new_args;
	if (@indices > 1) {
	    shift @indices;    # keep last instance only
	    splice @new_args, $_, 2 for @indices;
	}
    }

    for my $opt (STRIP_ARGS_1) 
    {
	my @indices = reverse grep {$new_args[$_] eq $opt} 0..$#new_args;
	splice @new_args, $_, 1 for @indices;
    }

    for my $opt (STRIP_ARGS_2) 
    {
	my @indices = reverse grep {$new_args[$_] eq $opt} 0..$#new_args;
	splice @new_args, $_, 2 for @indices;
    }

    return @new_args;
}

if ( -e "@abs_top_builddir@/native-ecj" )
{
    my @ecj_args = gen_ecj_opts( \@ARGV );
    exec '@abs_top_builddir@/native-ecj', @ecj_parms, @ecj_args ;
}
elsif ( -e "@JAVAC@" )
{
    if ("@USING_ECJ@" eq "yes")
    {
	my @ecj_args = gen_ecj_opts( \@ARGV );
	exec '@JAVAC@', @ecj_parms, @ecj_args ;
    }
    else
    {
	exec '@JAVAC@', @javac_parms, @ARGV ;
    }
}
else
{
    my @ecj_args = gen_ecj_opts( \@ARGV );
    my @CLASSPATH = ('@ECJ_JAR@');
    push @CLASSPATH, split /:/, $ENV{"CLASSPATH"} if exists $ENV{"CLASSPATH"};
    $ENV{"CLASSPATH"} = join ':', @CLASSPATH;
    exec '@JAVA@', 'org.eclipse.jdt.internal.compiler.batch.Main', @ecj_parms, @ecj_args;
}