Added: #1440 Utility function for creating output path structures

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent d3c1988edb
commit 7def04c28e

@ -96,6 +96,10 @@ public:
virtual bool needsToBeRebuilt(const std::vector<std::string> &inputPaths) = 0;
bool needsToBeRebuilt(const std::string &inputPath) { std::vector<std::string> inputPaths; inputPaths.push_back(inputPath); return needsToBeRebuilt(inputPaths); }
/// Create directories for paths. Call for output paths
virtual void makePaths(const std::vector<std::string> &outputPaths) = 0;
void makePaths(const std::string &outputPath) { std::vector<std::string> outputPaths; outputPaths.push_back(outputPath); makePaths(outputPaths); }
/// Parse the depend and error logs. Only set writeOutputMeta true if the output is not known in advance by the plugin, see needsToBeRebuilt
virtual void parseToolLog(const std::string &dependLogFile, const std::string &errorLogFile, bool writeOutputMeta) = 0;

@ -54,6 +54,14 @@ CProcessInterface::~CProcessInterface()
void CProcessInterface::buildAtlas(const std::vector<std::string> &srcDirectories, const std::string &dstFile)
{
nldebug("Build atlas '%s'", dstFile.c_str());
std::stringstream ss;
ss << "build_interface " << 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());
}
void CProcessInterface::build()
@ -78,16 +86,13 @@ void CProcessInterface::build()
ss << "Interface.Atlas[" << i << "].DstFile";
if (!m_PipelineProcess->getValue(dstFile, ss.str())) break;
}
// GO
if (m_PipelineProcess->needsToBeRebuilt(srcDirectories, dstFile))
{
// TODO
nldebug("Need to rebuild");
m_PipelineProcess->makePaths(dstFile);
buildAtlas(srcDirectories, dstFile);
m_PipelineProcess->parseToolLog("", "", false);
}
else nldebug("Don't need to rebuild");
if (m_PipelineProcess->needsExit())
return;
if (m_PipelineProcess->needsExit()) return;
}
}
}

@ -35,6 +35,7 @@
#include <nel/misc/time_nl.h>
#include <nel/misc/app_context.h>
#include <nel/misc/debug.h>
#include <nel/misc/path.h>
// Project includes
#include "pipeline_service.h"
@ -90,6 +91,7 @@ std::string CPipelineProcessImpl::getTempDirectory()
ss << rand();
ss << PIPELINE_DIRECTORY_TEMP_SUFFIX;
ss << "/";
NLMISC::CFile::createDirectoryTree(ss.str());
return ss.str();
}
else
@ -137,6 +139,22 @@ bool CPipelineProcessImpl::getValueNb(uint &result, const std::string &name)
}
}
void CPipelineProcessImpl::makePaths(const std::vector<std::string> &outputPaths)
{
for (std::vector<std::string>::const_iterator it = outputPaths.begin(), end = outputPaths.end(); it != end; ++it)
{
const std::string &path = *it;
if (path[path.size() - 1] == '/') // isDirectory
{
NLMISC::CFile::createDirectoryTree(path);
}
else
{
NLMISC::CFile::createDirectoryTree(NLMISC::CFile::getPath(path));
}
}
}
} /* namespace PIPELINE */
/* end of file */

@ -67,6 +67,8 @@ public:
virtual bool needsToBeRebuilt(const std::vector<std::string> &inputPaths, const std::vector<std::string> &outputPaths);
virtual bool needsToBeRebuilt(const std::vector<std::string> &inputPaths);
virtual void makePaths(const std::vector<std::string> &outputPaths);
virtual void parseToolLog(const std::string &dependLogFile, const std::string &errorLogFile, bool writeOutputMeta);
virtual bool needsExit();

@ -225,6 +225,7 @@ std::string CPipelineProject::getTempDirectory()
ss << rand();
ss << PIPELINE_DIRECTORY_TEMP_SUFFIX;
ss << "/";
NLMISC::CFile::createDirectoryTree(ss.str());
m_TempDirectory = ss.str();
}
return m_TempDirectory;

Loading…
Cancel
Save