diff options
Diffstat (limited to 'dist/linux')
25 files changed, 548 insertions, 259 deletions
diff --git a/dist/linux/build.sh b/dist/linux/build.sh new file mode 100755 index 000000000..d6f5a3a20 --- /dev/null +++ b/dist/linux/build.sh @@ -0,0 +1,144 @@ +#! /bin/bash + +. dist/linux/travis-utils.sh +. dist/ansi_color.sh +disable_color + +echo "$0" "$@" + +# Stop in case of error +set -e + +# Transform long options to short ones +for arg in "$@"; do + shift + case "$arg" in + "--color"|"-color") set -- "$@" "-c";; + "--build"|"-build") set -- "$@" "-b";; + "--pkg"|"-pkg") set -- "$@" "-p";; + "--gpl"|"-gpl") set -- "$@" "-g";; + *) set -- "$@" "$arg" + esac +done +# Parse args +while getopts ":b:p:cg" opt; do + case $opt in + c) enable_color;; + b) BLD=$OPTARG ;; + p) PKG_NAME=$OPTARG;; + g) ISGPL=true;; + \?) printf "$ANSI_RED[GHDL - build] Invalid option: -$OPTARG $ANSI_NOCOLOR\n" >&2 + exit 1 ;; + :) printf "$ANSI_RED[GHDL - build] Option -$OPTARG requires an argument. $ANSI_NOCOLOR\n" >&2 + exit 1 ;; + esac +done + +rm -f build_ok + +#--- Env + +echo "travis_fold:start:env.docker" +printf "$ANSI_YELLOW[Info] Environment $ANSI_NOCOLOR\n" +env +echo "travis_fold:end: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" + 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" +fi + +#--- Configure + +echo "travis_fold:start:configure" +printf "$ANSI_YELLOW[GHDL - build] Configure $ANSI_NOCOLOR\n" + +CDIR=$(pwd) +export prefix="$CDIR/install-$BLD" +mkdir "$prefix" +mkdir "build-$BLD" +cd "build-$BLD" + +case "$BLD" in + mcode) + config_opts="" + CXX="" + ;; + llvm) + CXX="clang" + config_opts="--with-llvm-config CXX=$CXX" + ;; + llvm-3.5) + CXX="clang++" + config_opts="--with-llvm-config=llvm-config-3.5 CXX=$CXX" + ;; + llvm-3.8) + CXX="clang++-3.8" + config_opts="--with-llvm-config=llvm-config-3.8 CXX=$CXX" + ;; + llvm-3.9) + CXX="clang++-3.9" + config_opts="--with-llvm-config=llvm-config-3.9 CXX=$CXX" + ;; + llvm-4.0) + CXX="clang++-4.0" + config_opts="--with-llvm-config=llvm-config-4.0 CXX=$CXX" + ;; + llvm-5.0) + CXX="clang++-5.0" + config_opts="--with-llvm-config=llvm-config-5.0 CXX=$CXX" + ;; + *) + echo "$ANSI_RED[GHDL - build] Unknown build $BLD $ANSI_NOCOLOR" + exit 1;; +esac +DEP_CLANG="" +if [ "$CXX" != "" ]; then + DEP_CLANG="`$CXX --version | grep 'clang'`" +fi +echo "../configure --prefix=$prefix $config_opts" +../configure "--prefix=$prefix" $config_opts +echo "travis_fold:end:configure" + +#--- make + +echo "travis_fold:start:make" +travis_time_start +printf "$ANSI_YELLOW[GHDL - build] Make $ANSI_NOCOLOR\n" +make +travis_time_finish +echo "travis_fold:end:make" + +echo "travis_fold:start:install" +printf "$ANSI_YELLOW[GHDL - build] Install $ANSI_NOCOLOR\n" +make install +cd .. +echo "travis_fold:end:install" + +#--- package + +echo "travis_fold:start:tar.bin" +printf "$ANSI_YELLOW[GHDL - build] Create package ${ANSI_DARKCYAN}${PKG_NAME}.tgz $ANSI_NOCOLOR\n" +tar -zcvf "${PKG_NAME}.tgz" -C "$prefix" . +echo "travis_fold:end:tar.bin" + +#--- build tools versions + +printf "%s\n" \ + "`make --version | grep 'Make'`" \ + "`gnat --version | grep 'GNAT'`" \ + "`gcc --version | grep 'gcc'`" "$DEP_CLANG" > BUILD_TOOLS + +#--- + +echo "[SUCCESSFUL]" +touch build_ok diff --git a/dist/linux/buildtest.sh b/dist/linux/buildtest.sh deleted file mode 100755 index 31ae23a1b..000000000 --- a/dist/linux/buildtest.sh +++ /dev/null @@ -1,193 +0,0 @@ -#! /bin/bash - -. dist/ansi_color.sh -disable_color - -echo "$0" "$@" - -# Stop in case of error -set -e - -. dist/linux/travis-utils.sh - -rm -f build_ok - -# Transform long options to short ones -for arg in "$@"; do - shift - case "$arg" in - "--color"|"-color") set -- "$@" "-c";; - "--build"|"-build") set -- "$@" "-b";; - "--pkg"|"-pkg") set -- "$@" "-p";; - "--gpl"|"-gpl") set -- "$@" "-g";; - *) set -- "$@" "$arg" - esac -done -# Parse args -while getopts ":b:p:cg" opt; do - case $opt in - c) enable_color;; - b) BLD=$OPTARG ;; - p) PKG_NAME=$OPTARG;; - g) ISGPL=true;; - \?) printf "$ANSI_RED[GHDL] Invalid option: -$OPTARG $ANSI_NOCOLOR\n" >&2 - exit 1 ;; - :) printf "$ANSI_RED[GHDL] Option -$OPTARG requires an argument. $ANSI_NOCOLOR\n" >&2 - exit 1 ;; - esac -done - -#--- Env - -echo "travis_fold:start:env.docker" -printf "$ANSI_YELLOW[Info] Environment $ANSI_NOCOLOR\n" -env -echo "travis_fold:end: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" - 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" -fi - -#--- Configure - -echo "travis_fold:start:configure" -printf "$ANSI_YELLOW[GHDL] Configure $ANSI_NOCOLOR\n" - -CDIR=$(pwd) -prefix="$CDIR/install-$BLD" -mkdir "$prefix" -mkdir "build-$BLD" -cd "build-$BLD" - -case "$BLD" in - mcode) - config_opts="" ;; - llvm) - config_opts="--with-llvm-config" ;; - llvm-3.5) - config_opts="--with-llvm-config=llvm-config-3.5 CXX=clang++" ;; - llvm-3.8) - config_opts="--with-llvm-config=llvm-config-3.8 CXX=clang++-3.8" ;; - docker) - echo "Check docker container!" - exit 0;; - *) - echo "$ANSI_RED[GHDL - build] Unknown build $BLD $ANSI_NOCOLOR" - exit 1;; -esac -echo "../configure --prefix=$prefix $config_opts" -../configure "--prefix=$prefix" $config_opts -echo "travis_fold:end:configure" - -#--- make - -echo "travis_fold:start:make" -travis_time_start -printf "$ANSI_YELLOW[GHDL] Make $ANSI_NOCOLOR\n" -make -travis_time_finish -echo "travis_fold:end:make" - -echo "travis_fold:start:install" -printf "$ANSI_YELLOW[GHDL] Install $ANSI_NOCOLOR\n" -make install -cd .. -echo "travis_fold:end:install" - -#--- package - -echo "travis_fold:start:tar.bin" -printf "$ANSI_YELLOW[GHDL] Create package ${ANSI_DARKCYAN}${PKG_NAME}.tgz $ANSI_NOCOLOR\n" -tar -zcvf "${PKG_NAME}.tgz" -C "$prefix" . -echo "travis_fold:end:tar.bin" - -#--- test - -export ENABLECOLOR TASK -export GHDL="$prefix/bin/ghdl" -cd testsuite -failures="" - -echo "travis_fold:start:tests.sanity" -travis_time_start -printf "$ANSI_YELLOW[Test] sanity $ANSI_NOCOLOR\n" -cd sanity -for d in [0-9]*; do - cd $d - if ./testsuite.sh > test.log 2>&1 ; then - echo "sanity $d: ok" - # Don't disp log - else - echo "${ANSI_RED}sanity $d: failed${ANSI_NOCOLOR}" - cat test.log - failures="$failures $d" - fi - cd .. - # Stop at the first failure - [ "$failures" = "" ] || break -done -cd .. -travis_time_finish -echo "travis_fold:end:tests.sanity" -[ "$failures" = "" ] || exit 1 - -if [ "$ISGPL" != "true" ]; then - echo "travis_fold:start:tests.gna" - travis_time_start - printf "$ANSI_YELLOW[Test] gna $ANSI_NOCOLOR\n" - cd gna - dirs=`./testsuite.sh --list-tests` - for d in $dirs; do - cd $d - if ./testsuite.sh > test.log 2>&1 ; then - echo "gna $d: ok" - # Don't disp log - else - echo "${ANSI_RED}gna $d: failed${ANSI_NOCOLOR}" - cat test.log - failures="$failures $d" - fi - cd .. - # Stop at the first failure - [ "$failures" = "" ] || break - done - cd .. - travis_time_finish - echo "travis_fold:end:tests.gna" - [ "$failures" = "" ] || exit 1 -fi - -echo "travis_fold:start:tests.vests" -travis_time_start -printf "$ANSI_YELLOW[Test] vests $ANSI_NOCOLOR\n" -cd vests -if ./testsuite.sh > vests.log 2>&1 ; then - echo "${ANSI_GREEN}Vests is OK$ANSI_NOCOLOR" - wc -l vests.log -else - cat vests.log - echo "${ANSI_RED}Vests failure$ANSI_NOCOLOR" - failures=vests -fi -cd .. -travis_time_finish -echo "travis_fold:end:tests.vests" -[ "$failures" = "" ] || exit 1 - -$GHDL --version -cd .. - -#--- - -echo "[SUCCESSFUL]" -touch build_ok diff --git a/dist/linux/create.sh b/dist/linux/create.sh new file mode 100644 index 000000000..aed834fa0 --- /dev/null +++ b/dist/linux/create.sh @@ -0,0 +1,24 @@ +#! /bin/sh +# This script is executed in the travis-ci environment. + +set -e + +. dist/linux/travis-utils.sh +. dist/ansi_color.sh +#disable_color + +scriptdir=$(dirname $0) + +for d in build run; do + currentdir="${scriptdir}/docker/$d" + for f in `ls $currentdir`; do + for tag in `grep -oP "FROM.*AS \K.*" ${currentdir}/$f`; do + echo "travis_fold:start:${f}-$tag" + travis_time_start + printf "$ANSI_BLUE[DOCKER build] ${d} : ${f} - ${tag}$ANSI_NOCOLOR\n" + docker build -t ghdl/${d}:${f}-${tag} --target $tag - < ${currentdir}/$f + travis_time_finish + echo "travis_fold:end:${f}-$tag" + done + done +done diff --git a/dist/linux/deploy2dockerhub.sh b/dist/linux/deploy2dockerhub.sh new file mode 100755 index 000000000..63b9fc8d9 --- /dev/null +++ b/dist/linux/deploy2dockerhub.sh @@ -0,0 +1,32 @@ +#! /bin/sh + +set -e + +. dist/linux/travis-utils.sh +. dist/ansi_color.sh +#disable_color + +# Skip deploy if we are in stage 0 (i.e. IMAGE="") and there is no '[ci images]' in the commit message +if [ "$1" = "skip" ] || [ "${1}$(echo $2 | grep -o '\[ci images\]')" = "" ]; then + printf "${ANSI_GREEN}SKIP DEPLOY2DOCKERHUB$ANSI_NOCOLOR\n"; + exit 0; +fi + +case $1 in + "") FILTER="/";; + *) FILTER="/ghdl /pkg";; +esac + +docker login -u="$DOCKER_USER" -p="$DOCKER_PASS" +for key in $FILTER; do + for tag in `echo $(docker images ghdl$key* | awk -F ' ' '{print $1 ":" $2}') | cut -d ' ' -f2-`; do + if [ "$tag" = "REPOSITORY:TAG" ]; then break; fi + echo "travis_fold:start:`echo $tag | grep -oP 'ghdl/\K.*'`" + travis_time_start + printf "$ANSI_YELLOW[DOCKER push] ${tag}$ANSI_NOCOLOR\n" + docker push $tag + travis_time_finish + echo "travis_fold:end:`echo $tag | grep -oP 'ghdl/\K.*'`" + done +done +docker logout diff --git a/dist/linux/docker/build-fedora26+mcode b/dist/linux/docker/build-fedora26+mcode deleted file mode 100644 index fb0aaee9d..000000000 --- a/dist/linux/docker/build-fedora26+mcode +++ /dev/null @@ -1,5 +0,0 @@ -# Fedora 26 -FROM fedora:26 - -RUN dnf --nodocs -y install gcc-gnat zlib-devel make \ - && dnf clean all diff --git a/dist/linux/docker/build-stretch+mcode b/dist/linux/docker/build-stretch+mcode deleted file mode 100644 index 2830f0769..000000000 --- a/dist/linux/docker/build-stretch+mcode +++ /dev/null @@ -1,7 +0,0 @@ -# Debian 9 -FROM debian:stretch-slim - -RUN apt-get update -qq \ - && apt-get -y install --no-install-recommends \ - gnat gcc make zlib1g-dev \ - && apt-get clean diff --git a/dist/linux/docker/build-stretch+mcode+gpl b/dist/linux/docker/build-stretch+mcode+gpl deleted file mode 100644 index 2830f0769..000000000 --- a/dist/linux/docker/build-stretch+mcode+gpl +++ /dev/null @@ -1,7 +0,0 @@ -# Debian 9 -FROM debian:stretch-slim - -RUN apt-get update -qq \ - && apt-get -y install --no-install-recommends \ - gnat gcc make zlib1g-dev \ - && apt-get clean diff --git a/dist/linux/docker/build-ubuntu14+llvm-3.8 b/dist/linux/docker/build-ubuntu14+llvm-3.8 deleted file mode 100644 index e90ab7bbc..000000000 --- a/dist/linux/docker/build-ubuntu14+llvm-3.8 +++ /dev/null @@ -1,7 +0,0 @@ -# Ubuntu 14 -FROM ubuntu:trusty - -RUN apt-get update -qq \ - && apt-get -y install --no-install-recommends \ - gnat gcc make zlib1g-dev llvm-3.8-dev clang-3.8 \ - && apt-get clean diff --git a/dist/linux/docker/build-ubuntu14+mcode b/dist/linux/docker/build-ubuntu14+mcode deleted file mode 100644 index 6756dc35f..000000000 --- a/dist/linux/docker/build-ubuntu14+mcode +++ /dev/null @@ -1,7 +0,0 @@ -# Ubuntu 14 -FROM ubuntu:trusty - -RUN apt-get update -qq \ - && apt-get -y install --no-install-recommends \ - gnat gcc make zlib1g-dev \ - && apt-get clean diff --git a/dist/linux/docker/build/buster b/dist/linux/docker/build/buster new file mode 100644 index 000000000..776b51485 --- /dev/null +++ b/dist/linux/docker/build/buster @@ -0,0 +1,11 @@ +# [build] Debian 10 + +FROM debian:buster-slim AS mcode + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + gnat gcc make zlib1g-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove + + +FROM mcode AS mcode-gpl diff --git a/dist/linux/docker/build/fedora26 b/dist/linux/docker/build/fedora26 new file mode 100644 index 000000000..dfbf99a6c --- /dev/null +++ b/dist/linux/docker/build/fedora26 @@ -0,0 +1,12 @@ +# [build] Fedora 26 + +FROM fedora:26 AS mcode + +RUN dnf --nodocs -y install gcc-gnat zlib-devel make \ + && dnf clean all --enablerepo=\* + + +FROM mcode AS llvm + +RUN dnf --nodocs -y install llvm-devel gcc-c++ clang \ + && dnf clean all --enablerepo=\* diff --git a/dist/linux/docker/build/stretch b/dist/linux/docker/build/stretch new file mode 100644 index 000000000..9803a5619 --- /dev/null +++ b/dist/linux/docker/build/stretch @@ -0,0 +1,11 @@ +# [build] Debian 9 + +FROM debian:stretch-slim AS mcode + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + gnat gcc make zlib1g-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove + + +FROM mcode AS mcode-gpl diff --git a/dist/linux/docker/build/ubuntu14 b/dist/linux/docker/build/ubuntu14 new file mode 100644 index 000000000..924fd7297 --- /dev/null +++ b/dist/linux/docker/build/ubuntu14 @@ -0,0 +1,16 @@ +# [build] Ubuntu 14 + +FROM ubuntu:trusty AS mcode + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + gnat gcc make zlib1g-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove + + +FROM mcode AS llvm-3.8 + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + llvm-3.8-dev clang-3.8 \ + && apt-get autoclean && apt-get clean && apt-get autoremove diff --git a/dist/linux/docker/build/ubuntu16 b/dist/linux/docker/build/ubuntu16 new file mode 100644 index 000000000..308377e19 --- /dev/null +++ b/dist/linux/docker/build/ubuntu16 @@ -0,0 +1,16 @@ +# [build] Ubuntu 16 + +FROM ubuntu:xenial AS mcode + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + gnat gcc make zlib1g-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove + + +FROM mcode AS llvm-3.9 + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + llvm-3.9-dev clang-3.9 \ + && apt-get autoclean && apt-get clean && apt-get autoremove diff --git a/dist/linux/docker/build/ubuntu18 b/dist/linux/docker/build/ubuntu18 new file mode 100644 index 000000000..ac514a554 --- /dev/null +++ b/dist/linux/docker/build/ubuntu18 @@ -0,0 +1,16 @@ +# [build] Ubuntu 18 + +FROM ubuntu:bionic AS mcode + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + gnat gcc make zlib1g-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove + + +FROM mcode AS llvm-5.0 + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + llvm-5.0-dev clang-5.0 \ + && apt-get autoclean && apt-get clean && apt-get autoremove diff --git a/dist/linux/docker/run/buster b/dist/linux/docker/run/buster new file mode 100644 index 000000000..ff5bbf3da --- /dev/null +++ b/dist/linux/docker/run/buster @@ -0,0 +1,10 @@ +# [run] Debian 10 + +FROM debian:buster-slim AS mcode + +RUN apt-get update -qq \ + && apt-get -y install libgnat-7 gcc libc6-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove + + +FROM mcode AS mcode-gpl diff --git a/dist/linux/docker/run/fedora26 b/dist/linux/docker/run/fedora26 new file mode 100644 index 000000000..ff0e17bc2 --- /dev/null +++ b/dist/linux/docker/run/fedora26 @@ -0,0 +1,12 @@ +# [run] Fedora 26 + +FROM fedora:26 AS mcode + +RUN dnf --nodocs -y install libgnat gcc \ + && dnf clean all --enablerepo=\* + + +FROM mcode AS llvm + +RUN dnf --nodocs -y install llvm-libs zlib-devel \ + && dnf clean all --enablerepo=\* diff --git a/dist/linux/docker/run/stretch b/dist/linux/docker/run/stretch new file mode 100644 index 000000000..1d42722eb --- /dev/null +++ b/dist/linux/docker/run/stretch @@ -0,0 +1,10 @@ +# [run] Debian 9 + +FROM debian:stretch-slim AS mcode + +RUN apt-get update -qq \ + && apt-get -y install libgnat-6 gcc libc6-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove + + +FROM mcode AS mcode-gpl diff --git a/dist/linux/docker/run/ubuntu14 b/dist/linux/docker/run/ubuntu14 new file mode 100644 index 000000000..6c72d9c19 --- /dev/null +++ b/dist/linux/docker/run/ubuntu14 @@ -0,0 +1,16 @@ +# [run] Ubuntu 14 + +FROM ubuntu:trusty AS mcode + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + libgnat-4.6 gcc libc6-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove + + +FROM mcode AS llvm-3.8 + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + libllvm-3.8 zlib1g-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove diff --git a/dist/linux/docker/run/ubuntu16 b/dist/linux/docker/run/ubuntu16 new file mode 100644 index 000000000..2bccad554 --- /dev/null +++ b/dist/linux/docker/run/ubuntu16 @@ -0,0 +1,16 @@ +# [run] Ubuntu 16 + +FROM ubuntu:xenial AS mcode + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + libgnat-4.9 gcc libc6-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove + + +FROM mcode AS llvm-3.9 + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + libllvm-3.9 zlib1g-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove diff --git a/dist/linux/docker/run/ubuntu18 b/dist/linux/docker/run/ubuntu18 new file mode 100644 index 000000000..1b2f956ac --- /dev/null +++ b/dist/linux/docker/run/ubuntu18 @@ -0,0 +1,16 @@ +# [run] Ubuntu 18 + +FROM ubuntu:bionic AS mcode + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + libgnat-7 gcc libc6-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove + + +FROM mcode AS llvm-5.0 + +RUN apt-get update -qq \ + && apt-get -y install --no-install-recommends \ + libllvm5.0 zlib1g-dev \ + && apt-get autoclean && apt-get clean && apt-get autoremove diff --git a/dist/linux/test.sh b/dist/linux/test.sh new file mode 100755 index 000000000..f2eb4e176 --- /dev/null +++ b/dist/linux/test.sh @@ -0,0 +1,114 @@ +#! /bin/bash + +. dist/linux/travis-utils.sh +. dist/ansi_color.sh +disable_color + +echo "$0" "$@" + +# Stop in case of error +set -e + +# Transform long options to short ones +for arg in "$@"; do + shift + case "$arg" in + "--color"|"-color") set -- "$@" "-c";; + "--gpl"|"-gpl") set -- "$@" "-g";; + *) set -- "$@" "$arg" + esac +done +# Parse args +while getopts ":b:p:cg" opt; do + case $opt in + c) enable_color;; + g) ISGPL=true;; + \?) printf "$ANSI_RED[GHDL - test] Invalid option: -$OPTARG $ANSI_NOCOLOR\n" >&2 + exit 1 ;; + :) printf "$ANSI_RED[GHDL - test] Option -$OPTARG requires an argument. $ANSI_NOCOLOR\n" >&2 + exit 1 ;; + esac +done + +rm -f test_ok + +export ENABLECOLOR TASK +if [ "$GHDL" = "" ]; then + export GHDL="$prefix/bin/ghdl" +fi +cd testsuite +failures="" + +echo "travis_fold:start:tests.sanity" +travis_time_start +printf "$ANSI_YELLOW[GHDL - test] sanity $ANSI_NOCOLOR\n" +cd sanity +for d in [0-9]*; do + cd $d + if ./testsuite.sh > test.log 2>&1 ; then + echo "sanity $d: ok" + # Don't disp log + else + echo "${ANSI_RED}sanity $d: failed${ANSI_NOCOLOR}" + cat test.log + failures="$failures $d" + fi + cd .. + # Stop at the first failure + [ "$failures" = "" ] || break +done +cd .. +travis_time_finish +echo "travis_fold:end: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" + cd gna + dirs=`./testsuite.sh --list-tests` + for d in $dirs; do + cd $d + if ./testsuite.sh > test.log 2>&1 ; then + echo "gna $d: ok" + # Don't disp log + else + echo "${ANSI_RED}gna $d: failed${ANSI_NOCOLOR}" + cat test.log + failures="$failures $d" + fi + cd .. + # Stop at the first failure + [ "$failures" = "" ] || break + done + cd .. + travis_time_finish + echo "travis_fold:end:tests.gna" + [ "$failures" = "" ] || exit 1 +fi + +echo "travis_fold:start:tests.vests" +travis_time_start +printf "$ANSI_YELLOW[GHDL - test] vests $ANSI_NOCOLOR\n" +cd vests +if ./testsuite.sh > vests.log 2>&1 ; then + echo "${ANSI_GREEN}Vests is OK$ANSI_NOCOLOR" + wc -l vests.log +else + cat vests.log + echo "${ANSI_RED}Vests failure$ANSI_NOCOLOR" + failures=vests +fi +cd .. +travis_time_finish +echo "travis_fold:end:tests.vests" +[ "$failures" = "" ] || exit 1 + +$GHDL --version +cd .. + +#--- + +echo "[SUCCESSFUL]" +touch test_ok diff --git a/dist/linux/travis-ci.sh b/dist/linux/travis-ci.sh index 0c21ed545..d423db9e6 100755 --- a/dist/linux/travis-ci.sh +++ b/dist/linux/travis-ci.sh @@ -1,11 +1,34 @@ #! /bin/bash # 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" +} + +#--- + set -e +. dist/linux/travis-utils.sh . dist/ansi_color.sh #disable_color +scriptdir=$(dirname $0) + # Display env (to debug) @@ -14,6 +37,14 @@ printf "$ANSI_YELLOW[TRAVIS] Travis environment $ANSI_NOCOLOR\n" env | grep TRAVIS echo -en "travis_fold:end:travis_env\r" + +if [ "$IMAGE" = "" ]; then + echo "IMAGE not defined" + exit 1 +fi + + +echo "travis_fold:start:patch_version" # 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 @@ -22,6 +53,8 @@ git fetch --unshallow || true # correctly set). make -f Makefile.in srcdir=. version.tmp cp version.tmp src/version.in +echo "travis_fold:end:patch_version" + # Compute package name @@ -37,25 +70,21 @@ else PKG_TAG="$TRAVIS_TAG" fi -if [ "$IMAGE" = "" ]; then - echo "IMAGE not defined" - exit 1 -fi - IFS='+' read -ra REFS <<< "$IMAGE" DDIST=${REFS[0]} DBLD=${REFS[1]} DGPL=${REFS[2]} PKG_NAME="ghdl-${PKG_TAG}-${DBLD}-${DDIST}" -BUILD_CMD="./dist/linux/buildtest.sh $ENABLECOLOR -b $DBLD" +BUILD_CMD_OPTS="$ENABLECOLOR -b $DBLD" if [ "$DGPL" = "gpl" ]; then - BUILD_CMD="$BUILD_CMD --gpl" + BUILD_CMD_OPTS="$BUILD_CMD_OPTS --gpl" PKG_NAME="ghdl-gpl-${PKG_TAG}" fi -BUILD_CMD="${BUILD_CMD} -p $PKG_NAME" +BUILD_CMD_OPTS="${BUILD_CMD_OPTS} -p $PKG_NAME" + +echo "build cmd: $BUILD_CMD_OPTS" -echo "build cmd: $BUILD_CMD" # Build @@ -64,37 +93,33 @@ if [ "$TRAVIS_OS_NAME" = "osx" ]; then ./dist/macosx/install-ada.sh || exit 1 PATH=$PWD/gnat/bin:$PATH - bash -c "$BUILD_CMD" + bash -c "${scriptdir}/build.sh $BUILD_CMD_OPTS" else # Assume linux - # Create docker image - - . ./dist/linux/travis-utils.sh - - echo "travis_fold:start:create" - travis_time_start - printf "$ANSI_YELLOW[DOCKER build] Docker build $ANSI_NOCOLOR\n" - - DOCKERFILE="dist/linux/docker/build-$IMAGE" - - echo "dockerfile: $DOCKERFILE" - DOCKER_NAME=`echo $IMAGE | sed -e 's/+/-/g'` + # 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" +fi - docker build -t $DOCKER_NAME - < $DOCKERFILE - travis_time_finish - echo "travis_fold:end:create" +if [ ! -f build_ok ]; then + printf "$ANSI_RED[TRAVIS] BUILD failed $ANSI_NOCOLOR\n" + exit 1 +fi - # Run build+test in docker +# Test - docker run --rm --tty --volume $(pwd):/work -w "/work" $DOCKER_NAME bash -c "$BUILD_CMD" +if [ "$TRAVIS_OS_NAME" = "osx" ]; then + bash -c "prefix=$(realpath ./install-mcode) ${scriptdir}/test.sh $BUILD_CMD_OPTS" +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" fi - -ls -l ghdl-* - -if [ ! -f build_ok ]; then - printf "$ANSI_RED[TRAVIS] BUILD failed $ANSI_NOCOLOR\n" +if [ ! -f test_ok ]; then + printf "$ANSI_RED[TRAVIS] TEST failed $ANSI_NOCOLOR\n" exit 1 fi diff --git a/dist/linux/travis-enc-dockerhub.sh b/dist/linux/travis-enc-dockerhub.sh new file mode 100755 index 000000000..a677f8039 --- /dev/null +++ b/dist/linux/travis-enc-dockerhub.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# - Run `$(command -v winpty) docker run --rm -it alpine sh -c "REPO='https://github.com/<user|organization>/<repo>'; USERNAME=<username>; PASSWORD=<password>; $(cat travis-enc.sh)"` +# - Check the log and copy the secure key to `.travis.yml`: https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml + +apk add -U --no-cache git openssh ruby ruby-dev libffi-dev build-base ruby-dev libc-dev libffi-dev linux-headers +gem install travis --no-rdoc --no-ri + +git clone $REPO ./tmp-repo && cd tmp-repo + +travis login --org --auto +travis encrypt DOCKER_USER=$USERNAME +travis encrypt DOCKER_PASS=$PASSWORD diff --git a/dist/linux/travis-utils.sh b/dist/linux/travis-utils.sh index 3f644c930..8db013f7b 100644 --- a/dist/linux/travis-utils.sh +++ b/dist/linux/travis-utils.sh @@ -1,7 +1,8 @@ # 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() { - travis_timer_id=$RANDOM + # `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" } |