From feca49455f11f20df1a36d79ade47559d7278450 Mon Sep 17 00:00:00 2001
From: donker <donker@astron.nl>
Date: Wed, 10 May 2023 10:40:15 +0200
Subject: [PATCH] RTSD-56, processed review comment

---
 applications/ta2/doc/README.txt |  1 -
 doc/erko_howto_tools.txt        |  2 --
 init_hdl.sh                     | 21 +++++++++++++++------
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/applications/ta2/doc/README.txt b/applications/ta2/doc/README.txt
index 903444cfca..e58654eab1 100644
--- a/applications/ta2/doc/README.txt
+++ b/applications/ta2/doc/README.txt
@@ -54,7 +54,6 @@ The ta2 project folder contains 4 sub-folders:
     # Altera, Mentor and modelsim_altera_libs dir
     export ALTERA_DIR=/home/software/Altera
     export MENTOR_DIR=/home/software/Mentor
-    export MODELSIM_ALTERA_LIBS_DIR=/home/software/modelsim_altera_libs
 
     . ${GIT}/radiohdl/init_radiohdl.sh
 
diff --git a/doc/erko_howto_tools.txt b/doc/erko_howto_tools.txt
index 8836bb0082..14826279e3 100755
--- a/doc/erko_howto_tools.txt
+++ b/doc/erko_howto_tools.txt
@@ -43,7 +43,6 @@
   * bashrc defines root directories that contain one or more versions of tool installations
     - define MENTOR_DIR : modelsim installations
     - define ALTERA_DIR : altera installations
-    - define MODELSIM_ALTERA_LIBS_DIR  : compiled modelsim simulation libraries for altera components
 
     - LM_LICENSE_FILE=<our_license@our_compagny>
 
@@ -87,7 +86,6 @@ source also radiohdl tools
 
 > compile_altera_simlibs unb1   # creates build/unb1/hdl_libraries_ip_stratixiv.txt
                                 # creates build/quartus/<tool version> simulation models that need to be moved
-                                # manually to $MODELSIM_ALTERA_LIBS_DIR/<tool version>
 
 > generate_ip_libs unb1         # creates build/unb1/qmegawiz/
                                 # creates build/unb1/quartus_sh --> empty dir, why is it there?
diff --git a/init_hdl.sh b/init_hdl.sh
index ab43b537eb..4ac562709c 100644
--- a/init_hdl.sh
+++ b/init_hdl.sh
@@ -55,13 +55,22 @@ if [[ ! -d "${HDL_BUILD_DIR}" ]]; then
     mkdir "${HDL_BUILD_DIR}"
 fi
 
-# set modelsim_altera_libs dir
-export MODELSIM_ALTERA_LIBS_DIR=${HDL_BUILD_DIR}/quartus
-if [[ ! -d "${MODELSIM_ALTERA_LIBS_DIR}" ]]; then
-    echo "make modelsim_altera_libs dir"
+# set hdl_build_quartus dir
+export HDL_BUILD_QUARTUS_DIR=${HDL_BUILD_DIR}/quartus
+if [[ ! -d "${HDL_BUILD_QUARTUS_DIR}" ]]; then
+    echo "make hdl/build/quartus dir"
+    echo "${HDL_BUILD_QUARTUS_DIR}"
+    mkdir "${HDL_BUILD_QUARTUS_DIR}"
+    echo "Do not remove this dir, it is used by modelsim_altera_libs symlink" > ${HDL_BUILD_QUARTUS_DIR}/readme.txt
+fi
+
+export MODELSIM_ALTERA_LIBS_DIR=${HDL_BUILD_DIR}/modelsim_altera_libs
+if [[ -L "${MODELSIM_ALTERA_LIBS_DIR}" ]] && [[ -e "${MODELSIM_ALTERA_LIBS_DIR}" ]]; then
+    echo "${MODELSIM_ALTERA_LIBS_DIR} is a valid symlink"
+else
+    echo "make a symlink for modelsim_altera_libs dir"
     echo "${MODELSIM_ALTERA_LIBS_DIR}"
-    mkdir "${MODELSIM_ALTERA_LIBS_DIR}"
-    echo "This dir is also used as modelsim_altera_libs dir" > ${MODELSIM_ALTERA_LIBS_DIR}/readme.txt
+    ln -s "${HDL_BUILD_QUARTUS_DIR}" "${MODELSIM_ALTERA_LIBS_DIR}"
 fi
 
 # modelsim uses this sim dir for testing
-- 
GitLab