summaryrefslogtreecommitdiff
path: root/buildscripts/phing/bin/phing
blob: bbc6eefe737b699d2dff9721fc4d525db97f9a63 (plain)
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
#!/bin/sh
# Shell wrapper for Phing
# $Id$
#
# This script will do the following:
# - check for PHP_COMMAND env, if found, use it.
#   - if not found assume php is on the path
# - check for PHING_HOME evn, if found use it
#   - if not look for it
# - check for PHP_CLASSPATH, if found use it
#   - if not found set it using PHING_HOME/classes


# Put all args in quotes
phing_exec_debug=false
phing_exec_args=
for arg in "$@" ; do
  phing_exec_args="$phing_exec_args \"$arg\""
done

if [ -z "$PHING_HOME" ] ; then

  # echo "WARNING: PHING_HOME environment not set. Attempting to guess."

  # try to find PHING
  if [ -d /opt/phing ] ; then 
    PHING_HOME=/opt/phing
  fi

  if [ -d "${HOME}/opt/phing" ] ; then 
    PHING_HOME="${HOME}/opt/phing"
  fi

  if [ -d "/usr/local/phing" ] ; then 
    PHING_HOME="/usr/local/phing"
  fi

  if [ -d "${HOME}/usr/phing" ] ; then 
    PHING_HOME="${HOME}/usr/phing"
  fi
  
  ## resolve links - $0 may be a link to phing's home
  PRG="$0"
  progname=`basename "$0"`
  saveddir=`pwd`

  # need this for relative symlinks
  dirname_prg=`dirname "$PRG"`
  cd "$dirname_prg"
  
  while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
	PRG="$link"
    else
	PRG=`dirname "$PRG"`"/$link"
    fi
  done
  
  PHING_HOME=`dirname "$PRG"`/..

  cd "$saveddir"

  # make it fully qualified
  PHING_HOME=`cd "$PHING_HOME" && pwd`
  
  # make it available in PHP via getenv("PHING_HOME")
  export PHING_HOME
fi

if (test -z "$PHP_COMMAND") ; then
	# echo "WARNING: PHP_COMMAND environment not set. (Assuming php on PATH)"
	PHP_COMMAND=php
	export PHP_COMMAND
fi

if (test -z "$PHP_CLASSPATH") ; then
	PHP_CLASSPATH=$PHING_HOME/classes
	export PHP_CLASSPATH
fi

phing_exec_cmd="exec $PHP_COMMAND -d html_errors=off -qC \"$PHING_HOME/bin/phing.php\" -logger phing.listener.AnsiColorLogger $phing_exec_args"
if $phing_exec_debug ; then
  echo $phing_exec_cmd
fi
eval $phing_exec_cmd