From f9de7ed61693faba21d6a90c922604cc6889eb35 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 1 Aug 2012 13:03:01 +0200 Subject: [PATCH] Added: #1440 Placeholder function for reading previous process run results --HG-- branch : build_pipeline_v3 --- .../pipeline/service/metadata_storage.cpp | 30 +++++++++++++++++-- .../tools/pipeline/service/metadata_storage.h | 14 ++++++--- .../service/pipeline_process_impl.cpp | 1 + .../pipeline/service/pipeline_project.cpp | 5 +++- .../pipeline/service/workspace_storage.cpp | 6 ++++ .../pipeline/service/workspace_storage.h | 3 +- 6 files changed, 50 insertions(+), 9 deletions(-) diff --git a/code/nel/tools/pipeline/service/metadata_storage.cpp b/code/nel/tools/pipeline/service/metadata_storage.cpp index 40541ce27..fed910d07 100644 --- a/code/nel/tools/pipeline/service/metadata_storage.cpp +++ b/code/nel/tools/pipeline/service/metadata_storage.cpp @@ -72,17 +72,18 @@ void CFileRemove::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) stream.serial(Lost); } -void CProjectResult::CFileResult::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) +void CProcessResult::CFileResult::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) { uint version = stream.serialVersion(1); stream.serial(CRC32); stream.serial((uint8 &)Level); // test this :o) } -void CProjectResult::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) +void CProcessResult::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) { uint version = stream.serialVersion(1); - stream.serialCont(FilePaths); + stream.serial(LastSuccessfulBuildStart); + stream.serialCont(MacroPaths); stream.serialCont(FileResults); } @@ -133,6 +134,29 @@ void CMetadataStorage::eraseStatus(const std::string &path) /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// +std::string CMetadataStorage::getResultPath(const std::string &projectName, const std::string &pluginName) +{ + std::string lwPluginName = NLMISC::toLower(pluginName); + std::string resultPath = CWorkspaceStorage::getMetaDirectoryPath( + CWorkspaceStorage::getProjectDirectory(projectName)) + + lwPluginName + PIPELINE_DATABASE_RESULT_SUFFIX; + nldebug("Result path: '%s'", resultPath.c_str()); + return resultPath; +} + +void CMetadataStorage::readProcessResult(CProcessResult &result, const std::string &path) +{ + // TODO + result.LastSuccessfulBuildStart = 0; + result.MacroPaths.clear(); + result.FileResults.clear(); + // TODO +} + +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// + } /* namespace PIPELINE */ /* end of file */ diff --git a/code/nel/tools/pipeline/service/metadata_storage.h b/code/nel/tools/pipeline/service/metadata_storage.h index eb2150433..9b8f55458 100644 --- a/code/nel/tools/pipeline/service/metadata_storage.h +++ b/code/nel/tools/pipeline/service/metadata_storage.h @@ -103,12 +103,17 @@ public: #define PIPELINE_DATABASE_DEPEND_SUFFIX ".depend" // ....................... -/// Suffix for metafiles that contain the result of the last build of a project +/// Suffix for metafiles that contain the result of the last build of a process #define PIPELINE_DATABASE_RESULT_SUFFIX ".result" -struct CProjectResult +struct CProcessResult { public: - std::vector FilePaths; + // Note: this file may have been erased on build start in case something went wrong! + // In that case, the last successfulbuild start is 0, and no output files will be known. + // This is the same situation as if the project never built before. + // It must be handled sanely. + uint32 LastSuccessfulBuildStart; + std::vector MacroPaths; struct CFileResult { uint32 CRC32; @@ -145,7 +150,8 @@ public: // static void eraseRemove(const std::string &path); // Pathname for result metadata is like .../project.projectname.meta/pluginname.result - // static std::string getResultPath(const std::string &projectName, const std::string &pluginName); + static std::string getResultPath(const std::string &projectName, const std::string &pluginName); + static void readProcessResult(CProcessResult &result, const std::string &path); }; /* class CMetadataStorage */ diff --git a/code/nel/tools/pipeline/service/pipeline_process_impl.cpp b/code/nel/tools/pipeline/service/pipeline_process_impl.cpp index 35e02f636..f785176f5 100644 --- a/code/nel/tools/pipeline/service/pipeline_process_impl.cpp +++ b/code/nel/tools/pipeline/service/pipeline_process_impl.cpp @@ -87,6 +87,7 @@ std::string CPipelineProcessImpl::getTempDirectory() ss << "."; ss << rand(); ss << PIPELINE_DIRECTORY_TEMP_SUFFIX; + ss << "/"; return ss.str(); } else diff --git a/code/nel/tools/pipeline/service/pipeline_project.cpp b/code/nel/tools/pipeline/service/pipeline_project.cpp index be98af81a..1ee4067a6 100644 --- a/code/nel/tools/pipeline/service/pipeline_project.cpp +++ b/code/nel/tools/pipeline/service/pipeline_project.cpp @@ -41,6 +41,7 @@ // Project includes #include "pipeline_service.h" +#include "workspace_storage.h" using namespace std; // using namespace NLMISC; @@ -206,7 +207,8 @@ std::string CPipelineProject::getName() std::string CPipelineProject::getOutputDirectory() { - return g_WorkDir + PIPELINE_DIRECTORY_PREFIX_PROJECT + getName() + "/"; + // return g_WorkDir + PIPELINE_DIRECTORY_PREFIX_PROJECT + getName() + "/"; + return CWorkspaceStorage::getProjectDirectory(getName()); } std::string CPipelineProject::getTempDirectory() @@ -222,6 +224,7 @@ std::string CPipelineProject::getTempDirectory() ss << "."; ss << rand(); ss << PIPELINE_DIRECTORY_TEMP_SUFFIX; + ss << "/"; m_TempDirectory = ss.str(); } return m_TempDirectory; diff --git a/code/nel/tools/pipeline/service/workspace_storage.cpp b/code/nel/tools/pipeline/service/workspace_storage.cpp index 04cc8188b..dc980ea28 100644 --- a/code/nel/tools/pipeline/service/workspace_storage.cpp +++ b/code/nel/tools/pipeline/service/workspace_storage.cpp @@ -145,6 +145,12 @@ std::string CWorkspaceStorage::getMetaDirectoryPath(const std::string &path) return standardizePath(CWorkspaceStorage::getMetaFilePath(path, ""), true); } +std::string CWorkspaceStorage::getProjectDirectory(const std::string &projectName) +{ + std::string lwProjectName = NLMISC::toLower(projectName); + return g_WorkDir + PIPELINE_DIRECTORY_PREFIX_PROJECT + lwProjectName + "/"; +} + } /* namespace PIPELINE */ /* end of file */ diff --git a/code/nel/tools/pipeline/service/workspace_storage.h b/code/nel/tools/pipeline/service/workspace_storage.h index 47c5d9cce..3e12c26da 100644 --- a/code/nel/tools/pipeline/service/workspace_storage.h +++ b/code/nel/tools/pipeline/service/workspace_storage.h @@ -56,7 +56,8 @@ public: /// Get the directory where metadata files are stored, based on the filepath containing the files which the containing metadata represents static std::string getMetaDirectoryPath(const std::string &path); - // TODO: getProjectDirectory /// Format like .../project.common/ + /// Format like .../project.someproject/ + static std::string getProjectDirectory(const std::string &projectName); }; /* class CWorkspaceStorage */