diff --git a/init_hdl.sh b/init_hdl.sh index 42eeaaab84b5baf6d436e9612c7e9033a8fe730e..802e18c9a342001cf42f2ec80599adbd056249df 100644 --- a/init_hdl.sh +++ b/init_hdl.sh @@ -34,29 +34,42 @@ if [[ "$_" == "${0}" ]]; then exit fi +# +if [ -z "${ALTERA_DIR}" ]; then + echo "== environ variable 'ALTERA_DIR' not set. ==" + echo "should be in your .bashrc file." + echo "if it is your .bashrc file but not active run bash in your terminal" + exit +fi # Figure out where this script is located and set environment variables accordingly export RADIOHDL_WORK="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +echo "HDL environment will be setup for" $RADIOHDL_WORK + # setup paths to build and config dir if not already defined by the user. +export ARGS_WORK=${ARGS_WORK:-${RADIOHDL_WORK}} export HDL_BUILD_DIR=${HDL_BUILD_DIR:-${RADIOHDL_WORK}/build} -echo "HDL environment will be setup for" $RADIOHDL_WORK # modelsim uses this sim dir for testing export HDL_IOFILE_SIM_DIR=${HDL_IOFILE_SIM_DIR:-${HDL_BUILD_DIR}/sim} -if ! [[ -e HDL_IOFILE_SIM_DIR ]]; then +if [[ ! -d "${HDL_IOFILE_SIM_DIR}" ]]; then echo "make sim dir" - mkdir ${HDL_BUILD_DIR}/sim + mkdir "${HDL_IOFILE_SIM_DIR}" +fi +# if sim dir not empty, remove all files and dirs +if [ ! -z "$(ls -A ${HDL_IOFILE_SIM_DIR})" ]; then + echo "clear sim dir" + rm -r ${HDL_IOFILE_SIM_DIR}/* fi -rm -r ${HDL_BUILD_DIR}/sim/* # copy git user_componets.ipx into Altera dir's for altera_dir in ${ALTERA_DIR}/*; do - if [[ -d ${altera_dir} ]] && [[ ! -h ${altera_dir} ]]; then + if [[ -d "${altera_dir}" ]] && [[ ! -h "${altera_dir}" ]]; then echo "copy git hdl_user_components.ipx to ${altera_dir}/ip/altera/user_components.ipx" cp ${RADIOHDL_WORK}/hdl_user_components.ipx $altera_dir/ip/altera/user_components.ipx fi done -if [ -z "${RADIOHDL_GEAR}" ]; then - . ../radiohdl/init_radiohdl.sh -fi +# source also radiohdl and args tools +. ../radiohdl/init_radiohdl.sh +. ../args/init_args.sh