Commit 030fba71 authored by T.J. Corona's avatar T.J. Corona

Add docker recipe for building CMB on centos 7

parent 33bc805f
Pipeline #146108 passed with stage
FROM centos:7
MAINTAINER T.J. Corona <tj.corona@kitware.com>
COPY ./build_cmb.sh /tmp/build_cmb.sh
RUN yum install -y \
wget \
zlib-devel \
libcurl-devel \
python-devel \
epel-release \
emacs \
which \
freeglut-devel \
glew-devel \
graphviz-devel \
libpng-devel \
libxcb \
libxcb-devel \
libXt-devel \
xcb-util \
xcb-util-devel \
mesa-libGL-devel \
libxkbcommon-devel && \
yum group install -y "Development Tools" && \
yum install -y \
centos-release-scl \
devtoolset-7-gcc-c++ \
devtoolset-7 \
devtoolset-7-gcc \
centos-release-scl
# Build and install Qt
ARG QT_VERSION=5.12.3
ARG QT_BASE_DOWNLOAD_URL=http://download.qt.io/official_releases/qt/5.12/5.12.3/single/
ENV QT_DIR qt-everywhere-src-$QT_VERSION
ENV QT_TARBALL $QT_DIR.tar.xz
ENV QT_DOWNLOAD_URL $QT_BASE_DOWNLOAD_URL/$QT_TARBALL
RUN wget $QT_DOWNLOAD_URL && \
md5=$(md5sum ./$QT_TARBALL | awk '{ print $1 }') && \
[ $md5 = "38017e0ed88b9baba063bd723d9ca8b2" ] && \
tar -xJf $QT_TARBALL && \
rm -rf $QT_TARBALL && \
cd $QT_DIR && \
./configure -opensource \
-release \
-confirm-license \
-nomake examples \
-skip qtconnectivity \
-skip qtlocation \
-skip qtmultimedia \
-skip qtsensors \
-skip qtserialport \
-skip qtsvg \
-skip qtwayland \
-skip qtwebchannel \
-skip qtwebengine \
-skip qtwebsockets \
-no-dbus \
-no-openssl \
-qt-libjpeg \
-qt-pcre && \
make -j$(grep -c processor /proc/cpuinfo) && \
make install && \
cd .. && \
rm -rf $QT_DIR
RUN scl enable devtoolset-7 -- sh /tmp/build_cmb.sh
#!/usr/bin/env bash
#=========================================================================
# Copyright (c) Kitware, Inc.
# All rights reserved.
# See LICENSE.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the above copyright notice for more information.
#=========================================================================
# A bash script for building CMB in a *NIX development environment with Qt5 and
# the prerequesites for ParaView/VTK installed. Users can select the download,
# build and install directories via command-line arguments. Additionally, users
# can select the "download-only" option to download all necessary packages to
# the download directory for a subsequent offline build.
# The default locations for these paths are useful when constructing a fresh
# Docker container. They can be overridden using command-line arguments.
install_path=/usr/local
download_path=/tmp/download
build_path=/tmp
download_only=NO
# The number of parallel processes with which to execute our builds is
# determined by querying the operating system for the number of logical cores it
# contains.
nproc=4
if [ -f /proc/cpuinfo ]
then
nproc=$(grep -c processor /proc/cpuinfo)
elif [[ "$OSTYPE" == "darwin"* ]]
then
nproc=$(sysctl -n hw.ncpu)
fi
# The default Qt5 location corresponds to a default install on a linux machine.
# This parameter can be overridden by setting the environment variable
# "Qt5_DIR".
qt5_path=/usr/local/Qt-5.12.3/lib/cmake/Qt5
if [ -z "Qt5_DIR" ]
then
qt5_path=${Qt5_DIR}
fi
# Versions/revisions for CMake, CMB-Superbuild, SMTK and CMB
cmake_version='3.15.1'
cmb_superbuild_revision='33bc805f'
smtk_revision='70890bdf'
cmb_revision='32a2f2c7'
# Parse arguments
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-i|--install-path)
install_path="$2"
shift
shift
;;
-d|--download-path)
download_path="$2"
shift
shift
;;
-b|--build-path)
build_path="$2"
shift
shift
;;
--download-only)
download_only=YES
shift
;;
--help)
echo "usage: $0 [-i | --install-path /path/to/install] [-d | --download-path /path/to/download] [-b | --build-path /path/to/build] [--download_only]"
exit 1
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# Construct directories for download, build and install.
if [ ! -d ${download_path} ]; then mkdir ${download_path} ; fi
if [ ! -d ${build_path} ]; then mkdir ${build_path} ; fi
if [ ! -d ${install_path} ]; then mkdir ${install_path} ; fi
# CMake is used for both downloading and building/installing software. If the
# "download-only" selection is made, cmake is retrieved and extracted into the
# download directory. This global variable keeps track of the CMake executable.
cmake_executable=${install_path}/bin/cmake
install_cmake() {
os="Linux"
if [[ "$OSTYPE" == "darwin"* ]]; then os="Darwin" ; fi
# download
if [ ! -f ${download_path}/cmake-${cmake_version}-${os}-x86_64.tar.gz ]
then
curl -L https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${os}-x86_64.tar.gz > ${download_path}/cmake-${cmake_version}-${os}-x86_64.tar.gz
fi
if [ ! ${download_only} == "YES" ]
then
# extract
if [ ! -d ${build_path}/cmake-${cmake_version}-${os}-x86_64 ]
then
tar -xzf ${download_path}/cmake-${cmake_version}-${os}-x86_64.tar.gz -C ${build_path}
fi
# install
cp -r ${build_path}/cmake-${cmake_version}-${os}-x86_64/* ${install_path}
else
# If the user selected "download-only," we still need cmake to extract
# packages from the CMB superbuild. In this case, we simply extract
# cmake to the download directory.
# extract
if [ ! -d ${download_path}/cmake-${cmake_version}-${os}-x86_64 ]
then
tar -xzf ${download_path}/cmake-${cmake_version}-${os}-x86_64.tar.gz -C ${download_path}
fi
# Assign the cmake executable to point to the CMake instance in the
# download directory.
cmake_executable=${download_path}/cmake-${cmake_version}-${os}-x86_64/bin/cmake
fi
}
install_cmb_dependencies() {
# Build flags that are commonly needed in both the download and
# build/install phases.
cmb_dependencies_args="-D DEVELOPER_MODE_cmb=ON \
-D DEVELOPER_MODE_smtk=ON \
-D USE_SYSTEM_qt5=ON \
-D paraview_SOURCE_SELECTION=offline \
-D Qt5_DIR=${qt5_path}"
# On OS X, a system python is assumed but never implicilty found correctly,
# so we explicitly set it.
if [[ "$OSTYPE" == "darwin"* ]]; then
cmb_dependencies_args+=" -D PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python2.7 \
-D PYTHON_INCLUDE_DIR:PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/python2.7 \
-D PYTHON_LIBRARY:FILEPATH=/usr/lib/libpython2.7.dylib"
fi
# download
if [ ! -f ${download_path}/cmb-superbuild-${cmb_superbuild_revision}.tar.gz ]
then
git clone -n https://gitlab.kitware.com/cmb/cmb-superbuild.git \
${download_path}/cmb-superbuild
pushd ${download_path}/cmb-superbuild
git checkout ${cmb_superbuild_revision}
git submodule update --init --recursive
# git archive does not correcltly store submodules, so we simply tar the
# entire source tree.
cd ..
tar czf cmb-superbuild-${cmb_superbuild_revision}.tar.gz cmb-superbuild
# We create a dummy build directory to configure and run the target
# "download-all".
#
# TODO: this step should not require that the superbuild configure
# completely (we don't need python's location to download
# tarfiles).
mkdir -p ${download_path}/cmb-superbuild-projects
cd ${download_path}/cmb-superbuild-projects
${cmake_executable} ${cmb_dependencies_args} ${download_path}/cmb-superbuild
make download-all -j${nproc}
mv downloads ${download_path}/cmb-superbuild-downloads
# Clean up the downloaded source and dummy build directories.
cd ..
rm -rf cmb-superbuild-projects
rm -rf cmb-superbuild
popd
fi
if [ ${download_only} == "YES" ]; then return ; fi
# extract
if [ ! -d ${build_path}/cmb-superbuild ]
then
tar -xzf ${download_path}/cmb-superbuild-${cmb_superbuild_revision}.tar.gz -C ${build_path}
fi
# build
mkdir -p ${build_path}/cmb-superbuild-build
pushd ${build_path}/cmb-superbuild-build
cp ${download_path}/cmb-superbuild-downloads/* downloads/.
tar -xvf ${download_path}/paraview.tar.gz -C superbuild/paraview
${cmake_executable} ${cmb_dependencies_args} -D __BUILDBOT_INSTALL_LOCATION=${install_path} \
${build_path}/cmb-superbuild
# build
make -j${nproc}
# copy configuration files
mkdir -p ${install_path}/share
cp ./{smtk,cmb}-developer-config.cmake ${install_path}/share/.
popd
}
install_smtk() {
# download
if [ ! -f ${download_path}/smtk-${smtk_revision}.tar.gz ]
then
git clone -n https://gitlab.kitware.com/cmb/smtk.git ${download_path}/smtk
pushd ${download_path}/smtk
git checkout ${smtk_revision}
git submodule update --init --recursive
cd ..
tar czf smtk-${smtk_revision}.tar.gz smtk
rm -rf smtk
popd
fi
if [ ${download_only} == "YES" ]; then return ; fi
# extract
if [ ! -d ${build_path}/smtk ]
then
tar -xzf ${download_path}/smtk-${smtk_revision}.tar.gz -C ${build_path}
fi
# build
mkdir -p ${build_path}/smtk-build
pushd ${build_path}/smtk-build
${cmake_executable} \
-C ${install_path}/share/smtk-developer-config.cmake \
-D CMAKE_INSTALL_PREFIX=${install_path} \
${build_path}/smtk
# build
make install -j${nproc}
popd
}
install_cmb() {
# download
if [ ! -f ${download_path}/cmb-${cmb_revision}.tar.gz ]
then
git clone -n https://gitlab.kitware.com/cmb/cmb.git ${download_path}/cmb
pushd ${download_path}/cmb
git checkout ${cmb_revision}
git submodule update --init --recursive
cd ..
tar czf cmb-${cmb_revision}.tar.gz cmb
rm -rf cmb
popd
fi
if [ ${download_only} == "YES" ]; then return ; fi
# extract
if [ ! -d ${build_path}/cmb ]
then
tar -xzf ${download_path}/cmb-${cmb_revision}.tar.gz -C ${build_path}
fi
# build
mkdir -p ${build_path}/cmb-build
pushd ${build_path}/cmb-build
${cmake_executable} \
-C ${install_path}/share/cmb-developer-config.cmake \
-D CMAKE_INSTALL_PREFIX=${install_path} \
${build_path}/cmb
# build
make install -j${nproc}
popd
}
install_cmake
install_cmb_dependencies
install_smtk
install_cmb
exit
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment