Added the ability to build without tests

Signed-off-by: Jitendra Vaidya <jitendra.vaidya@gmail.com>
This commit is contained in:
Jitendra Vaidya 2018-12-23 06:13:33 +00:00
Родитель 23f135ea6e
Коммит 157ebf5830
3 изменённых файлов: 114 добавлений и 66 удалений

Просмотреть файл

@ -23,6 +23,7 @@
# 3. Detection of installed MySQL and setting MYSQL_FLAVOR.
# 4. Installation of development related steps e.g. creating Git hooks.
BUILD_TESTS=${BUILD_TESTS:-1}
#
# 0. Initialization and helper methods.
@ -47,7 +48,11 @@ function fail() {
go version &>/dev/null || fail "Go is not installed or is not on \$PATH"
# Set up the proper GOPATH for go get below.
source ./dev.env
if [ "$BUILD_TESTS" == 1 ] ; then
source ./dev.env
else
source ./build.env
fi
# Create main directories.
mkdir -p "$VTROOT/dist"
@ -55,15 +60,21 @@ mkdir -p "$VTROOT/bin"
mkdir -p "$VTROOT/lib"
mkdir -p "$VTROOT/vthook"
# Set up required soft links.
# TODO(mberlin): Which of these can be deleted?
ln -snf "$VTTOP/config" "$VTROOT/config"
ln -snf "$VTTOP/data" "$VTROOT/data"
ln -snf "$VTTOP/py" "$VTROOT/py-vtdb"
ln -snf "$VTTOP/go/vt/zkctl/zksrv.sh" "$VTROOT/bin/zksrv.sh"
ln -snf "$VTTOP/test/vthook-test.sh" "$VTROOT/vthook/test.sh"
ln -snf "$VTTOP/test/vthook-test_backup_error" "$VTROOT/vthook/test_backup_error"
ln -snf "$VTTOP/test/vthook-test_backup_transform" "$VTROOT/vthook/test_backup_transform"
if [ "$BUILD_TESTS" == 1 ] ; then
# Set up required soft links.
# TODO(mberlin): Which of these can be deleted?
ln -snf "$VTTOP/config" "$VTROOT/config"
ln -snf "$VTTOP/data" "$VTROOT/data"
ln -snf "$VTTOP/py" "$VTROOT/py-vtdb"
ln -snf "$VTTOP/go/vt/zkctl/zksrv.sh" "$VTROOT/bin/zksrv.sh"
ln -snf "$VTTOP/test/vthook-test.sh" "$VTROOT/vthook/test.sh"
ln -snf "$VTTOP/test/vthook-test_backup_error" "$VTROOT/vthook/test_backup_error"
ln -snf "$VTTOP/test/vthook-test_backup_transform" "$VTROOT/vthook/test_backup_transform"
else
ln -snf "$VTTOP/config" "$VTROOT/config"
ln -snf "$VTTOP/data" "$VTROOT/data"
ln -snf "$VTTOP/go/vt/zkctl/zksrv.sh" "$VTROOT/bin/zksrv.sh"
fi
# install_dep is a helper function to generalize the download and installation of dependencies.
#
@ -136,8 +147,10 @@ function install_grpc() {
grpcio_ver=$version
$PIP install --upgrade grpcio=="$grpcio_ver" grpcio-tools=="$grpcio_ver"
}
install_dep "gRPC" "1.16.0" "$VTROOT/dist/grpc" install_grpc
if [ "$BUILD_TESTS" == 1 ] ; then
install_dep "gRPC" "1.16.0" "$VTROOT/dist/grpc" install_grpc
fi
# Install protoc.
function install_protoc() {
@ -225,8 +238,9 @@ function install_pymock() {
popd >/dev/null
}
pymock_version=1.0.1
install_dep "py-mock" "$pymock_version" "$VTROOT/dist/py-mock-$pymock_version" install_pymock
if [ "$BUILD_TESTS" == 1 ] ; then
install_dep "py-mock" "$pymock_version" "$VTROOT/dist/py-mock-$pymock_version" install_pymock
fi
# Download Selenium (necessary to run test/vtctld_web_test.py).
function install_selenium() {
@ -239,7 +253,9 @@ function install_selenium() {
# instead of go/dist/selenium/lib/python3.5/site-packages and then can't find module 'pip._vendor.requests'
PYTHONPATH='' $PIP install selenium
}
install_dep "Selenium" "latest" "$VTROOT/dist/selenium" install_selenium
if [ "$BUILD_TESTS" == 1 ] ; then
install_dep "Selenium" "latest" "$VTROOT/dist/selenium" install_selenium
fi
# Download chromedriver (necessary to run test/vtctld_web_test.py).
@ -251,7 +267,9 @@ function install_chromedriver() {
unzip -o -q chromedriver_linux64.zip -d "$dist"
rm chromedriver_linux64.zip
}
install_dep "chromedriver" "2.44" "$VTROOT/dist/chromedriver" install_chromedriver
if [ "$BUILD_TESTS" == 1 ] ; then
install_dep "chromedriver" "2.44" "$VTROOT/dist/chromedriver" install_chromedriver
fi
#
@ -300,47 +318,52 @@ govendor sync || fail "Failed to download/update dependencies with govendor. Ple
# find mysql and prepare to use libmysqlclient
if [ -z "$MYSQL_FLAVOR" ]; then
export MYSQL_FLAVOR=MySQL56
echo "MYSQL_FLAVOR environment variable not set. Using default: $MYSQL_FLAVOR"
if [ "$BUILD_TESTS" == 1 ] ; then
if [ -z "$MYSQL_FLAVOR" ]; then
export MYSQL_FLAVOR=MySQL56
echo "MYSQL_FLAVOR environment variable not set. Using default: $MYSQL_FLAVOR"
fi
case "$MYSQL_FLAVOR" in
"MySQL56")
myversion="$("$VT_MYSQL_ROOT/bin/mysql" --version)"
[[ "$myversion" =~ Distrib\ 5\.[67] || "$myversion" =~ Ver\ 8\. ]] || fail "Couldn't find MySQL 5.6+ in $VT_MYSQL_ROOT. Set VT_MYSQL_ROOT to override search location."
echo "Found MySQL 5.6+ installation in $VT_MYSQL_ROOT."
;;
"MariaDB")
myversion="$("$VT_MYSQL_ROOT/bin/mysql" --version)"
[[ "$myversion" =~ MariaDB ]] || fail "Couldn't find MariaDB in $VT_MYSQL_ROOT. Set VT_MYSQL_ROOT to override search location."
echo "Found MariaDB installation in $VT_MYSQL_ROOT."
;;
*)
fail "Unsupported MYSQL_FLAVOR $MYSQL_FLAVOR"
;;
esac
# save the flavor that was used in bootstrap, so it can be restored
# every time dev.env is sourced.
echo "$MYSQL_FLAVOR" > "$VTROOT/dist/MYSQL_FLAVOR"
fi
case "$MYSQL_FLAVOR" in
"MySQL56")
myversion="$("$VT_MYSQL_ROOT/bin/mysql" --version)"
[[ "$myversion" =~ Distrib\ 5\.[67] || "$myversion" =~ Ver\ 8\. ]] || fail "Couldn't find MySQL 5.6+ in $VT_MYSQL_ROOT. Set VT_MYSQL_ROOT to override search location."
echo "Found MySQL 5.6+ installation in $VT_MYSQL_ROOT."
;;
"MariaDB")
myversion="$("$VT_MYSQL_ROOT/bin/mysql" --version)"
[[ "$myversion" =~ MariaDB ]] || fail "Couldn't find MariaDB in $VT_MYSQL_ROOT. Set VT_MYSQL_ROOT to override search location."
echo "Found MariaDB installation in $VT_MYSQL_ROOT."
;;
*)
fail "Unsupported MYSQL_FLAVOR $MYSQL_FLAVOR"
;;
esac
# save the flavor that was used in bootstrap, so it can be restored
# every time dev.env is sourced.
echo "$MYSQL_FLAVOR" > "$VTROOT/dist/MYSQL_FLAVOR"
#
# 4. Installation of development related steps e.g. creating Git hooks.
#
# Create the Git hooks.
echo "creating git hooks"
mkdir -p "$VTTOP/.git/hooks"
ln -sf "$VTTOP/misc/git/pre-commit" "$VTTOP/.git/hooks/pre-commit"
ln -sf "$VTTOP/misc/git/prepare-commit-msg.bugnumber" "$VTTOP/.git/hooks/prepare-commit-msg"
ln -sf "$VTTOP/misc/git/commit-msg" "$VTTOP/.git/hooks/commit-msg"
(cd "$VTTOP" && git config core.hooksPath "$VTTOP/.git/hooks")
if [ "$BUILD_TESTS" == 1 ] ; then
# Create the Git hooks.
echo "creating git hooks"
mkdir -p "$VTTOP/.git/hooks"
ln -sf "$VTTOP/misc/git/pre-commit" "$VTTOP/.git/hooks/pre-commit"
ln -sf "$VTTOP/misc/git/prepare-commit-msg.bugnumber" "$VTTOP/.git/hooks/prepare-commit-msg"
ln -sf "$VTTOP/misc/git/commit-msg" "$VTTOP/.git/hooks/commit-msg"
(cd "$VTTOP" && git config core.hooksPath "$VTTOP/.git/hooks")
echo
echo "bootstrap finished - run 'source dev.env' in your shell before building."
else
echo
echo "bootstrap finished - run 'source build.env' in your shell before building."
fi
echo
echo "bootstrap finished - run 'source dev.env' in your shell before building."

