diff options
author | Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> | 2014-12-23 12:31:50 +0100 |
---|---|---|
committer | Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> | 2015-01-27 15:33:08 +0100 |
commit | 74574fd1e3fad5e0c1d061ce194e47dde0f7f175 (patch) | |
tree | 99b1d38e3b178a4aca30b47f1c0e62b49a8f6c53 /gnu/packages/javac.in | |
parent | bfe26beb3e5ec2dfc327d87d848ea0a4c5abd3c6 (diff) | |
download | patches-74574fd1e3fad5e0c1d061ce194e47dde0f7f175.tar patches-74574fd1e3fad5e0c1d061ce194e47dde0f7f175.tar.gz |
gnu: Add GCJ
* gnu/packages/gcc.scm (gcj-4.8, ecj-bootstrap-4.8): New variables.
* gnu/packages/javac.in: New file.
* gnu-system.am (MISC_DISTRO_FILES): Add it.
* Makefile.am (nobase_dist_guilemodule_DATA): Add MISC_DISTRO_FILES.
Diffstat (limited to 'gnu/packages/javac.in')
-rw-r--r-- | gnu/packages/javac.in | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/gnu/packages/javac.in b/gnu/packages/javac.in new file mode 100644 index 0000000000..adb4dc1f6c --- /dev/null +++ b/gnu/packages/javac.in @@ -0,0 +1,61 @@ +#!/usr/bin/perl -w + +# Taken from Gentoo: +# http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-java/gcj-jdk/files/javac.in + +use strict; +use constant NO_DUP_ARGS => qw(-source -target -d -encoding); +use constant STRIP_ARGS => qw(-Werror -implicit:none -J-Xbootclasspath/p:); + +my $ECJ_WARNINGS="-nowarn"; + +my ( @bcoption, @source15, @target15, @cp ); +push @bcoption, '-bootclasspath', '@RT_JAR@:@TOOLS_JAR@' + unless grep {$_ eq '-bootclasspath'} @ARGV; +push @source15, '-source', '1.5' + unless grep {$_ eq '-source'} @ARGV; +push @target15, '-target', '1.5' + unless grep {$_ eq '-target'} @ARGV; +push @cp, '-cp', '.' + unless grep {$_ =~ '\-c(p|lasspath)'} @ARGV or $ENV{CLASSPATH}; +my @ecj_parms = ($ECJ_WARNINGS, @bcoption, @source15, @target15, @cp); + +# 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) + { + my @indices = reverse grep {$new_args[$_] eq $opt} 0..$#new_args; + splice @new_args, $_, 1 for @indices; + } + + return \@new_args; +} + +sub split_vm_args +{ + my @new_args = @{$_[0]}; + + my @vm_args = map { substr $_, 2 } grep $_ =~ /^-J/, @new_args; + my @javac_args = grep $_ !~ /^-J/, @new_args; + + return (\@vm_args, \@javac_args); +} + +my ($vm_args, $javac_args) = split_vm_args (gen_ecj_opts( \@ARGV )); +my @CLASSPATH = ('@ECJ_JAR@'); +push @CLASSPATH, split /:/, $ENV{"CLASSPATH"} if exists $ENV{"CLASSPATH"}; +$ENV{"CLASSPATH"} = join ':', @CLASSPATH; +exec '@JAVA@', @$vm_args, 'org.eclipse.jdt.internal.compiler.batch.Main', @ecj_parms, @$javac_args; |