diff options
Diffstat (limited to 'libraries/vendors/compile-osvvm.sh')
-rwxr-xr-x | libraries/vendors/compile-osvvm.sh | 176 |
1 files changed, 116 insertions, 60 deletions
diff --git a/libraries/vendors/compile-osvvm.sh b/libraries/vendors/compile-osvvm.sh index fe20e3872..d7430434f 100755 --- a/libraries/vendors/compile-osvvm.sh +++ b/libraries/vendors/compile-osvvm.sh @@ -4,10 +4,10 @@ # kate: tab-width 2; replace-tabs off; indent-width 2; # # ============================================================================== -# Bash Script: Script to compile the OSVVM library for GHDL on Linux -# # Authors: Patrick Lehmann # +# Bash Script: Script to compile the OSVVM library for GHDL on Linux +# # Description: # ------------------------------------ # This is a Bash script (executable) which: @@ -15,7 +15,7 @@ # - compiles all OSVVM packages # # ============================================================================== -# Copyright (C) 2015 Patrick Lehmann +# Copyright (C) 2015-2016 Patrick Lehmann # # GHDL is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -37,15 +37,17 @@ # save working directory WorkingDir=$(pwd) ScriptDir="$(dirname $0)" -ScriptDir="$(realpath $ScriptDir)" +ScriptDir="$(readlink -f $ScriptDir)" # source configuration file from GHDL's 'vendors' library directory source $ScriptDir/config.sh source $ScriptDir/shared.sh -NO_COMMAND=TRUE - # command line argument processing +NO_COMMAND=TRUE +GHDLBinDir="" +DestDir="" +SrcDir="" while [[ $# > 0 ]]; do key="$1" case $key in @@ -54,7 +56,11 @@ while [[ $# > 0 ]]; do NO_COMMAND=FALSE ;; -a|--all) - ALL=TRUE + COMPILE_ALL=TRUE + NO_COMMAND=FALSE + ;; + -o|--osvvm) + COMPILE_OSVVM=TRUE NO_COMMAND=FALSE ;; -s|--skip-existing) @@ -66,13 +72,22 @@ while [[ $# > 0 ]]; do -H|--halt-on-error) HALT_ON_ERROR=TRUE ;; -# -v|--verbose) -# VERBOSE=TRUE -# ;; -h|--help) HELP=TRUE NO_COMMAND=FALSE ;; + --ghdl) + GHDLBinDir="$2" + shift # past argument + ;; + --src) + SrcDir="$2" + shift # past argument + ;; + --out) + DestDir="$2" + shift # past argument + ;; *) # unknown option UNKNOWN_OPTION=TRUE ;; @@ -93,50 +108,88 @@ elif [ "$HELP" == "TRUE" ]; then fi echo "" echo "Synopsis:" - echo " Script to compile the simulation library OSVVM for GHDL on Linux" + echo " A script to compile the simulation library 'OSVVM' for GHDL on Linux." + echo " A library folder 'osvvm/v08' will be created relative to the current" + echo " working directory." + echo "" + echo " Use the adv. options or edit 'config.sh' to supply paths and default params." echo "" echo "Usage:" - echo " compile-osvvm.sh <common command>|<library> [<options>]" -# [-v] [-c] [--all] [-s|--skip-existing] [-n|--no-warnings] + echo " compile-osvvm.sh <common command>|<library> [<options>] [<adv. options>]" echo "" echo "Common commands:" - echo " -h --help Print this help page" - echo " -c --clean Remove all generated files" + echo " -h --help Print this help page" + echo " -c --clean Remove all generated files" echo "" echo "Libraries:" - echo " -a --all Compile all packages." + echo " -a --all Compile all packages (default)." + echo " -o --osvvm Compile package osvvm." echo "" echo "Library compile options:" - echo " -s --skip-existing Skip already compiled files (an *.o file exists)." - echo " -H --halt-on-error Halt on error(s)." + echo " -s --skip-existing Skip already compiled files (an *.o file exists)." + echo " -H --halt-on-error Halt on error(s)." + echo "" + echo "Advanced options:" + echo " --ghdl <GHDL BinDir> Path to GHDL binary directory e.g. /usr/bin." + echo " --out <dir name> Name of the output directory." + echo " --src <Path to OSVVM> Name of the output directory." echo "" echo "Verbosity:" -# echo " -v --verbose Print more messages" echo " -n --no-warnings Suppress all warnings. Show only error messages." echo "" exit 0 fi -if [ "$ALL" == "TRUE" ]; then - UNISIM=TRUE - UNIMACRO=TRUE - SIMPRIM=TRUE - SECUREIP=TRUE +if [ "$COMPILE_ALL" == "TRUE" ]; then + COMPILE_OSVVM=TRUE fi -# extract data from configuration -InstallDir=${InstallationDirectory[OSVVM]} -SourceDir="$InstallDir" +SourceDirectory=${SourceDirectory[OSVVM]} DestinationDir=${DestinationDirectory[OSVVM]} -if [ -z $InstallDir ] || [ -z $DestinationDir ]; then +# OSVVM source directory +# ---------------------- +# If a command line argument ('--src') was passed in, use it, else use the default value +# from config.sh +if [ ! -z "$SrcDir" ]; then + SourceDirectory=$SrcDir +fi +# OSVVM output directory +# ---------------------- +# If a command line argument ('--out') was passed in, use it, else use the default value +# from config.sh +if [ ! -z "$DestDir" ]; then + DestinationDir=$DestDir +fi + +# Use GHDL binary directory from command line argument, if set +if [ ! -z "$GHDLBinDir" ]; then + GHDLBinary=$GHDLBinDir/ghdl + if [[ ! -x "$GHDLBinary" ]]; then + echo -e "${COLORED_ERROR} GHDL not found or is not executable.${ANSI_RESET}" + exit -1 + fi +else # fall back to GHDL found via PATH + GHDLBinary=$(which ghdl) + if [ $? -ne 0 ]; then + echo -e "${COLORED_ERROR} GHDL not found in PATH.${ANSI_RESET}" + echo -e " Use adv. options '--ghdl' to set the GHDL binary directory." + exit -1 + fi +fi + +if [ -z $SourceDirectory ] || [ -z $DestinationDir ]; then echo -e "${COLORED_ERROR} OSVVM is not configured in '$ScriptDir/config.sh'${ANSI_RESET}" + echo -e " Use adv. options '--src' and '--out' or configure 'config.sh'." exit -1 -elif [ ! -d $SourceDir ]; then +elif [ ! -d $SourceDirectory ]; then echo -e "${COLORED_ERROR} Path '$SourceDir' does not exist.${ANSI_RESET}" exit -1 fi +# append VHDL version folder +DestinationDir=$DestinationDir/v08 + # set bash options set -o pipefail @@ -148,7 +201,7 @@ if [[ -d "$DestinationDir" ]]; then echo -e "${ANSI_YELLOW}Vendor directory '$DestinationDir' already exists.${ANSI_RESET}" else echo -e "${ANSI_YELLOW}Creating vendor directory: '$DestinationDir'${ANSI_RESET}" - mkdir "$DestinationDir" + mkdir -p "$DestinationDir" fi cd $DestinationDir @@ -163,57 +216,60 @@ else fi fi -STOPCOMPILING=FALSE - # Cleanup directory # ============================================================================== if [ "$CLEAN" == "TRUE" ]; then - echo -e "${ANSI_YELLOW}Cleaning up vendor directory ...${ANSI_RESET}" + echo -e "${ANSI_YELLOW}Cleaning up directory ...${ANSI_RESET}" rm *.o 2> /dev/null + rm *.cf 2> /dev/null fi # Library osvvm # ============================================================================== # compile osvvm packages -if [ "$STOPCOMPILING" == "FALSE" ]; then +if [ "$COMPILE_OSVVM" == "TRUE" ]; then echo -e "${ANSI_YELLOW}Compiling library 'osvvm' ...${ANSI_RESET}" GHDL_PARAMS=(${GHDL_OPTIONS[@]}) GHDL_PARAMS+=(--std=08) Files=( - $SourceDir/NamePkg.vhd - $SourceDir/OsvvmGlobalPkg.vhd - $SourceDir/TextUtilPkg.vhd - $SourceDir/TranscriptPkg.vhd - $SourceDir/AlertLogPkg.vhd - $SourceDir/MemoryPkg.vhd - $SourceDir/MessagePkg.vhd - $SourceDir/SortListPkg_int.vhd - $SourceDir/RandomBasePkg.vhd - $SourceDir/RandomPkg.vhd - $SourceDir/CoveragePkg.vhd - $SourceDir/OsvvmContext.vhd + NamePkg.vhd + OsvvmGlobalPkg.vhd + TextUtilPkg.vhd + TranscriptPkg.vhd + AlertLogPkg.vhd + MemoryPkg.vhd + MessagePkg.vhd + SortListPkg_int.vhd + RandomBasePkg.vhd + RandomPkg.vhd + CoveragePkg.vhd + OsvvmContext.vhd ) + + echo $GHDLBinary + + ERRORCOUNT=0 for File in ${Files[@]}; do FileName=$(basename "$File") if [ "$SKIP_EXISTING_FILES" == "TRUE" ] && [ -e "${FileName%.*}.o" ]; then echo -e "${ANSI_CYAN}Skipping package '$File'${ANSI_RESET}" else echo -e "${ANSI_CYAN}Analyzing package '$File'${ANSI_RESET}" - ghdl -a ${GHDL_PARAMS[@]} --work=osvvm "$File" 2>&1 | $GRC_COMMAND - if [ $? -ne 0 ] && [ "$HALT_ON_ERROR" == "TRUE" ]; then - STOPCOMPILING=TRUE - break + $GHDLBinary -a ${GHDL_PARAMS[@]} --work=osvvm "$SourceDirectory/$File" 2>&1 | $GRC_COMMAND + if [ $? -ne 0 ]; then + let ERRORCOUNT++ + if [ "$HALT_ON_ERROR" == "TRUE" ]; then + break + fi fi fi done + + echo "--------------------------------------------------------------------------------" + echo -n "Compiling OSVVM library " + if [ $ERRORCOUNT -gt 0 ]; then + echo -e $COLORED_FAILED + else + echo -e $COLORED_SUCCESSFUL + fi fi - -echo "--------------------------------------------------------------------------------" -echo -n "Compiling OSVVM library " -if [ "$STOPCOMPILING" == "TRUE" ]; then - echo -e $COLORED_FAILED -else - echo -e $COLORED_SUCCESSFUL -fi - -cd $WorkingDir |