diff options
author | 1138-4EB <1138-4EB@users.noreply.github.com> | 2019-02-23 02:24:34 +0100 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2019-02-23 07:12:04 +0100 |
commit | 75204b10ffb1f57fd035d8f0c601618b30e4b81a (patch) | |
tree | 214a309f05f69eb2a1f34da5d79d5c1959cdba5e | |
parent | d43cc2a62925d273147576b4a263dee1a051c74e (diff) | |
download | ghdl-75204b10ffb1f57fd035d8f0c601618b30e4b81a.tar.gz ghdl-75204b10ffb1f57fd035d8f0c601618b30e4b81a.tar.bz2 ghdl-75204b10ffb1f57fd035d8f0c601618b30e4b81a.zip |
rename travis-utils to utils; load ansi_color, add buildCmdOpts, travis_start and travis_finish
-rwxr-xr-x | dist/travis/build.sh | 61 | ||||
-rwxr-xr-x | dist/travis/test.sh | 24 | ||||
-rwxr-xr-x | dist/travis/travis-ci.sh | 89 | ||||
-rw-r--r-- | dist/travis/travis-utils.sh | 23 | ||||
-rw-r--r-- | dist/travis/utils.sh | 83 |
5 files changed, 141 insertions, 139 deletions
diff --git a/dist/travis/build.sh b/dist/travis/build.sh index b7518dc30..2a8852232 100755 --- a/dist/travis/build.sh +++ b/dist/travis/build.sh @@ -2,8 +2,7 @@ scriptdir=$(dirname $0) -. "$scriptdir/travis-utils.sh" -. "$scriptdir/../ansi_color.sh" +. "$scriptdir/utils.sh" disable_color echo "$0" "$@" @@ -40,29 +39,26 @@ rm -f build_ok #--- Env -echo "travis_fold:start:env.docker" -printf "$ANSI_YELLOW[Info] Environment $ANSI_NOCOLOR\n" +travis_start "env.docker" "$ANSI_YELLOW[Info] Environment $ANSI_NOCOLOR" env -echo "travis_fold:end:env.docker" +travis_finish "env.docker" #--- GPL: gpl-ize sources if [ "$ISGPL" = "true" ]; then - echo "travis_fold:start:gpl.src" - printf "$ANSI_YELLOW[Source] create GPL sources $ANSI_NOCOLOR\n" + travis_start "gpl.src" "$ANSI_YELLOW[Source] create GPL sources $ANSI_NOCOLOR" files=`echo *` make -f Makefile.in srcdir=. clean-pure-gpl mkdir ${PKG_NAME} cp -pdrl $files ${PKG_NAME} tar -zcf "${PKG_NAME}.tar.gz" ${PKG_NAME} PKG_NAME="${PKG_NAME}-${BLD}" - echo "travis_fold:end:gpl.src" + travis_finish "gpl.src" fi #--- Configure -echo "travis_fold:start:configure" -printf "$ANSI_YELLOW[GHDL - build] Configure $ANSI_NOCOLOR\n" +travis_start "configure" "$ANSI_YELLOW[GHDL - build] Configure $ANSI_NOCOLOR" -notime CDIR=$(pwd) export prefix="$CDIR/install-$BLD" @@ -72,9 +68,7 @@ cd "build-$BLD" case "$BLD" in gcc*) - echo "travis_fold:start:get_gcc" - travis_time_start - printf "$ANSI_YELLOW[GHDL] Get gcc sources $ANSI_NOCOLOR\n" + travis_start "get_gcc" "$ANSI_YELLOW[GHDL] Get gcc sources $ANSI_NOCOLOR" echo "https://github.com/gcc-mirror/gcc/archive/$(echo ${BLD} | sed -e 's/\./_/g')-release.tar.gz" mkdir gcc-srcs curl -L "https://github.com/gcc-mirror/gcc/archive/$(echo ${BLD} | sed -e 's/\./_/g')-release.tar.gz" | tar -xz -C gcc-srcs --strip-components=1 @@ -82,18 +76,14 @@ case "$BLD" in sed -i.bak s/ftp:/http:/g ./contrib/download_prerequisites ./contrib/download_prerequisites cd .. - travis_time_finish - echo "travis_fold:end:get_gcc" + travis_finish "get_gcc" - echo "travis_fold:start:configure_gcc" - travis_time_start - printf "$ANSI_YELLOW[GHDL] Configure gcc $ANSI_NOCOLOR\n" + travis_start "configure_gcc" "$ANSI_YELLOW[GHDL] Configure gcc $ANSI_NOCOLOR" ../configure --with-gcc=gcc-srcs --prefix="$prefix" make copy-sources mkdir gcc-objs; cd gcc-objs ../gcc-srcs/configure --prefix="$prefix" --enable-languages=c,vhdl --disable-bootstrap --disable-lto --disable-multilib --disable-libssp --disable-libgomp --disable-libquadmath "`gcc -v 2>&1 | grep -o -- --enable-default-pie`" - travis_time_finish - echo "travis_fold:end:configure_gcc" + travis_finish "configure_gcc" ;; mcode) config_opts="" @@ -137,47 +127,38 @@ if [ ! "$(echo $BLD | grep gcc)" ]; then ../configure "--prefix=$prefix" $config_opts fi -echo "travis_fold:end:configure" +travis_finish "configure" -notime #--- make -echo "travis_fold:start:make" -travis_time_start -printf "$ANSI_YELLOW[GHDL - build] Make $ANSI_NOCOLOR\n" +travis_start "make" "$ANSI_YELLOW[GHDL - build] Make $ANSI_NOCOLOR" set +e make -j$(nproc) 2>make_err.log tail -1000 make_err.log set -e -travis_time_finish -echo "travis_fold:end:make" +travis_finish "make" -echo "travis_fold:start:install" -printf "$ANSI_YELLOW[GHDL - build] Install $ANSI_NOCOLOR\n" +travis_start "install" "$ANSI_YELLOW[GHDL - build] Install $ANSI_NOCOLOR" make install cd .. -echo "travis_fold:end:install" +travis_finish "install" if [ "$(echo $BLD | grep gcc)" ]; then - echo "travis_fold:start:make_ghdllib" - travis_time_start - printf "$ANSI_YELLOW[GHDL - build] Make ghdllib $ANSI_NOCOLOR\n" + travis_start "make_ghdllib" "$ANSI_YELLOW[GHDL - build] Make ghdllib $ANSI_NOCOLOR" make ghdllib - travis_time_finish - echo "travis_fold:end:make_ghdllib" + travis_finish "make_ghdllib" - echo "travis_fold:start:install_ghdllib" - printf "$ANSI_YELLOW[GHDL - build] Install ghdllib $ANSI_NOCOLOR\n" + travis_start "install_ghdllib" "$ANSI_YELLOW[GHDL - build] Install ghdllib $ANSI_NOCOLOR" make install cd .. - echo "travis_fold:end:install_ghdllib" + travis_finish "install_ghdllib" fi #--- package -echo "travis_fold:start:tar.bin" -printf "$ANSI_YELLOW[GHDL - build] Create package ${ANSI_DARKCYAN}${PKG_NAME}.tgz $ANSI_NOCOLOR\n" +travis_start "tar.bin" "$ANSI_YELLOW[GHDL - build] Create package ${ANSI_DARKCYAN}${PKG_NAME}.tgz $ANSI_NOCOLOR" tar -zcvf "${PKG_NAME}.tgz" -C "$prefix" . -echo "travis_fold:end:tar.bin" +travis_finish "tar.bin" #--- build tools versions diff --git a/dist/travis/test.sh b/dist/travis/test.sh index c6113584d..b57d190d0 100755 --- a/dist/travis/test.sh +++ b/dist/travis/test.sh @@ -2,8 +2,7 @@ scriptdir=$(dirname $0) -. "$scriptdir/travis-utils.sh" -. "$scriptdir/../ansi_color.sh" +. "$scriptdir/utils.sh" disable_color echo "$0" "$@" @@ -43,9 +42,7 @@ fi cd testsuite failures="" -echo "travis_fold:start:tests.sanity" -travis_time_start -printf "$ANSI_YELLOW[GHDL - test] sanity $ANSI_NOCOLOR\n" +travis_start "tests.sanity" "$ANSI_YELLOW[GHDL - test] sanity $ANSI_NOCOLOR" cd sanity for d in [0-9]*; do cd $d @@ -62,14 +59,11 @@ for d in [0-9]*; do [ "$failures" = "" ] || break done cd .. -travis_time_finish -echo "travis_fold:end:tests.sanity" +travis_finish "tests.sanity" [ "$failures" = "" ] || exit 1 if [ "$ISGPL" != "true" ]; then - echo "travis_fold:start:tests.gna" - travis_time_start - printf "$ANSI_YELLOW[GHDL - test] gna $ANSI_NOCOLOR\n" + travis_start "tests.gna" "$ANSI_YELLOW[GHDL - test] gna $ANSI_NOCOLOR" cd gna dirs=`./testsuite.sh --list-tests` for d in $dirs; do @@ -87,14 +81,11 @@ if [ "$ISGPL" != "true" ]; then [ "$failures" = "" ] || break done cd .. - travis_time_finish - echo "travis_fold:end:tests.gna" + travis_finish "tests.gna" [ "$failures" = "" ] || exit 1 fi -echo "travis_fold:start:tests.vests" -travis_time_start -printf "$ANSI_YELLOW[GHDL - test] vests $ANSI_NOCOLOR\n" +travis_start "tests.vests" "$ANSI_YELLOW[GHDL - test] vests $ANSI_NOCOLOR" cd vests if ./testsuite.sh > vests.log 2>&1 ; then echo "${ANSI_GREEN}Vests is OK$ANSI_NOCOLOR" @@ -105,8 +96,7 @@ else failures=vests fi cd .. -travis_time_finish -echo "travis_fold:end:tests.vests" +travis_finish "tests.vests" [ "$failures" = "" ] || exit 1 $GHDL --version diff --git a/dist/travis/travis-ci.sh b/dist/travis/travis-ci.sh index e9e419c66..1f5596600 100755 --- a/dist/travis/travis-ci.sh +++ b/dist/travis/travis-ci.sh @@ -2,21 +2,12 @@ # This script is executed in the travis-ci environment. build_img_ghdl() { - # Build ghdl/ghdl from ghdl/run - echo "travis_fold:start:build_run" - travis_time_start - printf "$ANSI_BLUE[DOCKER build] ghdl : ${IMAGE_TAG}$ANSI_NOCOLOR\n" - - PKG=`ls | grep -oP 'ghdl-.*tgz'` - mkdir tmp-img && cd tmp-img - cp ../$PKG ./ - cp ../BUILD_TOOLS ./ - echo "FROM ghdl/run:$IMAGE_TAG" > Dockerfile - echo "ADD $PKG /usr/local" >> Dockerfile - docker build -t ghdl/ghdl:$IMAGE_TAG . - cd .. - travis_time_finish - echo "travis_fold:end:build_run" + travis_start "build_run" "$ANSI_BLUE[DOCKER build] ghdl/ghdl:${IMAGE_TAG}$ANSI_NOCOLOR" + docker build -t ghdl/ghdl:$IMAGE_TAG . -f-<<EOF +FROM ghdl/run:$IMAGE_TAG +ADD `ls | grep -oP 'ghdl-.*tgz'` /usr/local +EOF + travis_finish "build_run" } #--- @@ -25,17 +16,14 @@ set -e scriptdir=$(dirname $0) -. "$scriptdir/travis-utils.sh" -. "$scriptdir/../ansi_color.sh" -#disable_color +. "$scriptdir/utils.sh" # Display env (to debug) -echo -en "travis_fold:start:travis_env\r" -printf "$ANSI_YELLOW[TRAVIS] Travis environment $ANSI_NOCOLOR\n" +travis_start "travis_env" "$ANSI_YELLOW[TRAVIS] Travis environment $ANSI_NOCOLOR" env | grep TRAVIS -echo -en "travis_fold:end:travis_env\r" +travis_finish "travis_env" if [ "$IMAGE" = "" ]; then @@ -44,69 +32,53 @@ if [ "$IMAGE" = "" ]; then fi -echo "travis_fold:start:fetch" +travis_start "fetch" "$ANSI_YELLOW[GHDL - build] git fetch --unshallow $ANSI_NOCOLOR" # The command 'git describe' (used for version) needs the history. Get it. # But the following command fails if the repository is complete. git fetch --unshallow || true -echo "travis_fold:end:fetch" +travis_finish "fetch" + if [ "$TRAVIS_OS_NAME" = "osx" ]; then - # Install gnat compiler (use cache) + travis_start "ada" "$ANSI_YELLOW[GHDL - build] Install gnat compiler (use cache) $ANSI_NOCOLOR" ./dist/macosx/install-ada.sh || exit 1 PATH=$PWD/gnat/bin:$PATH + travis_finish "ada" fi -# Compute package name - -PKG_SHORTCOMMIT="$(printf $TRAVIS_COMMIT | cut -c1-10)" -PKG_VER=`grep "ghdl_version=" configure | sed -e 's/.*"\(.*\)";/\1/'` -if [ -z "$TRAVIS_TAG" ]; then - # No tag: use date + commit id - PKG_TAG="$(date -u +%Y%m%d)-$PKG_SHORTCOMMIT"; -elif expr "$TRAVIS_TAG" : 'v[0-9].*' > /dev/null; then - # Remove leading 'v' in tags in the filenames. - PKG_TAG="$(echo $TRAVIS_TAG | cut -c2-)" -else - # Regular tag (like snapshots), nothing to change. - PKG_TAG="$TRAVIS_TAG" -fi - -# Extract from IMAGE (defined in .travis.yml) -IFS='+' read -ra REFS <<< "$IMAGE" -DDIST=${REFS[0]} # Linux distro (eg: ubuntuXX, fedoraXX) -DBLD=${REFS[1]} # Build/backend (eg: mcode, llvm) -DGPL=${REFS[2]} # GPL or not - -PKG_NAME="ghdl-${PKG_TAG}-${DDIST}-${DBLD}" -BUILD_CMD_OPTS="$ENABLECOLOR -b $DBLD" -if [ "$DGPL" = "gpl" ]; then - BUILD_CMD_OPTS="$BUILD_CMD_OPTS --gpl" - PKG_NAME="ghdl-gpl-${PKG_TAG}" -fi -BUILD_CMD_OPTS="${BUILD_CMD_OPTS} -p $PKG_NAME" +# Get build command options +travis_start "opts" "$ANSI_YELLOW[GHDL - build] Get build command options $ANSI_NOCOLOR" +buildCmdOpts echo "build cmd: $BUILD_CMD_OPTS" - +travis_finish "opts" # Build +RUN="docker run --rm -t -e TRAVIS=$TRAVIS -v $(pwd):/work -w /work" + if [ "$TRAVIS_OS_NAME" = "osx" ]; then bash -c "${scriptdir}/build.sh $BUILD_CMD_OPTS" else # Assume linux - # Build version.tmp and replace version.in with it (so that the version is - # correctly set). + travis_start "version" "$ANSI_YELLOW[GHDL - build] Build version.tmp and replace version.in with it (so that the version is correctly set) $ANSI_NOCOLOR" # This is a little bit hack-ish, as it assumes that 'git' is not # available in docker (otherwise it will describe as -dirty # because this modifies the source file version.in). ghdl_version_line=`grep -e '^ghdl_version' configure` make -f Makefile.in srcdir=. $ghdl_version_line version.tmp cp version.tmp src/version.in + travis_finish "version" - # Run build in docker IMAGE_TAG=`echo $IMAGE | sed -e 's/+/-/g'` - docker run --rm -t -v $(pwd):/work -w "/work" ghdl/build:$IMAGE_TAG bash -c "${scriptdir}/build.sh $BUILD_CMD_OPTS" + + travis_start "pull" "$ANSI_YELLOW[GHDL - build] Docker pull ghdl/build:$IMAGE $ANSI_NOCOLOR" + docker pull ghdl/build:$IMAGE_TAG + travis_finish "pull" + + # Run build in docker + $RUN "ghdl/build:$IMAGE_TAG" bash -c "${scriptdir}/build.sh $BUILD_CMD_OPTS" fi if [ ! -f build_ok ]; then @@ -114,7 +86,6 @@ if [ ! -f build_ok ]; then exit 1 fi - # Test if [ "$TRAVIS_OS_NAME" = "osx" ]; then @@ -123,7 +94,7 @@ else # Build ghdl/ghdl:$IMAGE_TAG image build_img_ghdl # Run test in docker container - docker run --rm -t -v $(pwd):/work -w "/work" ghdl/ghdl:$IMAGE_TAG bash -c "GHDL=ghdl ${scriptdir}/test.sh $BUILD_CMD_OPTS" + $RUN "ghdl/ghdl:$IMAGE_TAG" bash -c "GHDL=ghdl ${scriptdir}/test.sh $BUILD_CMD_OPTS" fi if [ ! -f test_ok ]; then diff --git a/dist/travis/travis-utils.sh b/dist/travis/travis-utils.sh deleted file mode 100644 index 8db013f7b..000000000 --- a/dist/travis/travis-utils.sh +++ /dev/null @@ -1,23 +0,0 @@ -# This is a trimmed down copy of -# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh -travis_time_start() { - # `date +%N` returns the date in nanoseconds. It is used as a replacement for $RANDOM, which is only available in bash. - travis_timer_id=`date +%N` - travis_start_time=$(travis_nanoseconds) - echo "travis_time:start:$travis_timer_id" -} -travis_time_finish() { - travis_end_time=$(travis_nanoseconds) - local duration=$(($travis_end_time-$travis_start_time)) - echo "travis_time:end:$travis_timer_id:start=$travis_start_time,finish=$travis_end_time,duration=$duration" -} - -if [ "$TRAVIS_OS_NAME" = "osx" ]; then - travis_nanoseconds() { - date -u '+%s000000000' - } -else - travis_nanoseconds() { - date -u '+%s%N' - } -fi diff --git a/dist/travis/utils.sh b/dist/travis/utils.sh new file mode 100644 index 000000000..7987c762b --- /dev/null +++ b/dist/travis/utils.sh @@ -0,0 +1,83 @@ +travis_start () { + : +} +travis_finish () { + : +} + +if [ -n "$TRAVIS" ]; then + # This is a trimmed down copy of https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/* + travis_time_start() { + # `date +%N` returns the date in nanoseconds. It is used as a replacement for $RANDOM, which is only available in bash. + travis_timer_id=`date +%N` + travis_start_time=$(travis_nanoseconds) + echo "travis_time:start:$travis_timer_id" + } + travis_time_finish() { + travis_end_time=$(travis_nanoseconds) + local duration=$(($travis_end_time-$travis_start_time)) + echo "travis_time:end:$travis_timer_id:start=$travis_start_time,finish=$travis_end_time,duration=$duration" + } + + if [ "$TRAVIS_OS_NAME" = "osx" ]; then + travis_nanoseconds() { + date -u '+%s000000000' + } + else + travis_nanoseconds() { + date -u '+%s%N' + } + fi + + travis_start () { + echo "travis_fold:start:$1" + if [ -z "$3" ]; then + travis_time_start + fi + printf "$2\n" + } + + travis_finish () { + if [ -z "$2" ]; then + travis_time_finish + fi + echo "travis_fold:end:$1" + } +fi + +#-- + +buildCmdOpts () { + # Compute package name + PKG_SHORTCOMMIT="$(printf $TRAVIS_COMMIT | cut -c1-10)" + PKG_VER=`grep "ghdl_version=" configure | sed -e 's/.*"\(.*\)";/\1/'` + if [ -z "$TRAVIS_TAG" ]; then + # No tag: use date + commit id + PKG_TAG="$(date -u +%Y%m%d)-$PKG_SHORTCOMMIT"; + elif expr "$TRAVIS_TAG" : 'v[0-9].*' > /dev/null; then + # Remove leading 'v' in tags in the filenames. + PKG_TAG="$(echo $TRAVIS_TAG | cut -c2-)" + else + # Regular tag (like snapshots), nothing to change. + PKG_TAG="$TRAVIS_TAG" + fi + + # Extract from IMAGE (defined in .travis.yml) + IFS='+' read -ra REFS <<< "$IMAGE" + DDIST=${REFS[0]} # Linux distro (eg: ubuntuXX, fedoraXX) + DBLD=${REFS[1]} # Build/backend (eg: mcode, llvm) + DGPL=${REFS[2]} # GPL or not + + PKG_NAME="ghdl-${PKG_TAG}-${DDIST}-${DBLD}" + BUILD_CMD_OPTS="$ENABLECOLOR -b $DBLD" + if [ "$DGPL" = "gpl" ]; then + BUILD_CMD_OPTS="$BUILD_CMD_OPTS --gpl" + PKG_NAME="ghdl-gpl-${PKG_TAG}" + fi + export BUILD_CMD_OPTS="${BUILD_CMD_OPTS} -p $PKG_NAME" +} + +#-- + +. "$scriptdir/../ansi_color.sh" +#disable_color |