carbidecpp20devenv/plugins/org.apache.ant_1.7.0.v200803061910/bin/runant.pl
changeset 1 82d1d1de1a01
equal deleted inserted replaced
-1:000000000000 1:82d1d1de1a01
       
     1 #!/usr/bin/perl
       
     2 #
       
     3 # Copyright 2000-2004 The Apache Software Foundation
       
     4 #
       
     5 #  Licensed under the Apache License, Version 2.0 (the "License");
       
     6 #  you may not use this file except in compliance with the License.
       
     7 #  You may obtain a copy of the License at
       
     8 #
       
     9 #      http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    11 #  Unless required by applicable law or agreed to in writing, software
       
    12 #  distributed under the License is distributed on an "AS IS" BASIS,
       
    13 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    14 #  See the License for the specific language governing permissions and
       
    15 #  limitations under the License.
       
    16 #
       
    17 #######################################################################
       
    18 #
       
    19 # runant.pl
       
    20 #
       
    21 # wrapper script for invoking ant in a platform with Perl installed
       
    22 # this may include cgi-bin invocation, which is considered somewhat daft.
       
    23 # (slo: that should be a separate file which can be derived from this
       
    24 # and returns the XML formatted output)
       
    25 #
       
    26 # the code is not totally portable due to classpath and directory splitting
       
    27 # issues. oops. (NB, use File::Spec::Functions  will help and the code is
       
    28 # structured for the catfile() call, but because of perl version funnies
       
    29 # the code is not included. 
       
    30 #
       
    31 # created:         2000-8-24
       
    32 # author:          Steve Loughran steve_l@sourceforge.net
       
    33 #######################################################################
       
    34 #
       
    35 # Assumptions:
       
    36 #
       
    37 # - the "java" executable/script is on the command path
       
    38 # - ANT_HOME has been set
       
    39 # - target platform uses ":" as classpath separator or perl indicates it is dos/win32
       
    40 # - target platform uses "/" as directory separator.
       
    41 
       
    42 #be fussy about variables
       
    43 use strict;
       
    44 
       
    45 #platform specifics (disabled)
       
    46 #use File::Spec::Functions;
       
    47 
       
    48 #turn warnings on during dev; generates a few spurious uninitialised var access warnings
       
    49 #use warnings;
       
    50 
       
    51 #and set $debug to 1 to turn on trace info
       
    52 my $debug=1;
       
    53 
       
    54 #######################################################################
       
    55 #
       
    56 # check to make sure environment is setup
       
    57 #
       
    58 
       
    59 my $HOME = $ENV{ANT_HOME};
       
    60 if ($HOME eq "")
       
    61         {
       
    62     die "\n\nANT_HOME *MUST* be set!\n\n";
       
    63         }
       
    64 
       
    65 my $JAVACMD = $ENV{JAVACMD};
       
    66 $JAVACMD = "java" if $JAVACMD eq "";
       
    67 
       
    68 my $onnetware = 0;
       
    69 if ($^O eq "NetWare")
       
    70 {
       
    71   $onnetware = 1;
       
    72 }
       
    73 
       
    74 my $oncygwin = ($^O eq "cygwin");
       
    75 
       
    76 #ISSUE: what java wants to split up classpath varies from platform to platform 
       
    77 #and perl is not too hot at hinting which box it is on.
       
    78 #here I assume ":" 'cept on win32, dos, and netware. Add extra tests here as needed.
       
    79 my $s=":";
       
    80 if(($^O eq "MSWin32") || ($^O eq "dos") || ($^O eq "cygwin") ||
       
    81    ($onnetware == 1))
       
    82         {
       
    83         $s=";";
       
    84         }
       
    85 
       
    86 #build up standard classpath
       
    87 my $localpath = "$HOME/lib/ant-launcher.jar";
       
    88 #set JVM options and Ant arguments, if any
       
    89 my @ANT_OPTS=split(" ", $ENV{ANT_OPTS});
       
    90 my @ANT_ARGS=split(" ", $ENV{ANT_ARGS});
       
    91 
       
    92 #jikes
       
    93 if($ENV{JIKESPATH} ne "")
       
    94         {
       
    95         push @ANT_OPTS, "-Djikes.class.path=$ENV{JIKESPATH}";
       
    96         }
       
    97 
       
    98 #construct arguments to java
       
    99 my @ARGS;
       
   100 push @ARGS, @ANT_OPTS;
       
   101 
       
   102 my $CYGHOME = "";
       
   103 
       
   104 my $classpath=$ENV{CLASSPATH};
       
   105 if ($oncygwin == 1) {
       
   106   $localpath = `cygpath --path --windows $localpath`;
       
   107   chomp ($localpath);
       
   108   if (! $classpath eq "")
       
   109   {
       
   110     $classpath = `cygpath --path --windows "$classpath"`;
       
   111     chomp ($classpath);
       
   112   }
       
   113   $HOME = `cygpath --path --windows $HOME`;
       
   114   chomp ($HOME);
       
   115   $CYGHOME = `cygpath --path --windows $ENV{HOME}`;
       
   116   chomp ($CYGHOME);
       
   117 }
       
   118 push @ARGS, "-classpath", "$localpath";
       
   119 push @ARGS, "-Dant.home=$HOME";
       
   120 if ( ! $CYGHOME eq "" )
       
   121 {
       
   122   push @ARGS, "-Dcygwin.user.home=\"$CYGHOME\""
       
   123 }
       
   124 push @ARGS, "org.apache.tools.ant.launch.Launcher", @ANT_ARGS;
       
   125 push @ARGS, @ARGV;
       
   126 if (! $classpath eq "")
       
   127 {
       
   128   if ($onnetware == 1)
       
   129   {
       
   130     # make classpath literally $CLASSPATH
       
   131     # this is to avoid pushing us over the 512 character limit
       
   132     # even skip the ; - that is already in $localpath
       
   133     push @ARGS, "-lib", "\$CLASSPATH";
       
   134   }
       
   135   else
       
   136   {
       
   137     push @ARGS, "-lib", "$classpath";
       
   138   }
       
   139 }
       
   140 print "\n $JAVACMD @ARGS\n\n" if ($debug);
       
   141 
       
   142 my $returnValue = system $JAVACMD, @ARGS;
       
   143 if ($returnValue eq 0)
       
   144         {
       
   145         exit 0;
       
   146         }
       
   147 else
       
   148         {
       
   149         # only 0 and 1 are widely recognized as exit values
       
   150         # so change the exit value to 1
       
   151         exit 1;
       
   152         }