source: trunk/icedtea-web/javac.in@ 417

Last change on this file since 417 was 348, checked in by dmik, 13 years ago

vendor: Add icedtea-web v1.1.2 to current.

File size: 1.6 KB
Line 
1#!/usr/bin/perl -w
2use strict;
3use constant NO_DUP_ARGS => qw(-source -target -d -encoding);
4use constant STRIP_ARGS => qw(-Werror -implicit:none);
5
6my $ECJ_WARNINGS="-warn:-unused,-serial";
7my $JAVAC_WARNINGS="-Xlint:all,-serial";
8
9my @bcoption;
10push @bcoption, '-bootclasspath', glob '@abs_top_builddir@/bootstrap/jdk1.6.0/jre/lib/rt.jar'
11 unless grep {$_ eq '-bootclasspath'} @ARGV;
12my @ecj_parms = ($ECJ_WARNINGS, @bcoption);
13
14# Work around ecj's inability to handle duplicate command-line
15# options and unknown javac options.
16sub 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
38if ( -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}
43elsif ( -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}
55else
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}
Note: See TracBrowser for help on using the repository browser.