Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
{ci_build.sh, packpack}: add variable to docker CMake top-level direc…
Browse files Browse the repository at this point in the history
…tory
  • Loading branch information
lerwys committed Apr 6, 2021
1 parent 532e7d2 commit 4eccd82
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
18 changes: 13 additions & 5 deletions ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ SCRIPTS_ETC_PREFIX=$PWD/${BUILD_PREFIX_BASENAME}
SCRIPTS_SHARE_PREFIX=$PWD/${BUILD_PREFIX_BASENAME}/usr/local
LDCONF_ETC_PREFIX=$PWD/${BUILD_PREFIX_BASENAME}

# CMake docker top-level directory
DOCKER_SRC_TOP_LEVEL_DIR=/source/halcs/long-path-so-debuginfo-works-for-rpm
DOCKER_BUILD_TOP_LEVEL_DIR=/build/halcs/long-path-so-debuginfo-works-for-rpm

# With sonarqube or not
STATIC_ANALYSIS_WRAPPER=""
if [ "$SONARQUBE" = yes ]; then
Expand Down Expand Up @@ -370,20 +374,22 @@ cmake)

cpack)
# all of these options are relative to the docker container filesystem
LOCAL_LD_LIBRARY_PATH=/source/${BUILD_PREFIX_BASENAME}/lib:/source/${BUILD_PREFIX_BASENAME}/lib64
LOCAL_LD_LIBRARY_PATH=${DOCKER_SRC_TOP_LEVEL_DIR}/${BUILD_PREFIX_BASENAME}/lib:${DOCKER_SRC_TOP_LEVEL_DIR}/${BUILD_PREFIX_BASENAME}/lib64

# Build regular package
PACKPACK_OPTS=()
PACKPACK_OPTS+=("-Dcpack_generator_OPT=${CPACK_GENERATORS}")
PACKPACK_OPTS+=("-Dcpack_components_grouping_OPT=ALL_COMPONENTS_IN_ONE")
PACKPACK_OPTS+=("-Dcpack_components_all_OPT=\"Binaries;Libs;Scripts;Tools\"")
PACKPACK_OPTS+=("-Dhalcs_DISTRO_VERSION=${CPACK_DISTRO_VERSION}")
PACKPACK_OPTS+=("-DCMAKE_PREFIX_PATH=/source/${BUILD_PREFIX_BASENAME}")
PACKPACK_OPTS+=("-DCMAKE_PREFIX_PATH=${DOCKER_SRC_TOP_LEVEL_DIR}/${BUILD_PREFIX_BASENAME}")
PACKPACK_OPTS+=("-DBUILD_PCIE_DRIVER=OFF")
PACKPACK_OPTS+=("-Dhalcs_BOARD_OPT=${CPACK_BOARDS}")
# only expand and add ":" to LD_LIBRARY_PATH if non-empty
LD_LIBRARY_PATH=${LOCAL_LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} \
SOURCEDIR=$(pwd) BUILDDIR=$(pwd)/build ./packpack "${PACKPACK_OPTS[@]}"
SOURCEDIR=$(pwd) BUILDDIR=$(pwd)/build SRC_TOP_LEVEL_DIR=${DOCKER_SRC_TOP_LEVEL_DIR} \
BUILD_TOP_LEVEL_DIR=${DOCKER_BUILD_TOP_LEVEL_DIR} \
./packpack "${PACKPACK_OPTS[@]}"

if [ "$BUILD_PCIEDRIVER_PACKAGE" = yes ]; then
# Build driver package
Expand All @@ -392,11 +398,13 @@ cpack)
PACKPACK_PCIEDRIVER_OPTS+=("-Dcpack_components_grouping_OPT=ONE_PER_GROUP")
PACKPACK_PCIEDRIVER_OPTS+=("-Dcpack_components_all_OPT=\"Pciedriver\"")
PACKPACK_PCIEDRIVER_OPTS+=("-Dhalcs_DISTRO_VERSION=${CPACK_DISTRO_VERSION}")
PACKPACK_PCIEDRIVER_OPTS+=("-DCMAKE_PREFIX_PATH=/source/${BUILD_PREFIX_BASENAME}")
PACKPACK_PCIEDRIVER_OPTS+=("-DCMAKE_PREFIX_PATH=${DOCKER_SRC_TOP_LEVEL_DIR}/${BUILD_PREFIX_BASENAME}")
PACKPACK_PCIEDRIVER_OPTS+=("-DBUILD_PCIE_DRIVER=ON")
# only expand and add ":" to LD_LIBRARY_PATH if non-empty
LD_LIBRARY_PATH=${LOCAL_LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} \
SOURCEDIR=$(pwd) BUILDDIR=$(pwd)/build ./packpack "${PACKPACK_PCIEDRIVER_OPTS[@]}"
SOURCEDIR=$(pwd) BUILDDIR=$(pwd)/build SRC_TOP_LEVEL_DIR=${DOCKER_SRC_TOP_LEVEL_DIR} \
BUILD_TOP_LEVEL_DIR=${DOCKER_BUILD_TOP_LEVEL_DIR} \
./packpack "${PACKPACK_PCIEDRIVER_OPTS[@]}"
fi

