3 #############################################################################
5 # Script meant to be used for Continuous Integration automation for POSIX
6 # systems. On GitHub, this is used by Ubuntu and MacOS builds.
8 #############################################################################
12 # This file has been put into the public domain.
13 # You can do whatever you want with this file.
15 #############################################################################
21 -c [crc32|crc64|sha256]
22 -d [encoders|decoders|bcj|delta|threads|shared|nls]
25 -n [ARTIFACTS_DIR_NAME]
29 # Absolute path of script directory
30 ABS_DIR
=$
(cd -- "$(dirname -- "$0")" && pwd)
32 # Default CLI option values
33 BUILD_SYSTEM
="autotools"
34 CHECK_TYPE
="crc32,crc64,sha256"
41 NATIVE_LANG_SUPPORT
="y"
42 SRC_DIR
="$ABS_DIR/../"
43 DEST_DIR
="$SRC_DIR/../xz_build"
45 ARTIFACTS_DIR_NAME
="output"
48 while getopts b
:c
:d
:l
:n
:s
:p
:f
:h opt
; do
49 # b option can have either value "autotools" OR "cmake"
59 *) echo "Invalid build system: $OPTARG"; exit 1;;
61 BUILD_SYSTEM
="$OPTARG"
63 # c options can be a comma separated list of check types to support
65 for crc
in $
(echo "$OPTARG" |
sed "s/,/ /g"); do
70 *) echo "Invalid check type: $crc"; exit 1 ;;
75 # d options can be a comma separated list of things to disable at
78 for disable_arg
in $
(echo "$OPTARG" |
sed "s/,/ /g"); do
79 case "$disable_arg" in
80 encoders
) ENCODERS
="n" ;;
81 decoders
) DECODERS
="n" ;;
84 threads
) THREADS
="n" ;;
86 nls
) NATIVE_LANG_SUPPORT
="n";;
87 *) echo "Invalid disable value: $disable_arg"; exit 1 ;;
93 n
) ARTIFACTS_DIR_NAME
="$OPTARG"
106 if [ "$PHASE" = "all" ] ||
[ "$PHASE" = "build" ]; then
107 # Build based on arguments
109 case $BUILD_SYSTEM in
113 # Run autogen.sh script if not already run
114 if [ ! -f configure
]
121 # Generate configure option values
123 FILTER_LIST
="lzma1,lzma2"
127 FILTER_LIST
="$FILTER_LIST,x86,powerpc,ia64,arm,armthumb,arm64,sparc"
130 if [ "$DELTA" = "y" ]
132 FILTER_LIST
="$FILTER_LIST,delta"
135 if [ "$ENCODERS" = "y" ]
137 EXTRA_OPTIONS
="$EXTRA_OPTIONS --enable-encoders=$FILTER_LIST"
139 EXTRA_OPTIONS
="$EXTRA_OPTIONS --disable-encoders"
142 if [ "$DECODERS" = "y" ]
144 EXTRA_OPTIONS
="$EXTRA_OPTIONS --enable-decoders=$FILTER_LIST"
146 EXTRA_OPTIONS
="$EXTRA_OPTIONS --disable-decoders"
149 if [ "$THREADS" = "n" ]
151 EXTRA_OPTIONS
="$EXTRA_OPTIONS --disable-threads"
154 if [ "$SHARED" = "n" ]
156 EXTRA_OPTIONS
="$EXTRA_OPTIONS --disable-shared"
159 if [ "$NATIVE_LANG_SUPPORT" = "n" ]
161 EXTRA_OPTIONS
="$EXTRA_OPTIONS --disable-nls"
164 # Run configure script
165 "$SRC_DIR"/configure
--enable-werror --enable-checks="$CHECK_TYPE" $EXTRA_OPTIONS --config-cache
171 # CMake currently does not support disabling encoders, decoders,
172 # threading, or check types. For now, just run the full build.
174 cmake
"$SRC_DIR/CMakeLists.txt" -B "$DEST_DIR"
180 if [ "$PHASE" = "all" ] ||
[ "$PHASE" = "test" ]; then
181 case $BUILD_SYSTEM in
184 # If the tests fail, copy the test logs into the artifacts folder
189 mkdir
-p "$SRC_DIR/build-aux/artifacts/$ARTIFACTS_DIR_NAME"
190 cp .
/tests
/*.log
"$SRC_DIR/build-aux/artifacts/$ARTIFACTS_DIR_NAME"
200 mkdir
-p "$SRC_DIR/build-aux/artifacts/$ARTIFACTS_DIR_NAME"
201 cp .
/Testing
/Temporary
/*.log
"$SRC_DIR/build-aux/artifacts/$ARTIFACTS_DIR_NAME"