From b4d4d9abb322ed0807d2ba0888e73820499aa338 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral <38422348+umarcor@users.noreply.github.com> Date: Sat, 26 Jun 2021 19:40:25 +0100 Subject: Codacy issues, Travis cleanup and update ghdl.texi (#1807) * ghw: fix memleaks reported by codacy * ghw: printf issues and style (GNU indent) * testsuite/gna: minor printf issues * testsuite: fix issues reported by codacy * scripts/ci-run: clean travis stuff (deprecated) * scripts: fix issues reported by codacy * doc/Makefile: add .PHONY * doc: update ghdl.texi * testsuite/synth: use synth_tb --- scripts/ci-run.sh | 68 +++++--------------------------- scripts/vendors/compile-altera.sh | 2 +- scripts/vendors/compile-lattice.sh | 2 +- scripts/vendors/compile-osvvm.sh | 6 +-- scripts/vendors/compile-xilinx-ise.sh | 12 +++--- scripts/vendors/compile-xilinx-vivado.sh | 2 +- scripts/vendors/filter.analyze.sh | 6 +-- scripts/vendors/shared.sh | 16 ++++---- 8 files changed, 33 insertions(+), 81 deletions(-) (limited to 'scripts') diff --git a/scripts/ci-run.sh b/scripts/ci-run.sh index ba213310c..96e2a99bc 100755 --- a/scripts/ci-run.sh +++ b/scripts/ci-run.sh @@ -1,6 +1,6 @@ #! /bin/bash -scriptdir=`dirname $0` +scriptdir=`dirname "$0"` if [ -n "$GITHUB_EVENT_PATH" ]; then export CI=true @@ -24,56 +24,20 @@ 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 +if [ -n "$CI" ]; then + echo "INFO: set 'gstart' and 'gend' for CI" gstart () { - echo "travis_fold:start:group" - travis_time_start + printf '::group::' print_start "$@" + SECONDS=0 } gend () { - travis_time_finish - echo "travis_fold:end:group" + duration=$SECONDS + echo '::endgroup::' + printf "${ANSI_GRAY}took $(($duration / 60)) min $(($duration % 60)) sec.${ANSI_NOCOLOR}\n" } -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 $@" @@ -143,9 +107,6 @@ 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 @@ -154,8 +115,6 @@ buildCmdOpts () { 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" @@ -168,13 +127,6 @@ buildCmdOpts () { *heads*|*pull*) PKG_TAG="`notag`" ;; - "") - if [ -z "$TRAVIS_TAG" ]; then - PKG_TAG="`notag`" - else - PKG_TAG="`vertag "$TRAVIS_TAG"`" - fi - ;; *) PKG_TAG="$GITHUB_REF" ;; @@ -391,7 +343,7 @@ ci_run () { # Build - RUN="docker run --rm -t -e CI -e TRAVIS -v `pwd`:/work -w /work" + RUN="docker run --rm -t -e CI -v `pwd`:/work -w /work" if [ "x$IS_MACOS" = "xtrue" ]; then export CPATH="$CPATH:$(xcrun --show-sdk-path)/usr/include" export PATH="$PATH:$(brew --prefix llvm)/bin" @@ -477,7 +429,7 @@ EOF echo "command: $0 $@" unset IS_MACOS -if [ "$GITHUB_OS" = "macOS" ] || [ "$TRAVIS_OS_NAME" = "osx" ]; then +if [ "$GITHUB_OS" = "macOS" ]; then IS_MACOS="true" fi diff --git a/scripts/vendors/compile-altera.sh b/scripts/vendors/compile-altera.sh index 06269071e..17dfe42c7 100755 --- a/scripts/vendors/compile-altera.sh +++ b/scripts/vendors/compile-altera.sh @@ -217,7 +217,7 @@ fi # Search Altera Quartus in default installation locations DefaultDirectories=("/opt/Altera" "/opt/altera" "/c/Altera") -if [ ! -z $QUARTUS_ROOTDIR ]; then +if [ -n "$QUARTUS_ROOTDIR" ]; then EnvSourceDir="$QUARTUS_ROOTDIR/${Altera_Quartus_Settings[SourceDirectory]}" else for DefaultDir in "${DefaultDirectories[@]}"; do diff --git a/scripts/vendors/compile-lattice.sh b/scripts/vendors/compile-lattice.sh index 2c42e2200..e5e8c3242 100755 --- a/scripts/vendors/compile-lattice.sh +++ b/scripts/vendors/compile-lattice.sh @@ -232,7 +232,7 @@ SetupDirectories LatticeDiamond "Lattice Diamond" # create "lattice" directory and change to it # => $DestinationDirectory CreateDestinationDirectory -cd $DestinationDirectory +cd "$DestinationDirectory" # Extend global GHDL Options TODO: move to GHDLSetup diff --git a/scripts/vendors/compile-osvvm.sh b/scripts/vendors/compile-osvvm.sh index 34b5f2dd4..9f69fc088 100755 --- a/scripts/vendors/compile-osvvm.sh +++ b/scripts/vendors/compile-osvvm.sh @@ -34,10 +34,10 @@ test greadlink --version > /dev/null 2>&1 && READLINK=greadlink || READLINK=read # Save working directory WorkingDir=$(pwd) ScriptDir="$(dirname $0)" -ScriptDir="$($READLINK -f $ScriptDir)" +ScriptDir="$($READLINK -f "$ScriptDir")" # Source Bash utilities -source $ScriptDir/../ansi_color.sh +source "$ScriptDir"/../ansi_color.sh if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading Bash utilities.${ANSI_NOCOLOR}" ; exit 1; fi @@ -52,7 +52,7 @@ SUPPRESS_WARNINGS=0 HALT_ON_ERROR=0 DestDir="" SrcDir="" -while [[ $# -gt 0 ]]; do +while [[ "$#" -gt 0 ]]; do case "$1" in -c|--clean) COMMAND=3 diff --git a/scripts/vendors/compile-xilinx-ise.sh b/scripts/vendors/compile-xilinx-ise.sh index 354193501..b904f2f0e 100755 --- a/scripts/vendors/compile-xilinx-ise.sh +++ b/scripts/vendors/compile-xilinx-ise.sh @@ -35,10 +35,10 @@ test greadlink --version > /dev/null 2>&1 && READLINK=greadlink || READLINK=read # Save working directory WorkingDir=$(pwd) ScriptDir="$(dirname $0)" -ScriptDir="$($READLINK -f $ScriptDir)" +ScriptDir="$($READLINK -f "$ScriptDir")" # Source Bash utilities -source $ScriptDir/../ansi_color.sh +source "$ScriptDir"/../ansi_color.sh if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading Bash utilities.${ANSI_NOCOLOR}" ; exit 1; fi @@ -60,7 +60,7 @@ VHDLStandard=93 GHDLBinDir="" DestDir="" SrcDir="" -while [[ $# -gt 0 ]]; do +while [[ "$#" -gt 0 ]]; do case "$1" in -c|--clean) COMMAND=3 @@ -210,14 +210,14 @@ fi # Search Xilinx ISE in default installation locations DefaultDirectories=("/opt/Xilinx" "/opt/xilinx" "/c/Xilinx") -if [ ! -z $XILINX ]; then +if [ -n "$XILINX" ]; then EnvSourceDir="$XILINX/${Xilinx_ISE_Settings[SourceDirectory]}" else for DefaultDir in "${DefaultDirectories[@]}"; do for Major in 14 13; do for Minor in 7 6 5 4 3 2 1 0; do - Dir=$DefaultDir/${Major}.${Minor}/ISE_DS - if [ -d $Dir ]; then + Dir="$DefaultDir/${Major}.${Minor}"/ISE_DS + if [ -d "$Dir" ]; then EnvSourceDir="$Dir/${Xilinx_ISE_Settings[SourceDirectory]}" break 3 fi diff --git a/scripts/vendors/compile-xilinx-vivado.sh b/scripts/vendors/compile-xilinx-vivado.sh index 050f0ab4a..334df149f 100755 --- a/scripts/vendors/compile-xilinx-vivado.sh +++ b/scripts/vendors/compile-xilinx-vivado.sh @@ -38,7 +38,7 @@ ScriptDir="$(dirname $0)" ScriptDir="$($READLINK -f $ScriptDir)" # Source Bash utilities -source $ScriptDir/../ansi_color.sh +source "$ScriptDir"/../ansi_color.sh if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading Bash utilities.${ANSI_NOCOLOR}" ; exit 1; fi diff --git a/scripts/vendors/filter.analyze.sh b/scripts/vendors/filter.analyze.sh index dfb99eaa9..a3242df7e 100755 --- a/scripts/vendors/filter.analyze.sh +++ b/scripts/vendors/filter.analyze.sh @@ -35,9 +35,9 @@ test greadlink --version > /dev/null 2>&1 && READLINK=greadlink || READLINK=read # Save working directory WorkingDir=$(pwd) ScriptDir="$($READLINK -f $(dirname $0))" -RootDir="$($READLINK -f $ScriptDir/..)" +RootDir="$($READLINK -f "$ScriptDir"/..)" -source $ScriptDir/../ansi_color.sh +source "$ScriptDir"/../ansi_color.sh if [[ $? -ne 0 ]]; then echo 1>&2 -e "${COLORED_ERROR} While loading Bash utilities.${ANSI_NOCOLOR}" ; exit 1; fi # command line argument processing @@ -45,7 +45,7 @@ COMMAND=2 INDENT="" VERBOSE=0 DEBUG=0 -while [[ $# > 0 ]]; do +while [ "$#" -gt 0 ]; do key="$1" case $key in -i|--indent) diff --git a/scripts/vendors/shared.sh b/scripts/vendors/shared.sh index 23f99375d..1c620db41 100755 --- a/scripts/vendors/shared.sh +++ b/scripts/vendors/shared.sh @@ -56,9 +56,9 @@ VERBOSE=${VERBOSE:-0} DEBUG=${DEBUG:-0} CONTINUE_ON_ERROR=${CONTINUE_ON_ERROR:-0} -test $VERBOSE -eq 1 && echo -e " Declaring Bash procedures for GHDL..." +test "$VERBOSE" -eq 1 && echo -e " Declaring Bash procedures for GHDL..." -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure SetupDirectories( )${ANSI_NOCOLOR}" +test "$DEBUG" -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure SetupDirectories( )${ANSI_NOCOLOR}" # SetupDirectories # -> $Index # -> $Name @@ -108,7 +108,7 @@ SetupDirectories() { fi } -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure CreateDestinationDirectory( undocumented )${ANSI_NOCOLOR}" +test "$DEBUG" -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure CreateDestinationDirectory( undocumented )${ANSI_NOCOLOR}" # CreateDestinationDirectory # -> undocumented CreateDestinationDirectory() { @@ -123,18 +123,18 @@ CreateDestinationDirectory() { fi } -test $DEBUG -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure GHDLSetup( )${ANSI_NOCOLOR}" +test "$DEBUG" -eq 1 && echo -e " ${ANSI_DARK_GRAY}procedure GHDLSetup( )${ANSI_NOCOLOR}" # GHDLSetup # -> $VHDLStandard # <= $VHDLVersion # <= $VHDLStandard # <= $VHDLFlavor GHDLSetup() { - if [ $1 -eq 93 ]; then + if [ "$1" -eq 93 ]; then VHDLVersion="v93" VHDLStandard="93c" VHDLFlavor="synopsys" - elif [ $1 -eq 2008 ]; then + elif [ "$1" -eq 2008 ]; then VHDLVersion="v08" VHDLStandard="08" VHDLFlavor="synopsys" @@ -295,9 +295,9 @@ AnalyzeLibrary() { echo -e "${ANSI_YELLOW}Analyzing files into library '$LibraryName'...${ANSI_NOCOLOR}" for File in $Files; do - test $VERBOSE -eq 1 && echo -e "${ANSI_CYAN} Analyzing '$File'${ANSI_NOCOLOR}" + test "$VERBOSE" -eq 1 && echo -e "${ANSI_CYAN} Analyzing '$File'${ANSI_NOCOLOR}" - AnalyzeVHDL $LibraryName "$SourceDirectory" "$LibraryPath" "$File" + AnalyzeVHDL "$LibraryName" "$SourceDirectory" "$LibraryPath" "$File" done } -- cgit v1.2.3