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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
#!/usr/bin/env perl
# WARNING: DO NOT EDIT THE mpijava.pl FILE AS IT IS GENERATED!
# MAKE ALL CHANGES IN mpijava.pl.in
# Copyright (c) 2011-2013 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
use strict;
# The main purpose of this wrapper compiler is to check for
# and adjust the Java class path to include the OMPI classes
# in mpi.jar. The user may have specified a class path on
# our cmd line, or it may be in the environment, so we have
# to check for both. We also need to be careful not to
# just override the class path as it probably includes classes
# they need for their application! It also may already include
# the path to mpi.jar, and while it doesn't hurt anything, we
# don't want to include our class path more than once to avoid
# user astonishment
# Let the build system provide us with some critical values
my $my_compiler = "@JAVAC@";
my $mpi_jar = "@OMPI_WRAPPER_LIBDIR@/mpi.jar";
my $shmem_jar = "@OMPI_WRAPPER_LIBDIR@/shmem.jar";
# globals
my $showme_arg = 0;
my $verbose = 0;
my $my_arg;
# Cannot use the usual GetOpts library as the user might
# be passing -options to the Java compiler! So have to
# parse the options ourselves to look for help and showme
my @save_args;
foreach $my_arg (@ARGV) {
if ($my_arg eq "-h" ||
$my_arg eq "--h" ||
$my_arg eq "-help" ||
$my_arg eq "--help") {
print "Options:
--showme Show the wrapper compiler command without executing it
--verbose Show the wrapper compiler command *and* execute it
--help | -h This help list\n";
exit(0);
} elsif ($my_arg eq "--showme") {
$showme_arg = 1;
} elsif ($my_arg eq "--verbose") {
$verbose = 1;
} else {
push(@save_args, $my_arg);
}
}
# Create a place to save our argv array so we can edit any
# provide class path option
my @arguments = ();
# Check the command line for a class path
my $cp_found = 0;
my $my_cp;
foreach $my_arg (@save_args) {
if (1 == $cp_found) {
$my_cp = $my_arg;
if (0 > index($my_arg, "mpi.jar")) {
# not found, so we add our path
if (rindex($my_arg, ":") == length($my_arg)-1) {
# already have a colon at the end
$my_cp = $my_cp . $mpi_jar;
} else {
# need to add the colon between paths
$my_cp = $my_cp . ":" . $mpi_jar;
}
}
if (0 > index($my_arg, "shmem.jar")) {
# not found, so we add our path
if (rindex($my_arg, ":") == length($my_arg)-1) {
# already have a colon at the end
$my_cp = $my_cp . $shmem_jar;
} else {
# need to add the colon between paths
$my_cp = $my_cp . ":" . $shmem_jar;
}
}
push(@arguments, $my_cp);
$cp_found = 2;
} else {
if (0 == $cp_found && (
0 <= index($my_arg, "-cp") ||
0 <= index($my_arg, "-classpath")))
{
$cp_found = 1;
}
push(@arguments, $my_arg);
}
}
# If the class path wasn't found on the cmd line, then
# we next check the class path in the environment, if it exists
if (2 != $cp_found && exists $ENV{'CLASSPATH'} && length($ENV{'CLASSPATH'}) > 0) {
$my_cp = $ENV{'CLASSPATH'};
if(0 > index($my_cp, "mpi.jar")) {
# not found, so we add our path
if (rindex($my_cp, ":") == length($my_cp)-1) {
# already have a colon at the end
$my_cp = $my_cp . $mpi_jar;
} else {
# need to add the colon between paths
$my_cp = $my_cp . ":" . $mpi_jar;
}
}
if (0 > index($my_cp, "shmem.jar")) {
# not found, so we add our path
if (rindex($my_cp, ":") == length($my_cp)-1) {
# already have a colon at the end
$my_cp = $my_cp . $shmem_jar;
} else {
# need to add the colon between paths
$my_cp = $my_cp . ":" . $shmem_jar;
}
}
unshift(@arguments, $my_cp);
unshift(@arguments, "-cp");
# ensure we mark that we "found" the class path
$cp_found = 1;
}
# If the class path wasn't found in either location, then
# we have to insert it as the first argument
if (0 == $cp_found) {
unshift(@arguments, $mpi_jar . ":" . $shmem_jar);
unshift(@arguments, "-cp");
}
# Construct the command
my $returnCode = 0;
if ($showme_arg) {
print "$my_compiler @arguments\n";
} else {
if ($verbose) {
print "$my_compiler @arguments\n";
}
$returnCode = system $my_compiler, @arguments;
}
exit $returnCode;
|