From 6faec1d4a14a1af52681aabf19c9040dcee772ff Mon Sep 17 00:00:00 2001 From: Wade Fife Date: Wed, 27 May 2020 09:42:19 -0500 Subject: fpga: tools: Improve detection of setupenv sourcing This change allows detection of attempting to execute setupenv.sh rather than sourcing it, which is required. --- fpga/usrp3/tools/scripts/setupenv_base.sh | 60 ++++++++++++++++--------------- 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'fpga/usrp3/tools') diff --git a/fpga/usrp3/tools/scripts/setupenv_base.sh b/fpga/usrp3/tools/scripts/setupenv_base.sh index 76385c598..5919b3aa8 100644 --- a/fpga/usrp3/tools/scripts/setupenv_base.sh +++ b/fpga/usrp3/tools/scripts/setupenv_base.sh @@ -37,6 +37,31 @@ function resolve_viv_path { fi } +#---------------------------------------------------------------------------- +# Help message display function +#---------------------------------------------------------------------------- +function setupenv_help { + cat <] [--modelsim-path=] + +--vivado-path : Path to the base install directory for Xilinx Vivado + (Default: /opt/Xilinx/Vivado or /opt/Xilinx/Vivado_Lab) +--modelsim-path : Path to the base install directory for Modelsim (optional simulation tool) + (Default: /opt/mentor/modelsim) +--help -h : Shows this message. + +This script sets up the environment required to build FPGA images for the Ettus Research +${DISPLAY_NAME}. It will also optionally set up the the environment to run the +Modelsim simulator (although this tool is not required). + +Required tools: Xilinx Vivado $VIVADO_VER (Synthesis and Simulation) +Optional tools: Mentor Graphics Modelsim (Simulation) + +EOHELP +} + + #---------------------------------------------------------------------------- # Validate prerequisites #---------------------------------------------------------------------------- @@ -58,37 +83,14 @@ if [ ${#PRODUCT_ID_MAP[@]} -eq 0 ]; then return fi -# Ensure that the script is sourced -if [[ $BASH_SOURCE = $0 ]]; then +# Ensure that the script is sourced directly or from another script, and not +# executed. +if [[ ${BASH_SOURCE[0]} == "$0" || ${BASH_SOURCE[1]} == "$0" ]]; then echo "ERROR: This script must be sourced." - help + setupenv_help exit 1 fi -#---------------------------------------------------------------------------- -# Help message display function -#---------------------------------------------------------------------------- -function help { - cat <] [--modelsim-path=] - ---vivado-path : Path to the base install directory for Xilinx Vivado - (Default: /opt/Xilinx/Vivado or /opt/Xilinx/Vivado_Lab) ---modelsim-path : Path to the base install directory for Modelsim (optional simulation tool) - (Default: /opt/mentor/modelsim) ---help -h : Shows this message. - -This script sets up the environment required to build FPGA images for the Ettus Research -${DISPLAY_NAME}. It will also optionally set up the the environment to run the -Modelsim simulator (although this tool is not required). - -Required tools: Xilinx Vivado $VIVADO_VER (Synthesis and Simulation) -Optional tools: Mentor Graphics Modelsim (Simulation) - -EOHELP -} - #---------------------------------------------------------------------------- # Setup and parse command line #---------------------------------------------------------------------------- @@ -106,7 +108,7 @@ PARSE_STATE="" for i in "$@"; do case $i in -h|--help) - help + setupenv_help return 0 ;; --vivado-path=*) @@ -148,7 +150,7 @@ for i in "$@"; do ;; *) echo "ERROR: Unrecognized option: $i" - help + setupenv_help return 1 ;; esac -- cgit v1.2.3