carbidecpp20devenv/plugins/org.apache.ant_1.7.0.v200803061910/bin/runant.py
changeset 1 82d1d1de1a01
equal deleted inserted replaced
-1:000000000000 1:82d1d1de1a01
       
     1 #!/usr/bin/python
       
     2 # Copyright 2001,2003-2004 The Apache Software Foundation
       
     3 #
       
     4 #  Licensed under the Apache License, Version 2.0 (the "License");
       
     5 #  you may not use this file except in compliance with the License.
       
     6 #  You may obtain a copy of the License at
       
     7 #
       
     8 #      http://www.apache.org/licenses/LICENSE-2.0
       
     9 #
       
    10 #  Unless required by applicable law or agreed to in writing, software
       
    11 #  distributed under the License is distributed on an "AS IS" BASIS,
       
    12 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    13 #  See the License for the specific language governing permissions and
       
    14 #  limitations under the License.
       
    15 #
       
    16 
       
    17 """
       
    18 
       
    19  runant.py
       
    20 
       
    21     This script is a translation of the runant.pl written by Steve Loughran.
       
    22     It runs ant with/out arguments, it should be quite portable (thanks to
       
    23     the python os library)
       
    24     This script has been tested with Python2.0/Win2K
       
    25 
       
    26  created:         2001-04-11
       
    27  author:          Pierre Dittgen pierre.dittgen@criltelecom.com
       
    28 
       
    29  Assumptions:
       
    30 
       
    31  - the "java" executable/script is on the command path
       
    32 """
       
    33 import os, os.path, string, sys
       
    34 
       
    35 # Change it to 1 to get extra debug information
       
    36 debug = 0
       
    37 
       
    38 #######################################################################
       
    39 
       
    40 # If ANT_HOME is not set default to script's parent directory
       
    41 if os.environ.has_key('ANT_HOME'):
       
    42     ANT_HOME = os.environ['ANT_HOME']
       
    43 else:
       
    44     ANT_HOME = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
       
    45 
       
    46 # set ANT_LIB location
       
    47 ANT_LIB = os.path.join(ANT_HOME, 'lib')
       
    48 
       
    49 # set JAVACMD (check variables JAVACMD and JAVA_HOME)
       
    50 JAVACMD = None
       
    51 if not os.environ.has_key('JAVACMD'):
       
    52     if os.environ.has_key('JAVA_HOME'):
       
    53         if not os.path.exists(os.environ['JAVA_HOME']):
       
    54             print "Warning: JAVA_HOME is not defined correctly."
       
    55         else:
       
    56             JAVACMD = os.path.join(os.environ['JAVA_HOME'], 'bin', 'java')
       
    57     else:
       
    58         print "Warning: JAVA_HOME not set."
       
    59 else:
       
    60     JAVACMD = os.environ['JAVACMD']
       
    61 if not JAVACMD:
       
    62     JAVACMD = 'java'
       
    63 
       
    64 launcher_jar = os.path.join(ANT_LIB, 'ant-launcher.jar')
       
    65 if not os.path.exists(launcher_jar):
       
    66     print 'Unable to locate ant-launcher.jar. Expected to find it in %s' % \
       
    67         ANT_LIB
       
    68 
       
    69 # Build up standard classpath (LOCALCLASSPATH)
       
    70 LOCALCLASSPATH = launcher_jar
       
    71 if os.environ.has_key('LOCALCLASSPATH'):
       
    72     LOCALCLASSPATH += os.pathsep + os.environ['LOCALCLASSPATH']
       
    73 
       
    74 ANT_OPTS = ""
       
    75 if os.environ.has_key('ANT_OPTS'):
       
    76     ANT_OPTS = os.environ['ANT_OPTS']
       
    77 
       
    78 OPTS = ""
       
    79 if os.environ.has_key('JIKESPATH'):
       
    80     OPTS = '-Djikes.class.path=\"%s\"' % os.environ['JIKESPATH']
       
    81 
       
    82 ANT_ARGS = ""
       
    83 if os.environ.has_key('ANT_ARGS'):
       
    84     ANT_ARGS = os.environ['ANT_ARGS']
       
    85 
       
    86 CLASSPATH = ""
       
    87 if os.environ.has_key('CLASSPATH'):
       
    88     CLASSPATH = os.environ['CLASSPATH']
       
    89 
       
    90 # Builds the commandline
       
    91 cmdline = ('%s %s -classpath %s -Dant.home=%s %s ' + \
       
    92     'org.apache.tools.ant.launch.Launcher %s -lib %s %s') \
       
    93      % (JAVACMD, ANT_OPTS, LOCALCLASSPATH, ANT_HOME, OPTS, ANT_ARGS, \
       
    94         CLASSPATH, string.join(sys.argv[1:], ' '))
       
    95 
       
    96 if debug:
       
    97     print '\n%s\n\n' % (cmdline)
       
    98 
       
    99 # Run the biniou!
       
   100 os.system(cmdline)