aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/vendors/compile-osvvm.sh
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@tu-dresden.de>2016-06-07 20:54:10 +0200
committertgingold <tgingold@users.noreply.github.com>2016-06-07 20:54:10 +0200
commita41a009f2ebec350f0ebbcbf8353223a15cfa557 (patch)
tree44e1d7374c4aa7bea4f8541296f18c70b087682d /libraries/vendors/compile-osvvm.sh
parent20259a7f396e03c5bfce9237fd5732eb931e3d23 (diff)
downloadghdl-a41a009f2ebec350f0ebbcbf8353223a15cfa557.tar.gz
ghdl-a41a009f2ebec350f0ebbcbf8353223a15cfa557.tar.bz2
ghdl-a41a009f2ebec350f0ebbcbf8353223a15cfa557.zip
Paebbels/master (#75)
* Obviously, this is the initial commit on a .gitignore file. * Implemented vendor specific compile scripts for: Altera Quartus-II (tested with 15.0), Xilinx ISE (tested with 14.7) and OSVVM. * Minor fixes. * First version of a README file for the vendor specific library compile scripts. * Vendor specific simulation library compile scripts: Improved error handling by stream processing. Extracted configuration into a config.ps1 file. * Minor fixes. * Added Unisim SecureIP primitives. Added Unimacro library. * Fixed file encoding of compile-osvvm.ps1. Implemented a 'advanced functions' to restore ghdl warning/error messages as a one-liner. * Splitted Xilinx compile scripts into *-ise.ps1 and *-vivado.ps1. * Added compile script for VUnit. * Updated README.md for the vendor compile scripts. * Added file headers. Change config.ps1 and shared.ps1 to a PowerShell module (*.psm1). * Fixed embedded help pages in all compile scripts. * Fixed all errors in compile script for Vivado simulation libraries: *_retarget_VCOMP.vhd was missing. * First steps towards compile scripts for Linux. * Translated lines from Windows script to Linux script. * Step 3 - colors and basic control blocks. * Changed copyright line in file header. * Changed copyright line in file header. * Added colorizer rules. Added skip mode for existing object files. Added cleanup mode. * Disabled vital checks in Xilinx's simprim library. Fixed typo. * Added '-Clean' parameter to cleanup the directory before analyzing. * Added a new '-Help' switch to all compile scripts to show the embedded help page(s). * Generalized config.sh. Fixed some bugs in compile-xilinx-ise.sh. * Added command line argument parsing. * Fixed syntax errors on Linux. * Added --all option. Generalized GHDL parameters. * Added '--skip-largefile' option. * Added the 'stop compiling' feature (not working). * Updated README.md for vendor specific compile scripts. * Implemented a check if grcat is installed on the system. Added support to execute the script from an other directory. Changed file size test from 'du -b' to 'wc -b'. * Fixed exit code problem in pipes. Fixed word count problem. * Minor fixes. * Fixed possible syntax error. * Implemented vendor specific library compile script for OSVVM. * Implemented vendor specific library compile script for VUnit. * Enabled disabled messages. Fixed typos. * Implemented vendor specific library compile script for Xilinx Vivado. * Minor fixes. * Implemented vendor specific library compile script for Altera Quartus-II. * Applied chmod to all new compile scripts. * Minor fixes. * Fixed typos. * Implemented 'halt-on-error' feature. * Fixed relative path problem for grcat. * README updates. * Updated PoSh scripts for - IEEE library compilation (complib.ps1) - added VITAL2000 support for VHDL-2008 - minor fixes - vendor compile scripts - added VHDL93 and VHDL2008 switches to compile vendor libraries with VHDL-2008 - minor fixes * Updated vendor library compile scripts (Bash) for Linux, too. * Fixed error in vendor library compile scripts for osvvm and vunit. * Windows compile scripts for mcode backend: Reworked compile.ps1. * Changed default output directory to xilinx-ise and xilinx-vivado. * compile-altera.sh: Skip large files * Updated compile script for OSVVM. * Improved OSVVM compile script for Linux.
Diffstat (limited to 'libraries/vendors/compile-osvvm.sh')
-rwxr-xr-xlibraries/vendors/compile-osvvm.sh176
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