зеркало из https://github.com/github/vitess-gh.git
77 строки
2.1 KiB
Bash
77 строки
2.1 KiB
Bash
# Copyright 2012, Google Inc. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can
|
|
# be found in the LICENSE file.
|
|
|
|
export VTTOP=$(pwd)
|
|
export VTROOT="${VTROOT:-${VTTOP/\/src\/code.google.com\/p\/vitess/}}"
|
|
# VTTOP sanity check
|
|
if [[ "$VTTOP" == "${VTTOP/\/src\/code.google.com\/p\/vitess/}" ]]; then
|
|
echo "WARNING: VTTOP($VTTOP) does not contain src/code.google.com/p/vitess"
|
|
fi
|
|
export GOTOP=$VTTOP/go
|
|
export PYTOP=$VTTOP/py
|
|
|
|
function prepend_path()
|
|
{
|
|
# $1 path variable
|
|
# $2 path to add
|
|
if [ -d "$2" ] && [[ ":$1:" != *":$2:"* ]]; then
|
|
echo "$2:$1"
|
|
else
|
|
echo "$1"
|
|
fi
|
|
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
|
|
export PATH="$1:$PATH"
|
|
fi
|
|
}
|
|
|
|
for pypath in $(find $VTROOT/dist -name site-packages)
|
|
do
|
|
export PYTHONPATH=$(prepend_path $PYTHONPATH $pypath)
|
|
done
|
|
|
|
export PYTHONPATH=$(prepend_path $PYTHONPATH $VTROOT/py-vtdb)
|
|
|
|
export PATH=$(prepend_path $PATH $VTROOT/bin)
|
|
if [ "$GOBIN" ]; then
|
|
export PATH=$(prepend_path $PATH $GOBIN)
|
|
fi
|
|
|
|
# GOROOT sanity
|
|
go_bin=`which go`
|
|
go_env=`go env | grep GOROOT | cut -f 2 -d\"`
|
|
if [ "$go_bin" -a "$go_bin" != "$go_env/bin/go" ]; then
|
|
echo "WARNING: \$GOROOT may not compatible with the used go binary"
|
|
echo "Please make sure 'go' comes from \$GOROOT/bin"
|
|
echo "go_env: $go_env"
|
|
echo "go_bin: $go_bin"
|
|
fi
|
|
|
|
# mysql install location. Please set based on your environment.
|
|
# Build will not work if this is incorrect.
|
|
|
|
if [ "$VT_MYSQL_ROOT" == "" ]; then
|
|
if [ "$(which mysql_config)" == "" ]; then
|
|
echo "WARNING: VT_MYSQL_ROOT unset because mysql_config not found"
|
|
else
|
|
export VT_MYSQL_ROOT=$(dirname $(dirname $(which mysql_config)))
|
|
fi
|
|
fi
|
|
|
|
export LD_LIBRARY_PATH=$(prepend_path $LD_LIBRARY_PATH $VT_MYSQL_ROOT/lib/mysql)
|
|
export PKG_CONFIG_PATH=$(prepend_path $PKG_CONFIG_PATH $VTROOT/lib)
|
|
export GOPATH=$(prepend_path $GOPATH $VTROOT)
|
|
|
|
# Useful aliases. Remove if inconvenient.
|
|
alias gt="cd $GOTOP"
|
|
alias pt="cd $PYTOP"
|
|
alias vt="cd $VTTOP"
|
|
|
|
function vtretag() {
|
|
go-etags -o $VTROOT/src/TAGS $(find $VTROOT/src -iname '*.go' -a \! -name '*test.go' -type f | sort)
|
|
}
|
|
|
|
if [ "$(which go-etags)" ]; then
|
|
vtretag
|
|
fi
|