提交 879450e6 编写于 作者: L Levi-Armstrong 提交者: Levi Armstrong

Improve sourcing workspace when it does not contain ros packages

上级 ca95d913
......@@ -86,14 +86,30 @@ void ROSGenericRunStep::run()
if (workspaceInfo.install)
sourcePath = Utils::FilePath(workspaceInfo.installPath);
Utils::FilePath source_bash_file = sourcePath.pathAppended("setup.bash");
Utils::FilePath source_shell_file = sourcePath.pathAppended("setup.sh");
Utils::FilePath source_zshell_file = sourcePath.pathAppended("setup.zsh");
if (shell.fileName() == "bash")
source_cmd = QString("source %1\n").arg(sourcePath.pathAppended("setup.bash").toString());
{
// Some reason if a workspace does not contain at least one catkin package it does not generate a setup.bash only a setup.sh
if (source_bash_file.exists())
source_cmd = QString("source %1\n").arg(source_bash_file.toString());
else
source_cmd = QString("source %1\n").arg(source_shell_file.toString());
}
else if (shell.fileName() == "sh")
source_cmd = QString("source %1\n").arg(sourcePath.pathAppended("setup.sh").toString());
{
source_cmd = QString("source %1\n").arg(source_shell_file.toString());
}
else if (shell.fileName() == "zsh")
source_cmd = QString("source %1\n").arg(sourcePath.pathAppended("setup.zsh").toString());
{
source_cmd = QString("source %1\n").arg(source_zshell_file.toString());
}
else
{
Core::MessageManager::writeFlashing(tr("[ROS Error] The shell: %1 is currently not supported (Use bash, sh, or zsh)!").arg(shell.toString()));
}
//create terminal without starting shell
QTermWidget &terminal = ROSProjectPlugin::instance()->startTerminal(0, command);
......
......@@ -73,20 +73,28 @@ bool ROSUtils::sourceWorkspace(QProcess *process, const WorkspaceInfo &workspace
if (!initializeWorkspace(process, workspaceInfo))
return false;
Utils::FilePath bash(workspaceInfo.develPath);
Utils::FilePath sourcePath(workspaceInfo.develPath);
if (workspaceInfo.install)
bash = Utils::FilePath(workspaceInfo.installPath);
sourcePath = Utils::FilePath(workspaceInfo.installPath);
bash = bash.pathAppended(QLatin1String("setup.bash"));
if (bash.exists())
Utils::FilePath source_bash_file = sourcePath.pathAppended("setup.bash");
Utils::FilePath source_shell_file = sourcePath.pathAppended("setup.sh");
if (source_bash_file.exists())
{
Core::MessageManager::writeSilently(QObject::tr("[ROS Debug] Sourced workspace: %1.").arg(bash.toString()));
if (sourceWorkspaceHelper(process, bash.toString()))
Core::MessageManager::writeSilently(QObject::tr("[ROS Debug] Sourced workspace: %1.").arg(source_bash_file.toString()));
if (sourceWorkspaceHelper(process, source_bash_file.toString()))
return true;
}
else if (source_shell_file.exists())
{
// Some reason if a workspace does not contain at least one catkin package it does not generate a setup.bash only a setup.sh
Core::MessageManager::writeSilently(QObject::tr("[ROS Debug] Sourced workspace: %1.").arg(source_shell_file.toString()));
if (sourceWorkspaceHelper(process, source_shell_file.toString()))
return true;
}
else
{
Core::MessageManager::writeSilently(QObject::tr("[ROS Warning] Failed to source workspace because this file does not exist: %1.").arg(bash.toString()));
Core::MessageManager::writeSilently(QObject::tr("[ROS Warning] Failed to source workspace because either of these files do not exist: %1 or %2.").arg(source_bash_file.toString(), source_shell_file.toString()));
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册