39
build.env Normal file
Просмотреть файл

@ -0,0 +1,39 @@
# No shebang line as this script is sourced from an external shell.
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Plese ensure dev.env is written in a way which is POSIX (bourne)
# shell compatible.
# - Some build systems like rpm require the different scriptlets used
# to build a package to be run under a POSIX shell so non-POSIX
# syntax will break that as dev.env will not be sourced by bash..
# Import prepend_path function.
dir="$(dirname "${BASH_SOURCE[0]}")"
# shellcheck source=tools/shell_functions.inc
if ! source "${dir}/tools/shell_functions.inc"; then
echo "failed to load tools/shell_functions.inc"
return 1
fi
VTTOP=$(pwd)
export VTTOP
VTROOT="${VTROOT:-${VTTOP/\/src\/vitess.io\/vitess/}}"
export VTROOT
# VTTOP sanity check
if [[ "$VTTOP" == "${VTTOP/\/src\/vitess.io\/vitess/}" ]]; then
echo "WARNING: VTTOP($VTTOP) does not contain src/vitess.io/vitess"
fi

16
dev.env
Просмотреть файл

@ -20,22 +20,8 @@
# to build a package to be run under a POSIX shell so non-POSIX
# syntax will break that as dev.env will not be sourced by bash..
# Import prepend_path function.
dir="$(dirname "${BASH_SOURCE[0]}")"
# shellcheck source=tools/shell_functions.inc
if ! source "${dir}/tools/shell_functions.inc"; then
echo "failed to load tools/shell_functions.inc"
return 1
fi
source build.env
VTTOP=$(pwd)
export VTTOP
VTROOT="${VTROOT:-${VTTOP/\/src\/vitess.io\/vitess/}}"
export VTROOT
# VTTOP sanity check
if [[ "$VTTOP" == "${VTTOP/\/src\/vitess.io\/vitess/}" ]]; then
echo "WARNING: VTTOP($VTTOP) does not contain src/vitess.io/vitess"
fi
export GOTOP=$VTTOP/go
export PYTOP=$VTTOP/py