diff options
author | 1138-4EB <1138-4EB@users.noreply.github.com> | 2019-11-21 17:39:24 +0000 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2019-11-21 18:39:24 +0100 |
commit | e506f77e8f6ddeb3e114a3b7e3ce5f114192d801 (patch) | |
tree | d9387c5867ba98c81988591713249915230db9e3 /dist | |
parent | 03862a4607fd127e6570a3e141a92265a23c2a68 (diff) | |
download | ghdl-e506f77e8f6ddeb3e114a3b7e3ce5f114192d801.tar.gz ghdl-e506f77e8f6ddeb3e114a3b7e3ce5f114192d801.tar.bz2 ghdl-e506f77e8f6ddeb3e114a3b7e3ce5f114192d801.zip |
Actions: add workflow 'push' (#1016)
* use CC=clang to build C sources on macOS
* actions: ensure that shared libs are in the PATH on windows
* ci: add GitHub Actions 'push' workflow
* ci: fix group labels
* dist: add GRAY to ansi_color
* ci: use same scripts for GHA and Travis
Diffstat (limited to 'dist')
-rw-r--r-- | dist/ansi_color.sh | 1 | ||||
-rwxr-xr-x | dist/ci-run.sh | 476 | ||||
-rwxr-xr-x | dist/man.sh (renamed from dist/travis/man.sh) | 2 | ||||
-rw-r--r-- | dist/msys2-mingw/llvm/PKGBUILD | 28 | ||||
-rw-r--r-- | dist/msys2-mingw/mcode/PKGBUILD | 28 | ||||
-rw-r--r-- | dist/msys2-mingw/run.sh | 123 | ||||
-rwxr-xr-x | dist/travis/build.sh | 167 | ||||
-rwxr-xr-x | dist/travis/travis-ci.sh | 110 | ||||
-rw-r--r-- | dist/travis/utils.sh | 107 |
9 files changed, 658 insertions, 384 deletions
diff --git a/dist/ansi_color.sh b/dist/ansi_color.sh index 6b81229c5..bb5c348bc 100644 --- a/dist/ansi_color.sh +++ b/dist/ansi_color.sh @@ -7,6 +7,7 @@ enable_color() { ANSI_YELLOW="\033[33m" ANSI_BLUE="\033[34m" ANSI_MAGENTA="\033[35m" + ANSI_GRAY="\033[90m" ANSI_CYAN="\033[36;1m" ANSI_DARKCYAN="\033[36m" ANSI_NOCOLOR="\033[0m" diff --git a/dist/ci-run.sh b/dist/ci-run.sh new file mode 100755 index 000000000..d6061edb2 --- /dev/null +++ b/dist/ci-run.sh @@ -0,0 +1,476 @@ +#! /bin/bash + +scriptdir=`dirname $0` + +if [ -n "$GITHUB_EVENT_PATH" ]; then + export CI=true +fi + +. "$scriptdir/ansi_color.sh" +disable_color + +print_start() { + COL="$ANSI_YELLOW" + if [ "x$2" != "x" ]; then + COL="$2" + fi + printf "${COL}${1}$ANSI_NOCOLOR\n" +} + +gstart () { + print_start "$@" +} +gend () { + : +} + +if [ -n "$TRAVIS" ]; then + echo "INFO: set 'gstart' and 'gend' for TRAVIS" + # 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 + + gstart () { + echo "travis_fold:start:group" + travis_time_start + print_start "$@" + } + + gend () { + travis_time_finish + echo "travis_fold:end:group" + } +else + if [ -n "$CI" ]; then + echo "INFO: set 'gstart' and 'gend' for CI" + gstart () { + printf '::group::' + print_start "$@" + SECONDS=0 + } + + gend () { + duration=$SECONDS + echo '::endgroup::' + printf "${ANSI_GRAY}took $(($duration / 60)) min $(($duration % 60)) sec.${ANSI_NOCOLOR}\n" + } + fi +fi + +echo "cliargs: $0 $@" + +# Stop in case of error +set -e + +ISGPL=false +ISSYNTH=false + +# Transform long options to short ones +for arg in "$@"; do + shift + case "$arg" in + "--color"|"-color") set -- "$@" "-c";; + "--backend"|"-backend") set -- "$@" "-b";; + "--pkg"|"-pkg") set -- "$@" "-p";; + "--gpl"|"-gpl") set -- "$@" "-g";; + "--synth"|"-synth") set -- "$@" "-s";; + *) set -- "$@" "$arg" + esac +done +# Parse args +while getopts ":b:p:cgs" opt; do + case $opt in + c) enable_color;; + b) BACK=$OPTARG ;; + p) PKG_NAME=$OPTARG;; + g) ISGPL=true;; + s) ISSYNTH=true;; + \?) printf "$ANSI_RED[CI - args] Invalid option: -$OPTARG $ANSI_NOCOLOR\n" >&2 + exit 1 ;; + :) printf "$ANSI_RED[CI - args] Option -$OPTARG requires an argument. $ANSI_NOCOLOR\n" >&2 + exit 1 ;; + esac +done +shift $((OPTIND -1)) + +#--- + +# +# Build command options +# + +notag() { + # No tag: use date + commit id + echo "`git log -1 --date=short --pretty=format:%cd | sed 's/-//g'`-$PKG_SHA" +} + +vertag() { + if expr "$1" : 'v[0-9].*' > /dev/null; then + # Remove leading 'v' in tags in the filenames. + echo $1 | cut -c2- + # Check version defined in configure. + if [ "x$1" != "x`grep "^ghdl_version=" configure | sed -e 's/.*"\(.*\)";/\1/'`" ]; then + printf "${ANSI_RED}Tag '$1' does not match 'ghdl_version'!${ANSI_NOCOLOR}\n" 1>&2; + exit 1 + fi + else + # Regular tag (like snapshots), nothing to change. + echo "$2" + fi +} + +buildCmdOpts () { + BUILD_ARG="$1" + + # Get short commit SHA + if [ -n "$TRAVIS_COMMIT" ]; then + GIT_SHA="$TRAVIS_COMMIT" + fi + if [ -n "$GITHUB_SHA" ]; then + GIT_SHA="$GITHUB_SHA" + fi + if [ -z "$GIT_SHA" ]; then + GIT_SHA="`git rev-parse --verify HEAD`" + fi + PKG_SHA="`printf $GIT_SHA | cut -c1-10`" + + echo "TRAVIS_COMMIT: $TRAVIS_COMMIT" + echo "TRAVIS_TAG: $TRAVIS_TAG" + echo "GITHUB_SHA: $GITHUB_SHA" + echo "GITHUB_REF: $GITHUB_REF" + echo "GIT_SHA: $GIT_SHA" + + # Compute package name + case "$GITHUB_REF" in + *tags*) + PKG_TAG="$(vertag "`echo "$GITHUB_REF" | sed 's#^refs/tags/\(.*\)#\1#g'`" "$GITHUB_REF")" + ;; + *heads*|*pull*) + PKG_TAG="`notag`" + ;; + "") + if [ -z "$TRAVIS_TAG" ]; then + PKG_TAG="`notag`" + else + PKG_TAG="`vertag "$TRAVIS_TAG" "$TRAVIS_TAG"`" + fi + ;; + *) + PKG_TAG="$GITHUB_REF" + ;; + esac + + echo "PKG_SHA: $PKG_SHA" + echo "PKG_TAG: $PKG_TAG" + + # Extract from BUILD_ARG + IFS='+' read -ra REFS <<< "$BUILD_ARG" + DDIST=${REFS[0]} # Linux distro (eg: ubuntuXX, fedoraXX) + DBACK=${REFS[1]} # Build/backend (eg: mcode, llvm) + + PKG_NAME="ghdl-${PKG_TAG}-${DDIST}-${DBACK}" + BUILD_CMD_OPTS="$ENABLECOLOR -b $DBACK" + + if [ "x$ISGPL" = "xtrue" ]; then + BUILD_CMD_OPTS="$BUILD_CMD_OPTS --gpl" + PKG_NAME="${PKG_NAME}-gpl" + DEXT="-gpl" + fi + if [ "x$ISSYNTH" = "xtrue" ]; then + BUILD_CMD_OPTS="$BUILD_CMD_OPTS --synth" + PKG_NAME="${PKG_NAME}-synth" + DEXT="-synth" + fi + export BUILD_CMD_OPTS="${BUILD_CMD_OPTS} -p $PKG_NAME" + + GHDL_IMAGE_TAG="`echo $BUILD_ARG | sed -e 's/+/-/g'`" + BUILD_IMAGE_TAG="$GHDL_IMAGE_TAG" + + case $BUILD_ARG in + *gcc*) + BUILD_IMAGE_TAG="`echo $GHDL_IMAGE_TAG | sed 's#\(.*\)-gcc.*#\1-gcc#g'`" + ;; + esac + + GHDL_IMAGE_TAG="${GHDL_IMAGE_TAG}$DEXT" +} + +run_cmd() { + echo "$@" + "$@" +} + +# +# Build ghdl +# + +build () { + rm -f build_ok + + #--- Env + + gstart "[GHDL - build] Environment" + env + gend + + #--- GPL: gpl-ize sources + + if [ "$ISGPL" = "true" ]; then + GPLDIR="${PKG_NAME}.src" + gstart "[GHDL - build] create GPL source package (${ANSI_CYAN}${GPLDIR}.tgz${ANSI_NOCOLOR})" + files=`echo *` + make -f Makefile.in srcdir=. clean-pure-gpl + mkdir "$GPLDIR" + cp -pdrl $files "$GPLDIR" + tar -zcf "${GPLDIR}.tgz" "$GPLDIR" + gend + fi + + #--- Configure + + CDIR=`pwd` + export prefix="$CDIR/install-$BACK" + mkdir "$prefix" + mkdir "build-$BACK" + cd "build-$BACK" + + if [ "x$ISSYNTH" = "xtrue" ]; then + CONFIG_OPTS+=" --enable-synth" + fi + + case "$BACK" in + gcc*) + gstart "[GHDL - build] Get gcc sources" + echo "https://github.com/gcc-mirror/gcc/archive/`echo ${BACK} | sed -e 's/\./_/g'`-release.tar.gz" + mkdir gcc-srcs + curl -L "https://github.com/gcc-mirror/gcc/archive/`echo ${BACK} | sed -e 's/\./_/g'`-release.tar.gz" | tar -xz -C gcc-srcs --strip-components=1 + cd gcc-srcs + sed -i.bak s/ftp:/http:/g ./contrib/download_prerequisites + ./contrib/download_prerequisites + cd .. + gend + + gstart "[GHDL - build] Configure ghdl" + run_cmd ../configure --with-gcc=gcc-srcs --prefix="$prefix" $CONFIG_OPTS + gend + gstart "[GHDL - build] Copy sources" + make copy-sources + mkdir gcc-objs; cd gcc-objs + gend + gstart "[GHDL - build] Configure gcc" + run_cmd ../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`" + gend + ;; + mcode) + 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-*) + llvmver=`echo $BACK | sed -e "s/llvm-//"` + CXX="clang++-$llvmver" + CONFIG_OPTS+=" --with-llvm-config=llvm-config-$llvmver CXX=$CXX" + ;; + *) + printf "$ANSI_RED[GHDL - build] Unknown build $BACK $ANSI_NOCOLOR\n" + exit 1;; + esac + + if [ ! "`echo $BACK | grep gcc`" ]; then + gstart "[GHDL - build] Configure" + run_cmd ../configure "--prefix=$prefix" $CONFIG_OPTS + gend + fi + + #--- make + + gstart "[GHDL - build] Make" + set +e + make LIB_CFLAGS="$LIB_CFLAGS" OPT_FLAGS="$OPT_FLAGS" -j`nproc` 2>make_err.log + tail -1000 make_err.log + set -e + gend + + gstart "[GHDL - build] Install" + make install + cd .. + gend + + if [ "`echo $BACK | grep gcc`" ]; then + gstart "[GHDL - build] Make ghdllib" + make ghdllib + gend + + gstart "[GHDL - build] Install ghdllib" + make install + cd .. + gend + fi + + #--- package + + gstart "[GHDL - build] Create package ${ANSI_DARKCYAN}${PKG_NAME}.tgz" + tar -zcvf "${PKG_NAME}.tgz" -C "$prefix" . + gend + + #--- build tools versions + + { + make --version | grep 'Make' + gnatls --version | grep 'GNATLS' + gcc --version | grep 'gcc' + if [ "$CXX" != "" ]; then + $CXX --version | grep 'clang' + fi + } > BUILD_TOOLS + + #--- + + printf "$ANSI_GREEN[GHDL - build] SUCCESSFUL${ANSI_NOCOLOR}\n" + touch build_ok +} + +# +# Build ghdl/ghdl image +# + +build_img_ghdl() { + gstart "[DOCKER - build] ghdl/ghdl:${GHDL_IMAGE_TAG}" "$ANSI_BLUE" + docker build -t ghdl/ghdl:$GHDL_IMAGE_TAG . -f-<<EOF +FROM ghdl/run:$BUILD_IMAGE_TAG +ADD `ls | grep -v '\.src\.' | grep '^ghdl.*\.tgz'` /usr/local +EOF + gend +} + +# +# Full CI run +# + +ci_run () { + if [ "x$TASK" = "x" ]; then + if [ "x$1" = "x" ]; then + printf "${ANSI_RED}TASK not defined${ANSI_NOCOLOR}\n" + exit 1 + else + TASK="$1" + fi + fi + + gstart "[CI] git fetch --unshallow" "$ANSI_BLUE" + # 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 + gend + + if [ "x$IS_MACOS" = "xtrue" ]; then + gstart "[CI] Install gnat compiler (use cache) and set CPATH" "$ANSI_BLUE" + ./dist/macosx/install-ada.sh || exit 1 + PATH=$PWD/gnat/bin:$PATH + export CPATH="$CPATH:`xcrun --show-sdk-path`/usr/include" + gend + fi + + # Get build command options + gstart "[CI] Get build command options" "$ANSI_BLUE" + buildCmdOpts "$TASK" + echo "build cmd: $BUILD_CMD_OPTS" + gend + + # Build + + RUN="docker run --rm -t -e CI -e TRAVIS -v `pwd`:/work -w /work" + if [ "x$IS_MACOS" = "xtrue" ]; then + CC=clang CONFIG_OPTS="--disable-libghdl" bash -c "${scriptdir}/ci-run.sh $BUILD_CMD_OPTS build" + else + # Assume linux + + gstart "[CI] Build version.tmp and replace version.in with it (so that the version is correctly set)" "$ANSI_BLUE" + # 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 + gend + + gstart "[CI] Docker pull ghdl/build:$BUILD_IMAGE_TAG" "$ANSI_BLUE" + docker pull ghdl/build:$BUILD_IMAGE_TAG + gend + + printf "$ANSI_BLUE[CI] Build ghdl in docker image ghdl/build:$BUILD_IMAGE_TAG\n" + $RUN -e CONFIG_OPTS="$CONFIG_OPTS" "ghdl/build:$BUILD_IMAGE_TAG" bash -c "${scriptdir}/ci-run.sh $BUILD_CMD_OPTS build" + fi + + if [ ! -f build_ok ]; then + printf "${ANSI_RED}[GHDL - build] FAILED${ANSI_NOCOLOR}\n" + exit 1 + fi + + # Test + + if [ "x$IS_MACOS" = "xtrue" ]; then + CC=clang prefix="`cd ./install-mcode; pwd`" ./testsuite/testsuite.sh sanity gna vests + else + # Build ghdl/ghdl:$GHDL_IMAGE_TAG image + build_img_ghdl + # Run test in docker container + tests="sanity" + if [ "x$ISGPL" != "xtrue" ]; then + tests="$tests gna" + fi + tests="$tests vests" + if [ "x$ISSYNTH" = "xtrue" ]; then + tests="$tests synth" + fi + $RUN "ghdl/ghdl:$GHDL_IMAGE_TAG" bash -c "GHDL=ghdl ./testsuite/testsuite.sh $tests" + fi + + if [ ! -f testsuite/test_ok ]; then + printf "${ANSI_RED}[GHDL - test] FAILED${ANSI_NOCOLOR}\n" + exit 1 + fi +} + +#--- + +echo "command: $0 $@" + +unset IS_MACOS +if [ "$GITHUB_OS" = "macOS" ] || [ "$TRAVIS_OS_NAME" = "osx" ]; then + IS_MACOS="true" +fi + +case "$1" in + build) + build + ;; + *) + ci_run + ;; +esac diff --git a/dist/travis/man.sh b/dist/man.sh index ab00cb4c9..5244e49a7 100755 --- a/dist/travis/man.sh +++ b/dist/man.sh @@ -1,5 +1,7 @@ #! /bin/bash +cd $(dirname $0)/.. + rm -rf doc/_build/man/* set -e diff --git a/dist/msys2-mingw/llvm/PKGBUILD b/dist/msys2-mingw/llvm/PKGBUILD new file mode 100644 index 000000000..0f6ebf9af --- /dev/null +++ b/dist/msys2-mingw/llvm/PKGBUILD @@ -0,0 +1,28 @@ +_realname=ghdl-llvm +pkgbase=mingw-w64-${_realname} +pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}") +pkgver=ci +pkgrel=1 +pkgdesc="GHDL: the open-source analyzer, compiler and simulator for VHDL (LLVM backend) (mingw-w64)" +arch=('any') +#depends=() +makedepends=("${MINGW_PACKAGE_PREFIX}-clang" "${MINGW_PACKAGE_PREFIX}-gcc-ada") +#source=( +# "ghdl::git://github.com/ghdl/ghdl.git#branch=master" +#) +#sha512sums=( +# 'SKIP' +#) + +build() { + mkdir "${srcdir}/builddir" + cd "${srcdir}/builddir" + ../../../../../configure --prefix=${MINGW_PREFIX} --with-llvm-config LDFLAGS=-static --enable-libghdl --enable-synth + make GNATMAKE="gnatmake -j$(nproc)" +} + +package() { + cd "${srcdir}/builddir" + mkdir -p "${pkgdir}${MINGW_PREFIX}/lib" + make DESTDIR="${pkgdir}" install +} diff --git a/dist/msys2-mingw/mcode/PKGBUILD b/dist/msys2-mingw/mcode/PKGBUILD new file mode 100644 index 000000000..591fa6693 --- /dev/null +++ b/dist/msys2-mingw/mcode/PKGBUILD @@ -0,0 +1,28 @@ +_realname=ghdl-mcode +pkgbase=mingw-w64-${_realname} +pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}") +pkgver=ci +pkgrel=1 +pkgdesc="GHDL: the open-source analyzer, compiler and simulator for VHDL (mcode backend) (mingw-w64)" +arch=('any') +#depends=() +makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-gcc-ada") +#source=( +# "ghdl::git://github.com/ghdl/ghdl.git#branch=master" +#) +#sha512sums=( +# 'SKIP' +#) + +build() { + mkdir "${srcdir}/builddir" + cd "${srcdir}/builddir" + ../../../../../configure --prefix=${MINGW_PREFIX} LDFLAGS=-static --enable-libghdl --enable-synth + make GNATMAKE="gnatmake -j$(nproc)" +} + +package() { + cd "${srcdir}/builddir" + mkdir -p "${pkgdir}${MINGW_PREFIX}/lib" + make DESTDIR="${pkgdir}" install +} diff --git a/dist/msys2-mingw/run.sh b/dist/msys2-mingw/run.sh new file mode 100644 index 000000000..42af62b19 --- /dev/null +++ b/dist/msys2-mingw/run.sh @@ -0,0 +1,123 @@ +#!/bin/sh + +# Stop in case of error +set -e + +enable_color() { + ENABLECOLOR='-c ' + ANSI_RED="\033[31m" + ANSI_GREEN="\033[32m" + ANSI_YELLOW="\033[33m" + ANSI_BLUE="\033[34m" + ANSI_MAGENTA="\033[35m" + ANSI_GRAY="\033[90m" + ANSI_CYAN="\033[36;1m" + ANSI_DARKCYAN="\033[36m" + ANSI_NOCOLOR="\033[0m" +} + +disable_color() { unset ENABLECOLOR ANSI_RED ANSI_GREEN ANSI_YELLOW ANSI_BLUE ANSI_MAGENTA ANSI_CYAN ANSI_DARKCYAN ANSI_NOCOLOR; } +enable_color + +print_start() { + if [ "x$2" != "x" ]; then + COL="$2" + elif [ "x$BASE_COL" != "x" ]; then + COL="$BASE_COL" + else + COL="$ANSI_YELLOW" + fi + printf "${COL}${1}$ANSI_NOCOLOR\n" +} + +gstart () { + print_start "$@" +} +gend () { + : +} + +[ -n "$CI" ] && { + echo "INFO: set 'gstart' and 'gend' for CI" + gstart () { + printf '::group::' + print_start "$@" + SECONDS=0 + } + + gend () { + duration=$SECONDS + echo '::endgroup::' + printf "${ANSI_GRAY}took $(($duration / 60)) min $(($duration % 60)) sec.${ANSI_NOCOLOR}\n" + } +} || echo "INFO: not in CI" + +#--- + +cd $(dirname $0) + +build () { + gstart 'Install common build dependencies' + pacman -S --noconfirm base-devel git + gend + + if [ -z "$TARGET" ]; then + printf "${ANSI_RED}Undefined TARGET!$ANSI_NOCOLOR" + exit 1 + fi + cd "$TARGET" + + MINGW_INSTALLS="$(echo "$MINGW_INSTALLS" | tr '[:upper:]' '[:lower:]')" + + case "$MINGW_INSTALLS" in + mingw32) + TARBALL_ARCH="i686" + ;; + mingw64) + TARBALL_ARCH="x86_64" + + # FIXME: specific versions of these packages should be installed automatically by makepkg-mingw. + # E.g.: mingw-w64-x86_64-llvm-8.0.1-3 mingw-w64-x86_64-clang-8.0.1-3 mingw-w64-x86_64-z3-4.8.5-1 + # However, specifying the version produces 'error: target not found:' + gstart "Install build dependencies" + pacman -S --noconfirm mingw-w64-x86_64-llvm mingw-w64-x86_64-clang mingw-w64-x86_64-z3 + gend + ;; + *) + echo "Unknown MING_INSTALLS=${MINGW_INSTALLS}!" + exit 1 + esac + gstart 'Install toolchain' + pacman -S --noconfirm mingw-w64-${TARBALL_ARCH}-toolchain + gend + + gstart 'Build package' + dos2unix PKGBUILD + makepkg-mingw -sCLfc --noconfirm --noprogressbar + gend + + ls -la + + gstart 'Install package' + pacman --noconfirm -U "mingw-w64-${TARBALL_ARCH}-ghdl-${TARGET}-ci"-*-any.pkg.tar.xz + gend +} + +test () { + gstart 'Environment' + env | grep MSYSTEM + env | grep MINGW + gend + + export PATH=$PATH:"$(cd $(dirname $(which ghdl))/../lib; pwd)" + GHDL=ghdl ../../testsuite/testsuite.sh +} + +case "$1" in + -t) + test + ;; + *) + build + ;; +esac diff --git a/dist/travis/build.sh b/dist/travis/build.sh deleted file mode 100755 index 59438ff56..000000000 --- a/dist/travis/build.sh +++ /dev/null @@ -1,167 +0,0 @@ -#! /bin/bash - -scriptdir=$(dirname $0) - -. "$scriptdir/utils.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";; - "--synth"|"-synth") set -- "$@" "-s";; - *) set -- "$@" "$arg" - esac -done -# Parse args -while getopts ":b:p:cgs" opt; do - case $opt in - c) enable_color;; - b) BLD=$OPTARG ;; - p) PKG_NAME=$OPTARG;; - g) ISGPL=true;; - s) ISSYNTH=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 - -travis_start "env.docker" "$ANSI_YELLOW[Info] Environment $ANSI_NOCOLOR" -env -travis_finish "env.docker" - -#--- GPL: gpl-ize sources - -if [ "$ISGPL" = "true" ]; then - 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}" - travis_finish "gpl.src" -fi - -#--- Configure - -travis_start "configure" "$ANSI_YELLOW[GHDL - build] Configure $ANSI_NOCOLOR" -notime - -CDIR=$(pwd) -export prefix="$CDIR/install-$BLD" -mkdir "$prefix" -mkdir "build-$BLD" -cd "build-$BLD" - -if [ "x$ISSYNTH" = "xtrue" ]; then - CONFIG_OPTS+=" --enable-synth" -fi - -case "$BLD" in - gcc*) - 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 - cd gcc-srcs - sed -i.bak s/ftp:/http:/g ./contrib/download_prerequisites - ./contrib/download_prerequisites - cd .. - travis_finish "get_gcc" - - 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_finish "configure_gcc" - ;; - mcode) - 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-*) - llvmver=$(echo $BLD | sed -e "s/llvm-//") - CXX="clang++-$llvmver" - CONFIG_OPTS+=" --with-llvm-config=llvm-config-$llvmver CXX=$CXX" - ;; - *) - echo "$ANSI_RED[GHDL - build] Unknown build $BLD $ANSI_NOCOLOR" - exit 1;; -esac - -if [ ! "$(echo $BLD | grep gcc)" ]; then - echo "../configure --prefix=$prefix $CONFIG_OPTS" - ../configure "--prefix=$prefix" $CONFIG_OPTS -fi - -travis_finish "configure" -notime - -#--- make - -travis_start "make" "$ANSI_YELLOW[GHDL - build] Make $ANSI_NOCOLOR" -set +e -make LIB_CFLAGS="$LIB_CFLAGS" OPT_FLAGS="$OPT_FLAGS" -j$(nproc) 2>make_err.log -tail -1000 make_err.log -set -e -travis_finish "make" - -travis_start "install" "$ANSI_YELLOW[GHDL - build] Install $ANSI_NOCOLOR" -make install -cd .. -travis_finish "install" - -if [ "$(echo $BLD | grep gcc)" ]; then - travis_start "make_ghdllib" "$ANSI_YELLOW[GHDL - build] Make ghdllib $ANSI_NOCOLOR" - make ghdllib - travis_finish "make_ghdllib" - - travis_start "install_ghdllib" "$ANSI_YELLOW[GHDL - build] Install ghdllib $ANSI_NOCOLOR" - make install - cd .. - travis_finish "install_ghdllib" -fi - -#--- package - -travis_start "tar.bin" "$ANSI_YELLOW[GHDL - build] Create package ${ANSI_DARKCYAN}${PKG_NAME}.tgz $ANSI_NOCOLOR" -tar -zcvf "${PKG_NAME}.tgz" -C "$prefix" . -travis_finish "tar.bin" - -#--- build tools versions - -{ - make --version | grep 'Make' - gnatls --version | grep 'GNATLS' - gcc --version | grep 'gcc' - if [ "$CXX" != "" ]; then - $CXX --version | grep 'clang' - fi -} > BUILD_TOOLS - -#--- - -echo "[SUCCESSFUL]" -touch build_ok diff --git a/dist/travis/travis-ci.sh b/dist/travis/travis-ci.sh deleted file mode 100755 index 676d9dcf2..000000000 --- a/dist/travis/travis-ci.sh +++ /dev/null @@ -1,110 +0,0 @@ -#! /bin/bash -# This script is executed in the travis-ci environment. - -build_img_ghdl() { - travis_start "build_run" "$ANSI_BLUE[DOCKER build] ghdl/ghdl:${GHDL_IMAGE_TAG}$ANSI_NOCOLOR" - docker build -t ghdl/ghdl:$GHDL_IMAGE_TAG . -f-<<EOF -FROM ghdl/run:$BUILD_IMAGE_TAG -ADD `ls | grep '^ghdl.*\.tgz'` /usr/local -EOF - travis_finish "build_run" -} - -#--- - -set -e - -scriptdir=$(dirname $0) - -. "$scriptdir/utils.sh" - - -# Display env (to debug) - -travis_start "travis_env" "$ANSI_YELLOW[TRAVIS] Travis environment $ANSI_NOCOLOR" -env | grep TRAVIS -travis_finish "travis_env" - - -if [ "$IMAGE" = "" ]; then - echo "IMAGE not defined" - exit 1 -fi - - -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 -travis_finish "fetch" - - -if [ "$TRAVIS_OS_NAME" = "osx" ]; then - 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 - - -# Get build command options -travis_start "opts" "$ANSI_YELLOW[GHDL - build] Get build command options $ANSI_NOCOLOR" -buildCmdOpts "$EXTRA" -echo "build cmd: $BUILD_CMD_OPTS" -travis_finish "opts" - -# Build - -RUN="docker run --rm -t -e TRAVIS=$TRAVIS -e CONFIG_OPTS="$CONFIG_OPTS" -v $(pwd):/work -w /work" - -if [ "$TRAVIS_OS_NAME" = "osx" ]; then - CONFIG_OPTS="--disable-libghdl" bash -c "${scriptdir}/build.sh $BUILD_CMD_OPTS" -else - # Assume linux - - 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" - - - travis_start "pull" "$ANSI_YELLOW[GHDL - build] Docker pull ghdl/build:$BUILD_IMAGE_TAG $ANSI_NOCOLOR" - docker pull ghdl/build:$BUILD_IMAGE_TAG - travis_finish "pull" - - # Run build in docker - $RUN "ghdl/build:$BUILD_IMAGE_TAG" bash -c "${scriptdir}/build.sh $BUILD_CMD_OPTS" -fi - -if [ ! -f build_ok ]; then - printf "$ANSI_RED[TRAVIS] BUILD failed $ANSI_NOCOLOR\n" - exit 1 -fi - -# Test - -if [ "$TRAVIS_OS_NAME" = "osx" ]; then - bash -c "prefix=$(realpath ./install-mcode) ${scriptdir}/../../testsuite/testsuite.sh sanity gna vests" -else - # Build ghdl/ghdl:$GHDL_IMAGE_TAG image - build_img_ghdl - # Run test in docker container - tests="sanity" - if [ "x$EXTRA" != "xgpl" ]; then - tests="$tests gna" - fi - tests="$tests vests" - if [ "x$EXTRA" = "xsynth" ]; then - tests="$tests synth" - fi - $RUN "ghdl/ghdl:$GHDL_IMAGE_TAG" bash -c "GHDL=ghdl ${scriptdir}/../../testsuite/testsuite.sh $tests" -fi - -if [ ! -f "${scriptdir}/../../testsuite/test_ok" ]; then - printf "$ANSI_RED[TRAVIS] TEST failed $ANSI_NOCOLOR\n" - exit 1 -fi diff --git a/dist/travis/utils.sh b/dist/travis/utils.sh deleted file mode 100644 index 5cbf186d7..000000000 --- a/dist/travis/utils.sh +++ /dev/null @@ -1,107 +0,0 @@ -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 () { - # Extract from IMAGE (defined in .travis.yml) - BUILD_ARG="$IMAGE" - if [ "x$1" != "x" ]; then - BUILD_ARG="$IMAGE+$1" - 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 BUILD_ARG - IFS='+' read -ra REFS <<< "$BUILD_ARG" - DDIST=${REFS[0]} # Linux distro (eg: ubuntuXX, fedoraXX) - DBLD=${REFS[1]} # Build/backend (eg: mcode, llvm) - DEXT=${REFS[2]} # Extra constraints: GPL, synth - - PKG_NAME="ghdl-${PKG_TAG}-${DDIST}-${DBLD}" - BUILD_CMD_OPTS="$ENABLECOLOR -b $DBLD" - - if [ "x$DEXT" = "xgpl" ]; then - BUILD_CMD_OPTS="$BUILD_CMD_OPTS --gpl" - PKG_NAME="ghdl-$DEXT-${PKG_TAG}" - fi - if [ "x$DEXT" = "xsynth" ]; then - BUILD_CMD_OPTS="$BUILD_CMD_OPTS --synth" - PKG_NAME="ghdl-$DEXT-${PKG_TAG}" - fi - export BUILD_CMD_OPTS="${BUILD_CMD_OPTS} -p $PKG_NAME" - - GHDL_IMAGE_TAG="`echo $IMAGE | sed -e 's/+/-/g'`" - BUILD_IMAGE_TAG="$GHDL_IMAGE_TAG" - - case $BUILD_ARG in - *gcc*) - BUILD_IMAGE_TAG="`echo $GHDL_IMAGE_TAG | sed 's#\(.*\)-gcc.*#\1-gcc#g'`" - ;; - esac - - if [ "x$DEXT" != "x" ]; then - GHDL_IMAGE_TAG="$GHDL_IMAGE_TAG-$DEXT" - fi -} - -#-- - -. "$scriptdir/../ansi_color.sh" -#disable_color |