Added: #1440 Utility function for running console tools

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent f9bddebfd8
commit 8f389a0957

@ -59,6 +59,7 @@ public:
static IPipelineInterface *getInstance();
// ***************** PLUGIN UTILITY FUNCTIONS *****************
// ************* DO NOT USE FROM INSIDE A PROCESS *************
/// Get the configuration file of the pipeline service. Must only be used for configuration values that may be different on different services, such as tool paths.
virtual NLMISC::CConfigFile &getConfigFile() = 0;

@ -85,6 +85,9 @@ public:
/// Delete a directory if it's empty
virtual void deleteDirectoryIfEmpty(const std::string &path) = 0;
/// Get a value from the local service configuration. Use only to get paths to tool executables and similar installed utilities
virtual std::string getConfig(const std::string &name) = 0;
/// Get a value from the currently active project configuration. If false, don't use, no need to write warnings to service log, already written, set exit state and exit if necessary
virtual bool getValue(std::string &result, const std::string &name) = 0;
virtual bool getValues(std::vector<std::string> &resultAppend, const std::string &name) = 0;
@ -111,6 +114,9 @@ public:
/// Set the exit state, must exit the plugin immediately afterwards. Use for configuration mistakes, etc
virtual void setExit(const TProcessResult exitLevel, const std::string &exitMessage) = 0;
/// Run a console tool. If failed, error state is set for you, call needsExit afterwards to check
virtual void runConsoleTool(const std::string &executablePath, const std::vector<std::string> &arguments) = 0;
}; /* class IPipelineProcess */
} /* namespace PIPELINE */

@ -54,14 +54,13 @@ CProcessInterface::~CProcessInterface()
void CProcessInterface::buildAtlas(const std::string &dependLog, const std::string &errorLog, const std::vector<std::string> &srcDirectories, const std::string &dstFile)
{
nldebug("Build atlas '%s'", dstFile.c_str());
std::stringstream ss;
ss << "build_interface -d" << dependLog << " -e" << errorLog << " " << dstFile;
std::vector<std::string> arguments;
arguments.push_back(std::string("-d") + dependLog);
arguments.push_back(std::string("-e") + errorLog);
arguments.push_back(dstFile);
for (std::vector<std::string>::const_iterator it = srcDirectories.begin(), end = srcDirectories.end(); it != end; ++it)
{
const std::string &path = *it;
ss << " " << path;
}
system(ss.str().c_str());
arguments.push_back(*it);
m_PipelineProcess->runConsoleTool(m_PipelineProcess->getConfig("ToolBuildInterface"), arguments);
}
void CProcessInterface::build()
@ -97,6 +96,7 @@ void CProcessInterface::build()
{
m_PipelineProcess->makePaths(dstFiles);
buildAtlas(dependLog, errorLog, srcDirectories, dstFile);
if (m_PipelineProcess->needsExit()) return;
m_PipelineProcess->parseToolLog(dependLog, errorLog, false);
}
if (m_PipelineProcess->needsExit()) return;

@ -40,6 +40,8 @@ PrimitivesDirectory = SharedLeveldesign + "/primitives";
// ToolDirectories = { "R:/build/dev/bin/Release", "D:/libraries/external/bin" };
// ToolSuffix = ".exe";
ToolBuildInterface = "build_interface";
// Ignored process plugins, like CProcessMaxShape, which should be completely ignored by the master service, even if they are configured to be used inside the process sheets.
// MasterIgnoreProcessPlugins = { }; // Only used by the master service. NOT USED, USE WORKSPACE INTEAD!
// MasterTerminalPassword = "MASTERCLIENTPASSWORD"; // Only used by the master service.

@ -36,6 +36,7 @@
#include <nel/misc/app_context.h>
#include <nel/misc/debug.h>
#include <nel/misc/path.h>
#include <nel/net/service.h>
// Project includes
#include "pipeline_service.h"
@ -114,6 +115,11 @@ void CPipelineProcessImpl::deleteDirectoryIfEmpty(const std::string &path)
/*}*/
}
std::string CPipelineProcessImpl::getConfig(const std::string &name)
{
return NLNET::IService::getInstance()->ConfigFile.getVar(name).asString(0);
}
bool CPipelineProcessImpl::getValue(std::string &result, const std::string &name)
{
if (m_ActiveProject == NULL)
@ -169,6 +175,16 @@ void CPipelineProcessImpl::makePaths(const std::vector<std::string> &outputPaths
}
}
void CPipelineProcessImpl::runConsoleTool(const std::string &executablePath, const std::vector<std::string> &arguments)
{
// FIXME: NOT SAFE FOR ARGUMENTS WITH SPACES
std::stringstream ss;
ss << executablePath;
for (std::vector<std::string>::const_iterator it = arguments.begin(), end = arguments.end(); it != end; ++it)
ss << " " << *it;
system(ss.str().c_str());
}
} /* namespace PIPELINE */
/* end of file */

@ -61,6 +61,9 @@ public:
virtual std::string getOutputDirectory();
virtual std::string getTempDirectory();
virtual void deleteDirectoryIfEmpty(const std::string &path);
virtual std::string getConfig(const std::string &name);
virtual bool getValue(std::string &result, const std::string &name);
virtual bool getValues(std::vector<std::string> &resultAppend, const std::string &name);
virtual bool getValueNb(uint &result, const std::string &name);
@ -75,6 +78,8 @@ public:
virtual bool needsExit();
virtual void setExit(const TProcessResult exitLevel, const std::string &exitMessage);
virtual void runConsoleTool(const std::string &executablePath, const std::vector<std::string> &arguments);
private:
CProcessPluginInfo m_ActivePlugin;

@ -90,6 +90,20 @@ void CPipelineProcessImpl::parseToolLog(const std::string &dependLogFile, const
{
m_SubTaskResult = FINISH_NOT;
if (!NLMISC::CFile::fileExists(dependLogFile))
{
m_SubTaskErrorMessage = "Depend log does not exist";
m_SubTaskResult = FINISH_ERROR;
return;
}
if (!NLMISC::CFile::fileExists(errorLogFile))
{
m_SubTaskErrorMessage = "Error log does not exist";
m_SubTaskResult = FINISH_ERROR;
return;
}
// Parse error log
{
// ...

Loading…
Cancel
Save