Skip to content
Snippets Groups Projects
pylint-buildscript 3.55 KiB
Newer Older
Martyn Gigg's avatar
Martyn Gigg committed
#!/bin/bash -ex

###############################################################################
# Check if python files have changed
###############################################################################
if $ALLOW_SKIPPING
then
    if $WORKSPACE/buildconfig/Jenkins/check_for_changes py
    then
        echo "no python files changed, skipping pylint"
        exit 0
    fi
fi
echo "running pylint"

###############################################################################
# Print out the versions of things we are using
###############################################################################
cmake --version

###############################################################################
# RHEL6 setup steps - nodes must have a "rhel6" label set (in lowercase)
###############################################################################
if [[ ${NODE_LABELS} == *rhel6* ]]; then
  SCL_ON_RHEL6="scl enable mantidlibs34"
  ON_RHEL6=true
else
  SCL_ON_RHEL6="eval"
fi

###############################################################################
# Setup the build directory
###############################################################################
BUILD_DIR=$WORKSPACE/build
if [ -z "$BUILD_DIR" ]; then
  echo "Build directory not set. Cannot continue"
  exit 1
fi
###############################################################################
# Clean build if requested
###############################################################################
if [[ "${CLEAN}" == "true" ]]; then
  # Removing the build directory entirely guarantees a completely clean build
  rm -rf $BUILD_DIR
fi

###############################################################################
# Create the build directory if it doesn't exist
###############################################################################
[ -d $BUILD_DIR ] || mkdir $BUILD_DIR
cd $BUILD_DIR

###############################################################################
# Clean some artifacts
###############################################################################
rm -rf $BUILD_DIR/bin

###############################################################################
## Build configuration
###############################################################################
BUILD_CONFIG="Release"

###############################################################################
# CMake configuration
###############################################################################
# Generator
if [ $(command -v ninja) ]; then
  CMAKE_GENERATOR="-G Ninja"
elif [ $(command -v ninja-build) ]; then
  CMAKE_GENERATOR="-G Ninja"
fi
if [ -e $BUILD_DIR/CMakeCache.txt ]; then
  CMAKE_GENERATOR=""
fi

# Need this because some strange control sequences when using default TERM=xterm
export TERM="linux"
PYLINT_OUTPUT_DIR=$BUILD_DIR/pylint
PYLINT_FORMAT="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}"
$SCL_ON_RHEL6 "cmake ${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=${BUILD_CONFIG} -DENABLE_CPACK=OFF -DMAKE_VATES=OFF -DPYLINT_MSG_TEMPLATE=\"${PYLINT_FORMAT}\" -DPYLINT_NTHREADS=$BUILD_THREADS -DPYLINT_OUTPUT_DIR=${PYLINT_OUTPUT_DIR} .."
Martyn Gigg's avatar
Martyn Gigg committed

###############################################################################
# Build step (we only need the framework)
###############################################################################
$SCL_ON_RHEL6 "cmake --build . --target Framework -- -j$BUILD_THREADS"

###############################################################################
# Run plint check
Martyn Gigg's avatar
Martyn Gigg committed
###############################################################################
$SCL_ON_RHEL6 "cmake --build . --target pylintcheck"