| #!/bin/bash |
| |
| # Exit on error. |
| set -e |
| |
| # $BUCK_BIN_DIRECTORY is the directory that hosts this script. Solution taken from: |
| # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in |
| SOURCE="${BASH_SOURCE[0]}" |
| DIR="$( dirname "$SOURCE" )" |
| while [ -h "$SOURCE" ] |
| do |
| SOURCE="$(readlink "$SOURCE")" |
| [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" |
| DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" |
| done |
| DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" |
| BUCK_BIN_DIRECTORY=$DIR |
| |
| # Set environment and update buck if required. |
| # TODO(user): refactor buck_common in to functions rather than sourcing |
| source "${BUCK_BIN_DIRECTORY}/buck_common" |
| |
| # If a buck daemon is running, use it. |
| BUCK_CLIENT="${BUCK_DIRECTORY}/build/ng" |
| if [ $BUCKD_RUNNING -eq 0 ] && [ -e "$BUCK_CLIENT" ]; then |
| BUCKD_PORT=`cat ${BUCKD_DIR}/buckd.port` |
| $BUCK_CLIENT --nailgun-port $BUCKD_PORT \ |
| com.facebook.buck.cli.Main "$@" |
| exit $? |
| fi |
| |
| # Run buck. |
| java \ |
| $BUCK_JAVA_ARGS \ |
| -Dbuck.daemon=false \ |
| -classpath \ |
| $BUCK_JAVA_CLASSPATH \ |
| com.facebook.buck.cli.Main "$@" |