summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/ant/templates/generic-unix.tmpl
blob: a96d4db4647d6b1263a9a0f091f007afdbaaa91e (plain) (blame)
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
#!/bin/bash

##############################################################################
# Scala runtime @version@
##############################################################################
# @copyright@
# This is free software; see the distribution for copying conditions.
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
##############################################################################

cygwin=false;
darwin=false;
case "`uname`" in
    CYGWIN*) cygwin=true ;;
    Darwin*) darwin=true ;;
esac

SOURCE=$0;
SCRIPT=`basename "$SOURCE"`;
while [ -h "$SOURCE" ]; do
    SCRIPT=`basename "$SOURCE"`;
    LOOKUP=`ls -ld "$SOURCE"`;
    TARGET=`expr "$LOOKUP" : '.*-> \(.*\)$'`;
    if expr "${TARGET:-.}/" : '/.*/$' > /dev/null; then
        SOURCE=${TARGET:-.};
    else
        SOURCE=`dirname "$SOURCE"`/${TARGET:-.};
    fi;
done;
SCALA_HOME=`dirname "$SOURCE"`/..;
SCALA_HOME=`cd "$SCALA_HOME"; pwd`;

## buraq: previous version of this script computed the MYCLASSPATH and
##        then appended it to the bootclasspath. Unfortunately, this
##        won't work for library code that uses reflection to obtain
##        a class living on the classpath. For this reason, we have
##        to merge everything in the -cp classpath. This requires
##        intercepting the user's -cp, if any, or the user's $CLASSPATH, 
##        if set, appending our libs to it and passing the whole thing by -cp

MYCLASSPATH=@classpath@
if [ "$MYCLASSPATH" == "" ] ; then
  for jar in `ls $SCALA_HOME/lib/*.jar` ; do
    MYCLASSPATH="$MYCLASSPATH:$jar"
  done
  MYCLASSPATH=${MYCLASSPATH:1}
fi

QQ_USERCLASSPATH="."
QQ_USERARGS=""
QQ_NEXT=0
for i in $@@
do
  if [ $QQ_NEXT -eq 1 ]
  then
    QQ_USERCLASSPATH=$i;
    QQ_NEXT=0
  else if [[ $i = "-cp" || $i = "-classpath" ]]
       then
        QQ_NEXT=1
       else
        QQ_USERARGS="$QQ_USERARGS $i"
        QQ_NEXT=0
       fi
  fi
done

#echo $ARGS
#for j in $ARGS
#do
#  echo $j
#done


if $cygwin; then
    if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
        format=mixed
    else
        format=windows
    fi
    CLASSPATH=`cygpath --path --$format "$CLASSPATH"`
fi

## Lex suggested the userclasspath come before our stuff, since it gets
## preferred.

if [ "$QQ_USERCLASSPATH" != "." ]
then
  MYCLASSPATH="$QQ_USERCLASSPATH:$MYCLASSPATH"
else if [ "$CLASSPATH" != "" ]
  then
  MYCLASSPATH="$CLASSPATH:$MYCLASSPATH"
  else
  MYCLASSPATH=".:$MYCLASSPATH"
  fi
fi

QQ_USERARGS="-cp $MYCLASSPATH $QQ_USERARGS"

for flag in "$@@" ; do
    if [ $flag == '-version' ] ; then
        echo "Scala runtime version @version@ -- @copyright@"
        ${JAVACMD:=java} -version
        exit 0
    fi
done

${JAVACMD:=java} @javaflags@ $QQ_USERARGS