From 7def04c28eafb9912db89a17130438b74e43e3ea Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 3 Aug 2012 20:43:17 +0200 Subject: [PATCH] Added: #1440 Utility function for creating output path structures --HG-- branch : build_pipeline_v3 --- .../pipeline/plugin_library/pipeline_process.h | 4 ++++ .../pipeline/plugin_nel/process_interface.cpp | 17 +++++++++++------ .../pipeline/service/pipeline_process_impl.cpp | 18 ++++++++++++++++++ .../pipeline/service/pipeline_process_impl.h | 2 ++ .../pipeline/service/pipeline_project.cpp | 1 + 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/code/nel/tools/pipeline/plugin_library/pipeline_process.h b/code/nel/tools/pipeline/plugin_library/pipeline_process.h index 68256407d..10acabbbe 100644 --- a/code/nel/tools/pipeline/plugin_library/pipeline_process.h +++ b/code/nel/tools/pipeline/plugin_library/pipeline_process.h @@ -96,6 +96,10 @@ public: virtual bool needsToBeRebuilt(const std::vector &inputPaths) = 0; bool needsToBeRebuilt(const std::string &inputPath) { std::vector inputPaths; inputPaths.push_back(inputPath); return needsToBeRebuilt(inputPaths); } + /// Create directories for paths. Call for output paths + virtual void makePaths(const std::vector &outputPaths) = 0; + void makePaths(const std::string &outputPath) { std::vector 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; diff --git a/code/nel/tools/pipeline/plugin_nel/process_interface.cpp b/code/nel/tools/pipeline/plugin_nel/process_interface.cpp index 9d8f07732..9f7b5de82 100644 --- a/code/nel/tools/pipeline/plugin_nel/process_interface.cpp +++ b/code/nel/tools/pipeline/plugin_nel/process_interface.cpp @@ -54,6 +54,14 @@ CProcessInterface::~CProcessInterface() void CProcessInterface::buildAtlas(const std::vector &srcDirectories, const std::string &dstFile) { nldebug("Build atlas '%s'", dstFile.c_str()); + std::stringstream ss; + ss << "build_interface " << dstFile; + for (std::vector::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; } } } diff --git a/code/nel/tools/pipeline/service/pipeline_process_impl.cpp b/code/nel/tools/pipeline/service/pipeline_process_impl.cpp index 245125e1b..87b822b44 100644 --- a/code/nel/tools/pipeline/service/pipeline_process_impl.cpp +++ b/code/nel/tools/pipeline/service/pipeline_process_impl.cpp @@ -35,6 +35,7 @@ #include #include #include +#include // 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 &outputPaths) +{ + for (std::vector::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 */ diff --git a/code/nel/tools/pipeline/service/pipeline_process_impl.h b/code/nel/tools/pipeline/service/pipeline_process_impl.h index 9a376daee..025712ff8 100644 --- a/code/nel/tools/pipeline/service/pipeline_process_impl.h +++ b/code/nel/tools/pipeline/service/pipeline_process_impl.h @@ -67,6 +67,8 @@ public: virtual bool needsToBeRebuilt(const std::vector &inputPaths, const std::vector &outputPaths); virtual bool needsToBeRebuilt(const std::vector &inputPaths); + virtual void makePaths(const std::vector &outputPaths); + virtual void parseToolLog(const std::string &dependLogFile, const std::string &errorLogFile, bool writeOutputMeta); virtual bool needsExit(); diff --git a/code/nel/tools/pipeline/service/pipeline_project.cpp b/code/nel/tools/pipeline/service/pipeline_project.cpp index 1ee4067a6..c9f8e78c8 100644 --- a/code/nel/tools/pipeline/service/pipeline_project.cpp +++ b/code/nel/tools/pipeline/service/pipeline_project.cpp @@ -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;