From 0b6915017aeefa7cd891e016f4585fa106d9f090 Mon Sep 17 00:00:00 2001 From: Anna Born Date: Wed, 18 Jan 2023 13:37:21 +0100 Subject: [PATCH] dont check deployment executable if it is required (WIP) --- src/Deployment.cpp | 46 ++++++++++++++++++++++++++++------------------ src/Deployment.hpp | 34 +++++++++++++++++----------------- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/Deployment.cpp b/src/Deployment.cpp index 21099bb..b0e2f3b 100644 --- a/src/Deployment.cpp +++ b/src/Deployment.cpp @@ -10,27 +10,32 @@ using namespace orocos_cpp; -Deployment::Deployment(const std::string& name) : deploymentName(name), withValgrind(false) +Deployment::Deployment(const std::string& name, int doExecutableCheck) : deploymentName(name), withValgrind(false) { loadPkgConfigFile(name); - if(!checkExecutable(name)) - throw std::runtime_error("Deployment::Error, executable for deployment '" + name + "' could not be found in PATH"); + if (doExecutableCheck == 0) { + LOG_DEBUG_S << "Deployment::Warn, the existence of the deployment executable " << name << " in the local workspace will be CHECKED."; + if(!checkExecutable(name)) + throw std::runtime_error("Deployment::Error, executable for deployment '" + name + "' could not be found in PATH"); + } else { + LOG_WARN_S << "Deployment::Warn, No check for the existence of the deployment executable " << name << " in the local workspace."; + } } -Deployment::Deployment(const std::string &cmp1, const std::string &as) : withValgrind(false) +Deployment::Deployment(const std::string &cmp1, const std::string &as, int doExecutableCheck) : withValgrind(false) { //cmp1 is expected in the format "module::TaskSpec" std::string::size_type pos = cmp1.find_first_of(":"); - + if(pos == std::string::npos || cmp1.at(pos +1) != ':') { throw std::runtime_error("given component name " + cmp1 + " is not in the format 'module::TaskSpec'"); } - + std::string moduleName = cmp1.substr(0, pos); std::string taskModelName = cmp1.substr(pos + 2, cmp1.size()) ; std::string defaultDeploymentName = "orogen_default_" + moduleName + "__" + taskModelName; - + deploymentName = defaultDeploymentName; try { loadPkgConfigFile(deploymentName); @@ -38,12 +43,17 @@ Deployment::Deployment(const std::string &cmp1, const std::string &as) : withVal { throw std::runtime_error("Deployment::Error, could not find pkgConfig file for deployment " + deploymentName); } - if(!checkExecutable(deploymentName)) - throw std::runtime_error("Deployment::Error, executable for deployment " + deploymentName + " could not be found in PATH"); + if (doExecutableCheck == 0) { + LOG_DEBUG_S << "Deployment::Warn, the existence of the deployment executable " << deploymentName << " in the local workspace will be CHECKED."; + if(!checkExecutable(deploymentName)) + throw std::runtime_error("Deployment::Error, executable for deployment " + deploymentName + " could not be found in PATH"); + } else { + LOG_WARN_S << "Deployment::Warn, No check for the existence of the deployment executable " << deploymentName << " in the local workspace."; + } std::string taskName = as; std::vector args; - + if(!taskName.empty()) { renameTask(defaultDeploymentName, taskName); @@ -65,18 +75,18 @@ bool Deployment::checkExecutable(const std::string& name) { if(boost::filesystem::exists(name)) return true; - + const char *binPath = getenv("PATH"); if(!binPath) { throw std::runtime_error("Deployment::Internal Error, PATH is not set found."); } - + std::string binPathS = binPath; - + boost::char_separator sep(":"); boost::tokenizer > paths(binPathS, sep); - + for(const std::string &path: paths) { std::string candidate = path + "/" + name; @@ -117,7 +127,7 @@ bool Deployment::loadPkgConfigFile(const std::string& deploymentName) { renameMap[taskName] = taskName; tasks.push_back(taskName); - + //Identify if task is logger... //FIXME: Looks complicated. Does it look for the longest task name with '_Logger' suffix? WHy not simply assume '#{deploymentName}_Logger'? std::string loggerString("_Logger"); @@ -152,7 +162,7 @@ void Deployment::renameTask(const std::string& orignalName, const std::string& n { throw std::runtime_error("Deployment::renameTask : Error, deployment " + deploymentName + " has no task " + orignalName); } - + //set new name std::string origName = it->second; renameMap.erase(it); @@ -168,7 +178,7 @@ bool Deployment::getExecString(std::string& cmd, std::vector< std::string >& arg args.clear(); cmd = deploymentName; - + //FIXME: Better handle Valgrind (and GDB and possibly more) at the software module that actually controls the processes. E.g. ProcessServer in cnd/orogen/execution if(withValgrind) { @@ -192,7 +202,7 @@ bool Deployment::getExecString(std::string& cmd, std::vector< std::string >& arg for(const std::string& arg : cmdLineArgs) args.push_back(arg); - + return true; } diff --git a/src/Deployment.hpp b/src/Deployment.hpp index 9f425a0..0fbe498 100644 --- a/src/Deployment.hpp +++ b/src/Deployment.hpp @@ -14,64 +14,64 @@ class Deployment : public boost::noncopyable private: bool loadPkgConfigFile(const std::string &deploymentName); bool checkExecutable(const std::string &name); - + std::vector typekits; std::vector tasks; //this map contains a map from currentName to Origininal Name std::map renameMap; - + void regenerateNameVectors(); - + std::string deploymentName; std::string loggerName; bool withValgrind; std::vector cmdLineArgs; - + public: - Deployment(const std::string &name); - - Deployment(const std::string &model, const std::string &as); - + Deployment(const std::string &name, int doExecutableCheck = 0); + + Deployment(const std::string &model, const std::string &as, int doExecutableCheck = 0); + /** * Returns the name of the deployment * */ const std::string &getName() const; - + /** * Returns the task names, after renaming. * */ const std::vector &getTaskNames() const; - + const std::vector &getNeededTypekits() const; - + /** * Renames a task from the deployment to the given name * */ void renameTask(const std::string &orignalName, const std::string &newName); /** - * Returns the command line string, needed to - * start the deployment, including the renaming + * Returns the command line string, needed to + * start the deployment, including the renaming * operations. * */ bool getExecString(std::string& cmd, std::vector< std::string >& args); - + /** * Returns the name of the logger for this deployment * */ const std::string getLoggerName() const; - + /** * Returns if this deployment contains a logger * */ bool hasLogger() const; - + /** * If called, the deployment will be started within valgrind * */ - void runWithValgrind(); + void runWithValgrind(); /** * Set additional command line arguments. Default is empty