diff options
author | Wade Fife <wade.fife@ettus.com> | 2020-05-27 09:42:19 -0500 |
---|---|---|
committer | Wade Fife <wade.fife@ettus.com> | 2020-05-28 15:11:29 -0500 |
commit | 6faec1d4a14a1af52681aabf19c9040dcee772ff (patch) | |
tree | 5e4989a67bbc277bd99c41dd0297b50d1c2d6c6a /fpga/usrp3/tools | |
parent | 65fbf053c059c888fe544327f841313641561255 (diff) | |
download | uhd-6faec1d4a14a1af52681aabf19c9040dcee772ff.tar.gz uhd-6faec1d4a14a1af52681aabf19c9040dcee772ff.tar.bz2 uhd-6faec1d4a14a1af52681aabf19c9040dcee772ff.zip |
fpga: tools: Improve detection of setupenv sourcing
This change allows detection of attempting to execute setupenv.sh
rather than sourcing it, which is required.
Diffstat (limited to 'fpga/usrp3/tools')
-rw-r--r-- | fpga/usrp3/tools/scripts/setupenv_base.sh | 60 |
1 files changed, 31 insertions, 29 deletions
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 @@ -38,6 +38,31 @@ function resolve_viv_path { } #---------------------------------------------------------------------------- +# Help message display function +#---------------------------------------------------------------------------- +function setupenv_help { + cat <<EOHELP + +Usage: source setupenv.sh [--help|-h] [--vivado-path=<PATH>] [--modelsim-path=<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 #---------------------------------------------------------------------------- # Ensure required variables @@ -58,38 +83,15 @@ 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 <<EOHELP - -Usage: source setupenv.sh [--help|-h] [--vivado-path=<PATH>] [--modelsim-path=<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 #---------------------------------------------------------------------------- # Detect platform bitness @@ -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 |