cd "${BASE_PWD}"
Expand Down
26 changes: 17 additions & 9 deletions packpack
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ DOCKER_REPO=${DOCKER_REPO:-packpack/packpack}
# Extra parameters for docker run.
PACKPACK_EXTRA_DOCKER_RUN_PARAMS="${PACKPACK_EXTRA_DOCKER_RUN_PARAMS:-}"

# CMake top-level CMakeLists.txt directory
SRC_TOP_LEVEL_DIR="${SRC_TOP_LEVEL_DIR:-/source/halcs}"
BUILD_TOP_LEVEL_DIR="${BUILD_TOP_LEVEL_DIR:-/build/halcs}"

# Set CI variable to CI provider name
CI=""
if [ "${APPVEYOR:-}" = "True" -o "${APPVEYOR:-}" = "true" ]; then
Expand Down Expand Up @@ -140,8 +144,12 @@ chmod a+x ${BUILDDIR}/userwrapper.sh
(
echo "#!/bin/sh";
echo "set -x";
echo "SRC_TOP_LEVEL_DIR=\"\$1\"";
echo "shift 1";
echo "BUILD_TOP_LEVEL_DIR=\"\$1\"";
echo "shift 1";
echo "CMAKE_OPTS=\"\$@\"";
echo "cd /build";
echo "cd \${BUILD_TOP_LEVEL_DIR}";
echo "if [ -f \"/etc/debian_version\" ]; then";
echo " case \"\$(cat /etc/debian_version)\" in";
echo " *stretch* | 9.* )";
Expand All @@ -158,7 +166,7 @@ chmod a+x ${BUILDDIR}/userwrapper.sh
echo " make -j\$(nproc)";
echo " sudo make install";
echo " cmake --version";
echo " cd /build";
echo " cd \${BUILD_TOP_LEVEL_DIR}";
echo " ;;"
echo " esac";
echo "fi";
Expand All @@ -173,9 +181,9 @@ chmod a+x ${BUILDDIR}/userwrapper.sh
echo "if [ \"\$?\" -ne 0 ]; then";
echo " exit 1";
echo "fi";
echo "cmake3 \${CMAKE_OPTS} /source/build/halcsd/long-path-so-debuginfo-works";
echo "cmake3 \${CMAKE_OPTS} \${SRC_TOP_LEVEL_DIR}";
echo "if [ \"\$?\" -ne 0 ]; then";
echo " cmake \${CMAKE_OPTS} /source/build/halcsd/long-path-so-debuginfo-works";
echo " cmake \${CMAKE_OPTS} \${SRC_TOP_LEVEL_DIR}";
echo "fi";
echo "if [ \"\$?\" -ne 0 ]; then";
echo " exit 1";
Expand Down Expand Up @@ -210,19 +218,19 @@ set -ex
docker pull ${DOCKER_REPO}:${DOCKER_IMAGE}
docker run \
${PACKPACK_EXTRA_DOCKER_RUN_PARAMS} \
--volume "${SOURCEDIR}:/source/build/halcsd/long-path-so-debuginfo-works:ro" \
--volume "${BUILDDIR}:/build" \
--volume "${SOURCEDIR}:${SRC_TOP_LEVEL_DIR}:ro" \
--volume "${BUILDDIR}:${BUILD_TOP_LEVEL_DIR}" \
--env-file ${BUILDDIR}/env \
--workdir /build \
--workdir ${BUILD_TOP_LEVEL_DIR} \
--rm=true --tty=true \
--entrypoint=/build/userwrapper.sh \
--entrypoint=${BUILD_TOP_LEVEL_DIR}/userwrapper.sh \
-e XDG_CACHE_HOME=/cache \
-e CCACHE_DIR=/cache/ccache \
-e TMPDIR=/tmp \
-e CI=${CI} \
--volume "${CACHE_DIR}:/cache" \
${DOCKER_REPO}:${DOCKER_IMAGE} \
/build/usercmd.sh "$@"
${BUILD_TOP_LEVEL_DIR}/usercmd.sh "${SRC_TOP_LEVEL_DIR}" "${BUILD_TOP_LEVEL_DIR}" "$@"
retcode=$?
rm -f ${BUILDDIR}/userwrapper.sh ${BUILDDIR}/usercmd.sh ${BUILDDIR}/env
exit $retcode
Expand Down

0 comments on commit 4eccd82

Please sign in to comment.