From b46ba50fd0f4a1098f81b4dc1607270c2143845e Mon Sep 17 00:00:00 2001 From: Hong Chen Date: Tue, 17 Sep 2024 10:59:52 -0500 Subject: [PATCH] Added optional remote shell config file for the remote startup command. (#1771) * Added optional remote sheel config file for the remote startup command. * Updated to cd to the sim directory after sourcing a config file in case the config file changed pwd. --- include/trick/Master.hh | 3 +++ trick_source/sim_services/MasterSlave/Master.cpp | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/include/trick/Master.hh b/include/trick/Master.hh index f0479e00..3ce2eb17 100644 --- a/include/trick/Master.hh +++ b/include/trick/Master.hh @@ -83,6 +83,9 @@ namespace Trick { to change to that directory before calling S_main_name.\n */ std::string sim_path; /**< trick_units(--) */ + /** @userdesc Optional shell environment setup config file for the slave shell.\n */ + std::string remote_shell_config_file; /**< trick_units(--) */ + /** @userdesc Slave executable name, default is "./S_main_${TRICK_HOST_CPU}.exe".\n */ std::string S_main_name; /**< trick_units(--) */ diff --git a/trick_source/sim_services/MasterSlave/Master.cpp b/trick_source/sim_services/MasterSlave/Master.cpp index d4c834a6..7a4c91e8 100644 --- a/trick_source/sim_services/MasterSlave/Master.cpp +++ b/trick_source/sim_services/MasterSlave/Master.cpp @@ -127,6 +127,14 @@ int Trick::SlaveInfo::start() { startup_command << " 'cd " << sim_path << " ; " ; } + /** @li Set up remote shell environment if needed for the remote startup command */ + if ( !remote_shell_config_file.empty() ) { + startup_command << " source " << remote_shell_config_file << " ; " ; + // cd to sim_path directory again if in case the config file changed pwd + // to a different directory other than the sim_path + startup_command << " cd " << sim_path << " ; " ; + } + if (strstr(passp->pw_shell, "csh")) { startup_command << " setenv TRICK_HOST_CPU `trick-gte TRICK_HOST_CPU` ; " ; } else {