Skip to content

Commit

Permalink
build: Move cpack to another script (#285)
Browse files Browse the repository at this point in the history
The cpack was creating long delays on builds that did not require it.

This commit fixes this and another quirks:
- Move cpack command to a different script.
- Remove WORKSPACE variable as conflicting with Jenkins environment.
- Set the same build type on coverage than in test.
- Allow for additional arguments to make from the command line.

Signed-off-by: Baldor <[email protected]>
  • Loading branch information
ictus4u authored Jan 22, 2025
1 parent 45f4a36 commit 93aa1fd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
32 changes: 13 additions & 19 deletions tests/ci_build/run-build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -eux -o pipefail
PROJECT_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/../..")"
WORKSPACE=${WORKSPACE:-"${PROJECT_DIR}"}

die() { echo "Error: $*" >&2; exit 1; }
warn() { echo "Warning: $*" >&2; }

Expand Down Expand Up @@ -31,44 +31,44 @@ declare -a CMAKE_SAUNAFS_ARGUMENTS=(

[ -n "${1:-}" ] || usage
declare build_type="${1}"
declare build_dir
declare -a make_extra_args=()
shift
declare build_dir
declare -a make_extra_args=("${@}")
case "${build_type,,}" in
debug)
CMAKE_SAUNAFS_ARGUMENTS+=(
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX="${WORKSPACE}/install/saunafs/"
-DCMAKE_INSTALL_PREFIX="${PROJECT_DIR}/install/saunafs/"
-DENABLE_TESTS=ON
-DCODE_COVERAGE=OFF
-DSAUNAFS_TEST_POINTER_OBFUSCATION=ON
-DENABLE_WERROR=ON
)
build_dir="${WORKSPACE}/build/saunafs-debug"
build_dir="${PROJECT_DIR}/build/saunafs-debug"
make_extra_args+=( 'install' )
;;
coverage)
CMAKE_SAUNAFS_ARGUMENTS+=(
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX="${WORKSPACE}/install/saunafs/"
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DCMAKE_INSTALL_PREFIX="${PROJECT_DIR}/install/saunafs/"
-DENABLE_TESTS=ON
-DCODE_COVERAGE=ON
-DSAUNAFS_TEST_POINTER_OBFUSCATION=ON
-DENABLE_WERROR=OFF
)
build_dir="${WORKSPACE}/build/saunafs-coverage"
build_dir="${PROJECT_DIR}/build/saunafs-coverage"
make_extra_args+=( 'install' )
;;
test)
CMAKE_SAUNAFS_ARGUMENTS+=(
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DCMAKE_INSTALL_PREFIX="${WORKSPACE}/install/saunafs/"
-DCMAKE_INSTALL_PREFIX="${PROJECT_DIR}/install/saunafs/"
-DENABLE_TESTS=ON
-DCODE_COVERAGE=OFF
-DSAUNAFS_TEST_POINTER_OBFUSCATION=ON
-DENABLE_WERROR=ON
)
build_dir="${WORKSPACE}/build/saunafs"
build_dir="${PROJECT_DIR}/build/saunafs"
make_extra_args+=( 'install' )
;;
release)
Expand All @@ -80,7 +80,7 @@ case "${build_type,,}" in
-DSAUNAFS_TEST_POINTER_OBFUSCATION=OFF
-DENABLE_WERROR=OFF
)
build_dir="${WORKSPACE}/build/saunafs-release"
build_dir="${PROJECT_DIR}/build/saunafs-release"
;;
*) die "Unsupported build type: ${build_type}"
;;
Expand All @@ -95,12 +95,6 @@ declare -a EXTRA_ARGUMENTS=("${@}")
rm -r "${build_dir:?}"/{,.}* 2>/dev/null || true
cmake -B "${build_dir}" \
"${CMAKE_SAUNAFS_ARGUMENTS[@]}" \
"${EXTRA_ARGUMENTS[@]}" "${WORKSPACE}"

nice make -C "${build_dir}" -j "$(nproc)" "${make_extra_args[@]}"
"${EXTRA_ARGUMENTS[@]}" "${PROJECT_DIR}"

if [ -f "${build_dir}/CPackConfig.cmake" ]; then
nice cpack -B "${build_dir}" --config "${build_dir}/CPackConfig.cmake" -j "$(nproc)"
else
warn "No CPack configuration found in ${build_dir}. Skipping packaging."
fi
nice make -C "${build_dir}" -j"$(nproc)" "${make_extra_args[@]}"
11 changes: 11 additions & 0 deletions tests/ci_build/run-cpack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -eu -o pipefail

PROJECT_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/../..")"
build_dir="${PROJECT_DIR}/build/saunafs-release"

if [ -f "${build_dir}/CPackConfig.cmake" ]; then
nice cpack -B "${build_dir}" --config "${build_dir}/CPackConfig.cmake" -j "$(nproc)"
else
warn "No CPack configuration found in ${build_dir}. Skipping packaging."
fi

0 comments on commit 93aa1fd

Please sign in to comment.