From cefc026b1c5014c9bcaf837b822a0d74fd3b75af Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 3 Aug 2012 13:35:08 +0200 Subject: [PATCH] Added: #1440 Depend metafile --HG-- branch : build_pipeline_v3 --- .../pipeline/service/metadata_storage.cpp | 49 +++++++++++++++++++ .../tools/pipeline/service/metadata_storage.h | 20 +++++++- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/code/nel/tools/pipeline/service/metadata_storage.cpp b/code/nel/tools/pipeline/service/metadata_storage.cpp index c4b3bccaf..a1a61eae0 100644 --- a/code/nel/tools/pipeline/service/metadata_storage.cpp +++ b/code/nel/tools/pipeline/service/metadata_storage.cpp @@ -71,6 +71,20 @@ void CFileRemove::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) stream.serial(Lost); } +void CFileDepend::CDependency::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) +{ + uint version = stream.serialVersion(1); + stream.serial(CRC32); + stream.serial(MacroPath); +} + +void CFileDepend::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) +{ + uint version = stream.serialVersion(1); + stream.serial(CRC32); + stream.serialCont(Dependencies); +} + void CProcessResult::CFileResult::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) { uint version = stream.serialVersion(1); @@ -225,6 +239,41 @@ void CMetadataStorage::eraseOutput(const std::string &metaPath) /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// +std::string CMetadataStorage::getDependPath(const std::string &file) +{ + return CWorkspaceStorage::getMetaFilePath(file, PIPELINE_DATABASE_DEPEND_SUFFIX); +} + +bool CMetadataStorage::readDepend(CFileDepend &depend, const std::string &metaPath) +{ + if (!NLMISC::CFile::fileExists(metaPath)) + { + depend.CRC32 = 0; + depend.Dependencies.clear(); + return false; + } + + nlassert(!NLMISC::CFile::isDirectory(metaPath)); + + NLMISC::CIFile is(metaPath, false); + depend.serial(is); + is.close(); + + return true; +} + +void CMetadataStorage::writeDepend(const CFileDepend &depend, const std::string &metaPath) +{ + NLMISC::COFile os(metaPath, false, false, true); + const_cast(depend).serial(os); + os.flush(); + os.close(); +} + +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// + } /* 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 22d274261..60a890b3f 100644 --- a/code/nel/tools/pipeline/service/metadata_storage.h +++ b/code/nel/tools/pipeline/service/metadata_storage.h @@ -101,7 +101,21 @@ public: /// Suffix for metafiles that contain dependencies for a file #define PIPELINE_DATABASE_DEPEND_SUFFIX ".depend" -// ....................... +struct CFileDepend +{ +public: + uint32 CRC32; // Checksum of the current file + struct CDependency + { + std::string MacroPath; + uint32 CRC32; + + void serial(NLMISC::IStream &stream) throw (NLMISC::EStream); + }; + std::vector Dependencies; + + void serial(NLMISC::IStream &stream) throw (NLMISC::EStream); +}; /// Suffix for metafiles that contain the result of the last build of a process #define PIPELINE_DATABASE_RESULT_SUFFIX ".result" @@ -163,6 +177,10 @@ public: // static void createRemove(const CFileRemove &remove, const std::string &path); // Remove cannot be modified after creation, only erased. // static void eraseRemove(const std::string &path); + static std::string getDependPath(const std::string &file); + static bool readDepend(CFileDepend &status, const std::string &metaPath); + static void writeDepend(const CFileDepend &status, const std::string &metaPath); + // Pathname for result metadata is like .../project.projectname.meta/pluginname.result static std::string getResultPath(const std::string &projectName, const std::string &pluginName); static void readProcessResult(CProcessResult &result, const std::string &metaPath);