Skip to content

Commit

Permalink
allow for multiple "build" dirs to exist
Browse files Browse the repository at this point in the history
Signed-off-by: Yuval Lifshitz <yuvalif@yahoo.com>
  • Loading branch information
yuvalif committed Sep 6, 2019
1 parent c9863fb commit b8b43fe
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 43 deletions.
12 changes: 8 additions & 4 deletions do_cmake.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env bash
set -x

git submodule update --init --recursive
if test -e build; then
echo 'build dir already exists; rm -rf build and re-run'

[ -z "$BUILD_DIR" ] && BUILD_DIR=build

if [ -e $BUILD_DIR ]; then
echo "'$BUILD_DIR' dir already exists; either rm -rf '$BUILD_DIR' and re-run, or set BUILD_DIR env var to a different directory name"
exit 1
fi

Expand Down Expand Up @@ -46,8 +50,8 @@ if [ -n "$WITH_RADOSGW_AMQP_ENDPOINT" ] ; then
ARGS="$ARGS -DWITH_RADOSGW_AMQP_ENDPOINT=$WITH_RADOSGW_AMQP_ENDPOINT"
fi

mkdir build
cd build
mkdir $BUILD_DIR
cd $BUILD_DIR
if type cmake3 > /dev/null 2>&1 ; then
CMAKE=cmake3
else
Expand Down
16 changes: 9 additions & 7 deletions do_freebsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ CMAKE_C_FLAGS_DEBUG="$C_FLAGS_DEBUG $COMPILE_FLAGS"
# dashboard, because versions fetched are not working on FreeBSD.


[ -z "$BUILD_DIR" ] && BUILD_DIR=build

echo Keeping the old build
if [ -d build.old ]; then
sudo mv build.old build.del
sudo rm -rf build.del &
if [ -d ${BUILD_DIR}.old ]; then
sudo mv ${BUILD_DIR}.old ${BUILD_DIR}.del
sudo rm -rf ${BUILD_DIR}.del &
fi
if [ -d build ]; then
sudo mv build build.old
if [ -d ${BUILD_DIR} ]; then
sudo mv ${BUILD_DIR} ${BUILD_DIR}.old
fi

mkdir build
mkdir ${BUILD_DIR}
./do_cmake.sh "$*" \
-D WITH_CCACHE=ON \
-D CMAKE_BUILD_TYPE=Debug \
Expand Down Expand Up @@ -61,7 +63,7 @@ mkdir build
echo -n "start building: "; date
printenv

cd build
cd ${BUILD_DIR}
gmake -j$CPUS V=1 VERBOSE=1
gmake tests
echo -n "start testing: "; date ;
Expand Down
3 changes: 2 additions & 1 deletion examples/rbd-replay/trace
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ lttng create -o traces librbd
lttng enable-event -u 'librbd:*'
lttng add-context -u -t pthread_id
lttng start
LD_LIBRARY_PATH=../../build/lib qemu-system-i386 -m 1024 rbd:rbd/my-image:conf=../../src/ceph.conf
[ -z "$BUILD_DIR" ] && BUILD_DIR=build
LD_LIBRARY_PATH=../../${BUILD_DIR}/lib qemu-system-i386 -m 1024 rbd:rbd/my-image:conf=../../src/ceph.conf
lttng stop
lttng view > trace.log
4 changes: 3 additions & 1 deletion qa/workunits/rados/test_envlibrados_for_rocksdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ if type cmake3 > /dev/null 2>&1 ; then
else
CMAKE=cmake
fi
mkdir build && cd build && ${CMAKE} -DWITH_LIBRADOS=ON -DWITH_SNAPPY=ON -DWITH_GFLAGS=OFF -DFAIL_ON_WARNINGS=OFF ..

[ -z "$BUILD_DIR" ] && BUILD_DIR=build
mkdir ${BUILD_DIR} && cd ${BUILD_DIR} && ${CMAKE} -DWITH_LIBRADOS=ON -DWITH_SNAPPY=ON -DWITH_GFLAGS=OFF -DFAIL_ON_WARNINGS=OFF ..
make rocksdb_env_librados_test -j8

echo "Copy ceph.conf"
Expand Down
6 changes: 4 additions & 2 deletions qa/workunits/rgw/run-s3tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ port=$2

##

