upx/.github/travis_build.sh

168 lines
4.7 KiB
Bash
Raw Normal View History

2016-09-25 12:00:49 +00:00
#! /bin/bash
## vim:set ts=4 sw=4 et:
set -e; set -o pipefail
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
2016-09-30 22:58:03 +00:00
if [[ $TRAVIS_OS_NAME == osx ]]; then
2016-10-07 21:07:25 +00:00
argv0=$0; argv0abs=$(greadlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
2016-09-30 22:58:03 +00:00
else
2016-10-07 21:07:25 +00:00
argv0=$0; argv0abs=$(readlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
2016-09-30 22:58:03 +00:00
fi
source "$argv0dir/travis_init.sh" || exit 1
2016-09-25 12:00:49 +00:00
2016-09-30 22:58:03 +00:00
# create dirs
cd / || exit 1
mkbuilddirs $upx_BUILDDIR $ucl_BUILDDIR $upx_testsuite_BUILDDIR $zlib_BUILDDIR
cd / && cd $upx_SRCDIR || exit 1
2016-09-25 12:00:49 +00:00
2016-09-30 22:58:03 +00:00
echo
print_settings
echo
2016-09-25 12:00:49 +00:00
echo "$CC --version"; $CC --version
echo "$CXX --version"; $CXX --version
2016-09-30 22:58:03 +00:00
echo
2016-09-25 12:00:49 +00:00
# check whitespace
2016-09-26 15:28:09 +00:00
if [[ $TRAVIS_OS_NAME == linux ]]; then
2016-09-30 22:58:03 +00:00
cd / && cd $upx_SRCDIR || exit 1
2016-09-25 12:00:49 +00:00
echo "Checking source code for whitespace violations..."
bash ./src/stub/scripts/check_whitespace.sh || exit 1
2016-09-30 22:58:03 +00:00
echo " Passed."
2016-09-25 12:00:49 +00:00
fi # linux
set -x
2016-10-11 14:34:18 +00:00
#
# rebuild UPX stubs (needs upx-stubtools)
#
if [[ $BM_X =~ (^|\+)rebuild-stubs($|\+) ]]; then
2017-03-23 12:00:42 +00:00
if [[ -f "$HOME/local/bin/bin-upx/upx-stubtools-check-version" ]]; then
bin_upx=$(readlink -en -- "$HOME/local/bin/bin-upx")
elif [[ -f "$HOME/.local/bin/bin-upx/upx-stubtools-check-version" ]]; then
bin_upx=$(readlink -en -- "$HOME/.local/bin/bin-upx")
else
bin_upx=$(readlink -en -- "$upx_SRCDIR/../deps/bin-upx-20210104")
2017-03-23 12:00:42 +00:00
fi
2016-10-11 14:34:18 +00:00
cd / && cd $upx_SRCDIR || exit 1
2017-03-23 12:00:42 +00:00
extra_subdirs=()
extra_subdirs+=( src/stub/src/arch/amd64 )
extra_subdirs+=( src/stub/src/arch/arm/v4a )
extra_subdirs+=( src/stub/src/arch/arm/v4t )
2017-04-10 07:51:35 +00:00
extra_subdirs+=( src/stub/src/arch/arm64/v8 )
2017-03-23 12:00:42 +00:00
extra_subdirs+=( src/stub/src/arch/i386 )
extra_subdirs+=( src/stub/src/arch/m68k/m68000 )
extra_subdirs+=( src/stub/src/arch/m68k/m68020 )
extra_subdirs+=( src/stub/src/arch/mips/r3000 )
2017-04-05 14:37:32 +00:00
extra_subdirs+=( src/stub/src/arch/powerpc/32 )
2017-07-23 00:22:42 +00:00
extra_subdirs+=( src/stub/src/arch/powerpc/64 )
2017-03-23 12:00:42 +00:00
extra_subdirs+=( src/stub/src/arch/powerpc/64le )
2016-10-11 14:34:18 +00:00
make -C src/stub maintainer-clean
2017-03-23 12:00:42 +00:00
for d in ${extra_subdirs[@]}; do
make -C $d -f Makefile.extra maintainer-clean
git status $d || true
done
2017-04-10 07:51:35 +00:00
git status src/stub/src || true
2017-03-23 12:00:42 +00:00
git status || true
2016-10-11 14:34:18 +00:00
failed=0
2017-03-23 12:00:42 +00:00
for d in ${extra_subdirs[@]}; do
PATH="$bin_upx:$PATH" make -C $d -f Makefile.extra || failed=1
done
2016-10-11 14:34:18 +00:00
PATH="$bin_upx:$PATH" make -C src/stub all || failed=1
if [[ $failed != 0 ]]; then
echo "UPX-ERROR: FATAL: rebuild-stubs failed"
exit 1
fi
if ! git diff --quiet; then
git status || true
git diff || true
echo "UPX-ERROR: FATAL: rebuild-stubs git status mismatch. See log file."
exit 1
fi
2017-04-10 07:51:35 +00:00
git status
2016-10-11 14:34:18 +00:00
if [[ $BM_X == rebuild-stubs ]]; then
echo "X=rebuild-stubs done. Exiting."
exit 0
fi
2017-03-23 12:00:42 +00:00
unset bin_upx extra_subdirs d failed
2016-10-11 14:34:18 +00:00
fi
2016-09-25 12:00:49 +00:00
#
# build UCL
#
2016-09-30 22:58:03 +00:00
cd / && cd $ucl_BUILDDIR || exit 1
2017-03-23 01:07:08 +00:00
# patch UCL
sed 's/^#elif (ACC_ARCH_AMD64 || ACC_ARCH_IA64)$/& \&\& !defined(__ILP32__)/' $ucl_SRCDIR/acc/acc_chk.ch > a.tmp
if cmp -s a.tmp $ucl_SRCDIR/acc/acc_chk.ch; then rm a.tmp; else mv a.tmp $ucl_SRCDIR/acc/acc_chk.ch; fi
if [[ $BUILD_LOCAL_UCL == 1 ]]; then
# ucl-1.03/configure is too old - build manually
2016-09-30 22:58:03 +00:00
rm -f ./*.o libucl.a
$CC -O2 -I$ucl_SRCDIR/include -I$ucl_SRCDIR -c $ucl_SRCDIR/src/*.c
$AR rcs libucl.a *.o
mkdir -p src/.libs
cp libucl.a src/.libs
else
if [[ ! -f config.status ]]; then
$ucl_SRCDIR/configure --enable-static --disable-shared --disable-asm
fi
make
2016-09-26 15:28:09 +00:00
fi
2016-09-30 22:58:03 +00:00
#
# build zlib
#
if [[ $BUILD_LOCAL_ZLIB == 1 ]]; then
2016-09-30 22:58:03 +00:00
cd / && cd $zlib_BUILDDIR || exit 1
# build manually
2016-09-30 22:58:03 +00:00
rm -f ./*.o libz.a
$CC -O2 -c $zlib_SRCDIR/*.c
$AR rcs libz.a *.o
fi
2016-09-25 12:00:49 +00:00
#
# build UPX
#
2016-09-30 22:58:03 +00:00
export UPX_UCLDIR="$ucl_SRCDIR"
cd / && cd $upx_BUILDDIR || exit 1
2016-09-26 15:28:09 +00:00
make="make -f $upx_SRCDIR/src/Makefile"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$ucl_BUILDDIR/src/.libs"
if [[ $BUILD_LOCAL_ZLIB == 1 ]]; then
2016-09-30 22:58:03 +00:00
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -I$zlib_SRCDIR"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$zlib_BUILDDIR"
fi
if [[ $BM_B =~ (^|\+)coverage($|\+) ]]; then
2016-09-26 15:28:09 +00:00
EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -fprofile-arcs -ftest-coverage"
2016-09-28 07:54:48 +00:00
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage"
fi
2016-09-30 22:58:03 +00:00
if [[ $BM_B =~ (^|\+)debug($|\+) ]]; then
make="$make BUILD_TYPE_DEBUG=1"
2016-09-28 07:54:48 +00:00
fi
2016-09-30 22:58:03 +00:00
if [[ $BM_B =~ (^|\+)sanitize($|\+) ]]; then
make="$make BUILD_TYPE_SANITIZE=1"
2016-09-28 07:54:48 +00:00
fi
2016-09-30 22:58:03 +00:00
if [[ $BM_B =~ (^|\+)scan-build($|\+) ]]; then
2016-09-28 07:54:48 +00:00
make="$SCAN_BUILD $make"
fi
2016-09-30 22:58:03 +00:00
if [[ $BM_B =~ (^|\+)valgrind($|\+) ]]; then
2016-09-28 07:54:48 +00:00
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -DWITH_VALGRIND"
fi
2016-09-30 22:58:03 +00:00
if [[ $BM_B =~ (^|\+)ALLOW_FAIL($|\+) ]]; then
echo "ALLOW_FAIL"
2016-09-25 12:00:49 +00:00
set +e
fi
2016-09-26 15:28:09 +00:00
export EXTRA_CPPFLAGS EXTRA_CXXFLAGS EXTRA_LDFLAGS
2016-09-25 22:01:41 +00:00
[[ -z $upx_exeext ]] && upx_exeext=.out
$make exeext=$upx_exeext
2016-09-25 22:01:41 +00:00
2016-12-13 21:03:26 +00:00
pwd
ls -l upx${upx_exeext}
$SIZE upx${upx_exeext} || true
file upx${upx_exeext}
2016-09-25 12:00:49 +00:00
exit 0