diff options
author | Jia Tan <jiat0218@gmail.com> | 2023-01-07 10:07:20 +0800 |
---|---|---|
committer | Jia Tan <jiat0218@gmail.com> | 2023-01-07 21:15:14 +0800 |
commit | 4de35fd6b58d46fc887c78faf163f6a37b790c45 (patch) | |
tree | 7109ed79eff39b46632ccedc1367a49a93590c09 /build-aux | |
parent | Merge pull request #7 from tukaani-project/tuktest_index_hash (diff) | |
download | xz-4de35fd6b58d46fc887c78faf163f6a37b790c45.tar.xz |
CI/CD: Add new -p (PHASE) argument to ci_build.sh
The new PHASE argument can be build, test, or all. all is the default.
This way, the CI/CD script can differentiate between the build and test
phases to make it easier to track down errors when they happen.
Diffstat (limited to 'build-aux')
-rwxr-xr-x | build-aux/ci_build.sh | 140 |
1 files changed, 76 insertions, 64 deletions
diff --git a/build-aux/ci_build.sh b/build-aux/ci_build.sh index 76601580..85785d9f 100755 --- a/build-aux/ci_build.sh +++ b/build-aux/ci_build.sh @@ -16,7 +16,7 @@ set -e -USAGE="Usage: $0 -b [autotools|cmake] -c [crc32|crc64|sha256] -d [encoders,decoders,bcj,delta,threads] -l [destdir] -s [srcdir]" +USAGE="Usage: $0 -b [autotools|cmake] -c [crc32|crc64|sha256] -d [encoders|decoders|bcj|delta|threads] -l [destdir] -s [srcdir] -p [all|build|test]" # Absolute path of script directory ABS_DIR=$(cd -- "$(dirname -- "$0")" && pwd) @@ -31,9 +31,10 @@ DECODERS="y" THREADS="y" SRC_DIR="$ABS_DIR/../" DEST_DIR="$SRC_DIR/../xz_build" +PHASE="all" # Parse arguments -while getopts b:c:d:l:s: opt; do +while getopts b:c:d:l:s:p: opt; do # b option can have either value "autotools" OR "cmake" case ${opt} in b) @@ -74,68 +75,79 @@ while getopts b:c:d:l:s: opt; do ;; s) SRC_DIR="$OPTARG" ;; + p) PHASE="$OPTARG" + ;; esac done -# Build based on arguments -mkdir -p "$DEST_DIR" -case $BUILD_SYSTEM in - autotools) - # Run autogen.sh script - cd "$SRC_DIR" - "./autogen.sh" - cd "$DEST_DIR" - # Generate configure option values - - EXTRA_OPTIONS="" - FILTER_LIST="lzma1,lzma2" - - if [ "$BCJ" = "y" ] - then - FILTER_LIST="$FILTER_LIST,x86,powerpc,ia64,arm,armthumb,arm64,sparc" - fi - - if [ "$DELTA" = "y" ] - then - FILTER_LIST="$FILTER_LIST,delta" - fi - - if [ "$ENCODERS" = "y" ] - then - EXTRA_OPTIONS="$EXTRA_OPTIONS --enable-encoders=$FILTER_LIST" - else - EXTRA_OPTIONS="$EXTRA_OPTIONS --disable-encoders" - fi - - if [ "$DECODERS" = "y" ] - then - EXTRA_OPTIONS="$EXTRA_OPTIONS --enable-decoders=$FILTER_LIST" - else - EXTRA_OPTIONS="$EXTRA_OPTIONS --disable-decoders" - fi - - if [ "$THREADS" = "n" ] - then - EXTRA_OPTIONS="$EXTRA_OPTIONS --disable-threads" - fi - - # Run configure script - "$SRC_DIR"/configure --enable-checks=$CHECK_TYPE $EXTRA_OPTIONS - - # Build the project - make - - # Run the tests - make check - ;; - - cmake) - # CMake currently does not support disabling encoders, decoders, - # threading, or check types. For now, just run the full build. - cd "$DEST_DIR" - cmake "$SRC_DIR/CMakeLists.txt" -B "$DEST_DIR" - make - make test - ;; - -esac +if [ "$PHASE" = "all" ] || [ "$PHASE" = "build" ]; then + # Build based on arguments + mkdir -p "$DEST_DIR" + case $BUILD_SYSTEM in + autotools) + # Run autogen.sh script + cd "$SRC_DIR" + "./autogen.sh" + cd "$DEST_DIR" + # Generate configure option values + + EXTRA_OPTIONS="" + FILTER_LIST="lzma1,lzma2" + + if [ "$BCJ" = "y" ] + then + FILTER_LIST="$FILTER_LIST,x86,powerpc,ia64,arm,armthumb,arm64,sparc" + fi + + if [ "$DELTA" = "y" ] + then + FILTER_LIST="$FILTER_LIST,delta" + fi + + if [ "$ENCODERS" = "y" ] + then + EXTRA_OPTIONS="$EXTRA_OPTIONS --enable-encoders=$FILTER_LIST" + else + EXTRA_OPTIONS="$EXTRA_OPTIONS --disable-encoders" + fi + + if [ "$DECODERS" = "y" ] + then + EXTRA_OPTIONS="$EXTRA_OPTIONS --enable-decoders=$FILTER_LIST" + else + EXTRA_OPTIONS="$EXTRA_OPTIONS --disable-decoders" + fi + + if [ "$THREADS" = "n" ] + then + EXTRA_OPTIONS="$EXTRA_OPTIONS --disable-threads" + fi + + # Run configure script + "$SRC_DIR"/configure --enable-checks=$CHECK_TYPE $EXTRA_OPTIONS + + # Build the project + make + ;; + cmake) + # CMake currently does not support disabling encoders, decoders, + # threading, or check types. For now, just run the full build. + cd "$DEST_DIR" + cmake "$SRC_DIR/CMakeLists.txt" -B "$DEST_DIR" + make + ;; + esac +fi + +if [ "$PHASE" = "all" ] || [ "$PHASE" = "test" ]; then + case $BUILD_SYSTEM in + autotools) + cd "$DEST_DIR" + make check + ;; + cmake) + cd "$DEST_DIR" + make "test" + ;; + esac +fi
\ No newline at end of file |