[ -z "$BUILD_DIR" ] && BUILD_DIR=build

if [ -e CMakeCache.txt ]; then
BIN_PATH=$PWD/bin
elif [ -e $root_path/../build/CMakeCache.txt ]; then
cd $root_path/../build
elif [ -e $root_path/../${BUILD_DIR}/CMakeCache.txt ]; then
cd $root_path/../${BUILD_DIR}
BIN_PATH=$PWD/bin
fi
PATH=$PATH:$BIN_PATH
Expand Down
4 changes: 3 additions & 1 deletion src/init-ceph.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ if [ -e /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
fi

[ -z "$BUILD_DIR" ] && BUILD_DIR=build

if [ `dirname $0` = "." ] && [ $PWD != "/etc/init.d" ]; then
# looks like an autotools src dir build
BINDIR=.
Expand All @@ -33,7 +35,7 @@ else
LIBEXECDIR=$CEPH_ROOT/src
ETCDIR=.
ASSUME_DEV=1
CEPH_LIB=$CEPH_ROOT/build/lib
CEPH_LIB=$CEPH_ROOT/${BUILD_DIR}/lib
echo "$PYTHONPATH" | grep -q $CEPH_LIB || export PYTHONPATH=$CEPH_LIB/cython_modules/lib.@MGR_PYTHON_VERSION_MAJOR@:$PYTHONPATH
echo "$LD_LIBRARY_PATH" | grep -q $CEPH_LIB || export LD_LIBRARY_PATH=$CEPH_LIB:$LD_LIBRARY_PATH
echo "$DYLD_LIBRARY_PATH" | grep -q $CEPH_LIB || export DYLD_LIBRARY_PATH=$CEPH_LIB:$DYLD_LIBRARY_PATH
Expand Down
5 changes: 3 additions & 2 deletions src/mrgw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ set -e
rgw_frontend=${RGW_FRONTEND:-"beast"}
script_root=`dirname $0`
script_root=`(cd $script_root;pwd)`
[ -z "$BUILD_DIR" ] && BUILD_DIR=build
if [ -e CMakeCache.txt ]; then
script_root=$PWD
elif [ -e $script_root/../build/CMakeCache.txt ]; then
cd $script_root/../build
elif [ -e $script_root/../${BUILD_DIR}/CMakeCache.txt ]; then
cd $script_root/../${BUILD_DIR}
script_root=$PWD
fi
ceph_bin=$script_root/bin
Expand Down
6 changes: 4 additions & 2 deletions src/mrun
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ command=$2
CEPH_BIN=$root
CEPH_CONF_PATH=$root/run/$run_name

[ -z "$BUILD_DIR" ] && BUILD_DIR=build

if [ -e CMakeCache.txt ]; then
CEPH_BIN=$PWD/bin
CEPH_CONF_PATH=$PWD/run/$run_name
elif [ -e $root/../build/CMakeCache.txt ]; then
cd $root/../build
elif [ -e $root/../${BUILD_DIR}/CMakeCache.txt ]; then
cd $root/../${BUILD_DIR}
CEPH_BIN=$PWD/bin
CEPH_CONF_PATH=$PWD/run/$run_name
fi
Expand Down
6 changes: 4 additions & 2 deletions src/mstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ vstart_path=`dirname $0`
root_path=`dirname $0`
root_path=`(cd $root_path; pwd)`

[ -z "$BUILD_DIR" ] && BUILD_DIR=build

if [ -e CMakeCache.txt ]; then
root_path=$PWD
elif [ -e $root_path/../build/CMakeCache.txt ]; then
cd $root_path/../build
elif [ -e $root_path/../${BUILD_DIR}/CMakeCache.txt ]; then
cd $root_path/../${BUILD_DIR}
root_path=$PWD
fi
RUN_ROOT_PATH=${root_path}/run
Expand Down
6 changes: 4 additions & 2 deletions src/mstop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ set -e

script_root=`dirname $0`

[ -z "$BUILD_DIR" ] && BUILD_DIR=build

if [ -e CMakeCache.txt ]; then
script_root=$PWD
elif [ -e $script_root/../build/CMakeCache.txt ]; then
script_root=`(cd $script_root/../build; pwd)`
elif [ -e $script_root/../${BUILD_DIR}/CMakeCache.txt ]; then
script_root=`(cd $script_root/../${BUILD_DIR}; pwd)`
fi

[ "$#" -lt 1 ] && echo "usage: $0 <name> [entity [id]]" && exit 1
Expand Down
3 changes: 2 additions & 1 deletion src/pybind/mgr/dashboard/run-backend-api-request.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

CURR_DIR=`pwd`
cd ../../../../build
[ -z "$BUILD_DIR" ] && BUILD_DIR=build
cd ../../../../${BUILD_DIR}
API_URL=`./bin/ceph mgr services 2>/dev/null | jq .dashboard | sed -e 's/"//g' -e 's!/$!!g'`
if [ "$API_URL" = "null" ]; then
echo "Couldn't retrieve API URL, exiting..." >&2
Expand Down
26 changes: 14 additions & 12 deletions src/pybind/mgr/dashboard/run-backend-api-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ get_cmake_variable() {
grep "$variable" CMakeCache.txt | cut -d "=" -f 2
}

[ -z "$BUILD_DIR" ] && BUILD_DIR=build

get_build_py_version() {
CURR_DIR=`pwd`
BUILD_DIR="$CURR_DIR/../../../../build"
cd $BUILD_DIR
LOCAL_BUILD_DIR="$CURR_DIR/../../../../$BUILD_DIR"
cd "$LOCAL_BUILD_DIR"

CEPH_MGR_PY_VERSION_MAJOR=$(get_cmake_variable MGR_PYTHON_VERSION | cut -d '.' -f1)
if [ -n "$CEPH_MGR_PY_VERSION_MAJOR" ]; then
Expand Down Expand Up @@ -104,7 +106,7 @@ setup_coverage() {

on_tests_error() {
if [[ -n "$JENKINS_HOME" ]]; then
CEPH_OUT_DIR=${CEPH_OUT_DIR:-"$BUILD_DIR"/out}
CEPH_OUT_DIR=${CEPH_OUT_DIR:-"$LOCAL_BUILD_DIR"/out}
MGR_LOG_FILES=$(find "$CEPH_OUT_DIR" -iname "mgr.*.log" | tr '\n' ' ')
MGR_LOG_FILE_LAST_LINES=60000
for mgr_log_file in ${MGR_LOG_FILES[@]}; do
Expand All @@ -119,13 +121,13 @@ on_tests_error() {
run_teuthology_tests() {
trap on_tests_error ERR

cd "$BUILD_DIR"
cd "$LOCAL_BUILD_DIR"
find ../src/pybind/mgr/dashboard/ -name '*.pyc' -exec rm -f {} \;

OPTIONS=''
TEST_CASES=''
if [[ "$@" == '' || "$@" == '--create-cluster-only' ]]; then
TEST_CASES=`for i in \`ls $BUILD_DIR/../qa/tasks/mgr/dashboard/test_*\`; do F=$(basename $i); M="${F%.*}"; echo -n " tasks.mgr.dashboard.$M"; done`
TEST_CASES=`for i in \`ls $LOCAL_BUILD_DIR/../qa/tasks/mgr/dashboard/test_*\`; do F=$(basename $i); M="${F%.*}"; echo -n " tasks.mgr.dashboard.$M"; done`
# Mgr selftest module tests have to be run at the end as they stress the mgr daemon.
TEST_CASES="tasks.mgr.test_dashboard $TEST_CASES tasks.mgr.test_module_selftest"
if [[ "$@" == '--create-cluster-only' ]]; then
Expand All @@ -137,18 +139,18 @@ run_teuthology_tests() {
done
fi

export PATH=$BUILD_DIR/bin:$PATH
export PATH=$LOCAL_BUILD_DIR/bin:$PATH
source $TEMP_DIR/venv/bin/activate # Run after setting PATH as it does the last PATH export.
export LD_LIBRARY_PATH=$BUILD_DIR/lib/cython_modules/lib.${CEPH_PY_VERSION_MAJOR}/:$BUILD_DIR/lib
local source_dir=$(dirname "$BUILD_DIR")
export LD_LIBRARY_PATH=$LOCAL_BUILD_DIR/lib/cython_modules/lib.${CEPH_PY_VERSION_MAJOR}/:$LOCAL_BUILD_DIR/lib
local source_dir=$(dirname "$LOCAL_BUILD_DIR")
local pybind_dir=$source_dir/src/pybind
local python_common_dir=$source_dir/src/python-common
# In CI environment we set python paths inside build (where you find the required frontend build: "dist" dir).
if [[ -n "$JENKINS_HOME" ]]; then
export PYBIND=$BUILD_DIR/src/pybind
export PYBIND=$LOCAL_BUILD_DIR/src/pybind
pybind_dir=$PYBIND
fi
export PYTHONPATH=$TEMP_DIR/teuthology:$source_dir/qa:$BUILD_DIR/lib/cython_modules/lib.${CEPH_PY_VERSION_MAJOR}/:$pybind_dir:$python_common_dir:${COVERAGE_PATH}
export PYTHONPATH=$TEMP_DIR/teuthology:$source_dir/qa:$LOCAL_BUILD_DIR/lib/cython_modules/lib.${CEPH_PY_VERSION_MAJOR}/:$pybind_dir:$python_common_dir:${COVERAGE_PATH}
export RGW=${RGW:-1}

export COVERAGE_ENABLED=true
Expand All @@ -162,7 +164,7 @@ run_teuthology_tests() {
}

cleanup_teuthology() {
cd "$BUILD_DIR"
cd "$LOCAL_BUILD_DIR"
killall ceph-mgr
sleep 10
if [[ "$COVERAGE_ENABLED" == 'true' ]]; then
Expand All @@ -178,7 +180,7 @@ cleanup_teuthology() {

unset TEMP_DIR
unset CURR_DIR
unset BUILD_DIR
unset LOCAL_BUILD_DIR
unset COVERAGE_PATH
unset get_build_py_version
unset setup_teuthology
Expand Down
10 changes: 6 additions & 4 deletions src/pybind/mgr/dashboard/run-frontend-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

stop() {
if [ "$REMOTE" == "false" ]; then
cd $BUILD_DIR
cd ${FULL_PATH_BUILD_DIR}
../src/stop.sh
fi
exit $1
Expand Down Expand Up @@ -39,8 +39,10 @@ fi

DASH_DIR=`pwd`

cd ../../../../build
BUILD_DIR=`pwd`
[ -z "$BUILD_DIR" ] && BUILD_DIR=build

cd ../../../../${BUILD_DIR}
FULL_PATH_BUILD_DIR=`pwd`

if [ "$BASE_URL" == "" ]; then
MGR=2 RGW=1 ../src/vstart.sh -n -d
Expand All @@ -64,7 +66,7 @@ export BASE_URL
cd $DASH_DIR/frontend
jq .[].target=\"$BASE_URL\" proxy.conf.json.sample > proxy.conf.json

. $BUILD_DIR/src/pybind/mgr/dashboard/node-env/bin/activate
. ${FULL_PATH_BUILD_DIR}/src/pybind/mgr/dashboard/node-env/bin/activate

if [ "$DEVICE" == "chrome" ]; then
npm run e2e:ci || stop 1
Expand Down
3 changes: 2 additions & 1 deletion src/pybind/mgr/dashboard/run-frontend-unittests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
failed=false
: ${CEPH_ROOT:=$PWD/../../../../}
cd $CEPH_ROOT/src/pybind/mgr/dashboard/frontend
[ -z "$BUILD_DIR" ] && BUILD_DIR=build
if [ `uname` != "FreeBSD" ]; then
. $CEPH_ROOT/build/src/pybind/mgr/dashboard/node-env/bin/activate
. $CEPH_ROOT/${BUILD_DIR}/src/pybind/mgr/dashboard/node-env/bin/activate
fi

# Build
Expand Down
4 changes: 3 additions & 1 deletion src/script/gen-corpus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function get_jobs() {
fi
}

[ -z "$BUILD_DIR" ] && BUILD_DIR=build

function build() {
local encode_dump_path=$1
shift
Expand All @@ -22,7 +24,7 @@ function build() {
-DWITH_DPDK=OFF \
-DWITH_SPDK=OFF \
-DCMAKE_CXX_FLAGS="-DENCODE_DUMP_PATH=${encode_dump_path}"
cd build
cd ${BUILD_DIR}
cmake --build . -- -j$(get_jobs)
}

Expand Down

0 comments on commit b8b43fe

Please sign in to comment.