diff --git a/code/nel/tools/pipeline/service/metadata_storage.cpp b/code/nel/tools/pipeline/service/metadata_storage.cpp index 30b499937..c4b3bccaf 100644 --- a/code/nel/tools/pipeline/service/metadata_storage.cpp +++ b/code/nel/tools/pipeline/service/metadata_storage.cpp @@ -58,7 +58,6 @@ void CFileError::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) void CFileStatus::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) { uint version = stream.serialVersion(2); - // if (version >= 3) stream.serial(LastRemoved); else LastRemoved = 0; stream.serial(FirstSeen); stream.serial(LastChangedReference); if (version >= 2) stream.serial(LastFileSizeReference); else LastFileSizeReference = 0; @@ -94,6 +93,13 @@ void CProcessResult::clear() FileResults.clear(); } +void CFileOutput::serial(NLMISC::IStream &stream) throw (NLMISC::EStream) +{ + uint version = stream.serialVersion(1); + stream.serial(BuildStart); + stream.serialCont(MacroPaths); +} + /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// @@ -103,9 +109,9 @@ std::string CMetadataStorage::getStatusPath(const std::string &file) return CWorkspaceStorage::getMetaFilePath(file, PIPELINE_DATABASE_STATUS_SUFFIX); } -bool CMetadataStorage::readStatus(CFileStatus &status, const std::string &path) +bool CMetadataStorage::readStatus(CFileStatus &status, const std::string &metaPath) { - if (!NLMISC::CFile::fileExists(path)) + if (!NLMISC::CFile::fileExists(metaPath)) { status.FirstSeen = 0; status.LastChangedReference = 0; @@ -115,26 +121,26 @@ bool CMetadataStorage::readStatus(CFileStatus &status, const std::string &path) return false; } - nlassert(!NLMISC::CFile::isDirectory(path)); + nlassert(!NLMISC::CFile::isDirectory(metaPath)); - NLMISC::CIFile is(path, false); + NLMISC::CIFile is(metaPath, false); status.serial(is); is.close(); return true; } -void CMetadataStorage::writeStatus(const CFileStatus &status, const std::string &path) +void CMetadataStorage::writeStatus(const CFileStatus &status, const std::string &metaPath) { - NLMISC::COFile os(path, false, false, true); + NLMISC::COFile os(metaPath, false, false, true); const_cast(status).serial(os); os.flush(); os.close(); } -void CMetadataStorage::eraseStatus(const std::string &path) +void CMetadataStorage::eraseStatus(const std::string &metaPath) { - NLMISC::CFile::deleteFile(path); + NLMISC::CFile::deleteFile(metaPath); } /////////////////////////////////////////////////////////////////////// @@ -147,27 +153,27 @@ std::string CMetadataStorage::getResultPath(const std::string &projectName, cons std::string resultPath = CWorkspaceStorage::getMetaDirectoryPath( CWorkspaceStorage::getProjectDirectory(projectName)) + lwPluginName + PIPELINE_DATABASE_RESULT_SUFFIX; - nldebug("Result path: '%s'", resultPath.c_str()); + nldebug("Result metaPath: '%s'", resultPath.c_str()); return resultPath; } -void CMetadataStorage::readProcessResult(CProcessResult &result, const std::string &path) +void CMetadataStorage::readProcessResult(CProcessResult &result, const std::string &metaPath) { - if (!NLMISC::CFile::fileExists(path)) + if (!NLMISC::CFile::fileExists(metaPath)) { nlwarning("Process running for the first time, this may take a long time"); result.clear(); return; } - NLMISC::CIFile is(path, false); + NLMISC::CIFile is(metaPath, false); result.serial(is); is.close(); } -void CMetadataStorage::writeProcessResult(const CProcessResult &result, const std::string &path) +void CMetadataStorage::writeProcessResult(const CProcessResult &result, const std::string &metaPath) { - NLMISC::COFile os(path, false, false, true); + NLMISC::COFile os(metaPath, false, false, true); const_cast(result).serial(os); os.flush(); os.close(); @@ -177,6 +183,48 @@ void CMetadataStorage::writeProcessResult(const CProcessResult &result, const st /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// +std::string CMetadataStorage::getOutputPath(const std::string &file, const std::string &projectName, const std::string &pluginName) +{ + std::string lwProjectName = NLMISC::toLower(projectName); + std::string lwPluginName = NLMISC::toLower(pluginName); + return CWorkspaceStorage::getMetaFilePath(file, std::string(".") + lwProjectName + "." + lwPluginName + PIPELINE_DATABASE_OUTPUT_SUFFIX); +} + +bool CMetadataStorage::readOutput(CFileOutput &output, const std::string &metaPath) +{ + if (!NLMISC::CFile::fileExists(metaPath)) + { + output.BuildStart = 0; + output.MacroPaths.clear(); + return false; + } + + nlassert(!NLMISC::CFile::isDirectory(metaPath)); + + NLMISC::CIFile is(metaPath, false); + output.serial(is); + is.close(); + + return true; +} + +void CMetadataStorage::writeOutput(const CFileOutput &output, const std::string &metaPath) +{ + NLMISC::COFile os(metaPath, false, false, true); + const_cast(output).serial(os); + os.flush(); + os.close(); +} + +void CMetadataStorage::eraseOutput(const std::string &metaPath) +{ + NLMISC::CFile::deleteFile(metaPath); +} + +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// + } /* 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 0c63abb52..22d274261 100644 --- a/code/nel/tools/pipeline/service/metadata_storage.h +++ b/code/nel/tools/pipeline/service/metadata_storage.h @@ -129,6 +129,17 @@ public: void clear(); }; +/// Suffix for metafiles that contain the list of output files of an input file when it was last built (what happens to this meta when the file fails build? - erase it for now... forces a rebuild) +#define PIPELINE_DATABASE_OUTPUT_SUFFIX ".output" +struct CFileOutput +{ +public: + uint32 BuildStart; + std::vector MacroPaths; + + void serial(NLMISC::IStream &stream) throw (NLMISC::EStream); +}; + /** * \brief CMetadataStorage * \date 2012-07-30 14:31GMT @@ -142,9 +153,9 @@ public: // Note: Use the functions provided by CDatabaseStatus for manipulating status files. /// Format like .../something.somedirectory.meta/path/file.status static std::string getStatusPath(const std::string &file); - static bool readStatus(CFileStatus &status, const std::string &path); - static void writeStatus(const CFileStatus &status, const std::string &path); - static void eraseStatus(const std::string &path); + static bool readStatus(CFileStatus &status, const std::string &metaPath); + static void writeStatus(const CFileStatus &status, const std::string &metaPath); + static void eraseStatus(const std::string &metaPath); /// Format like .../something.somedirectory.meta/path/file.remove // static std::string getRemovePath(const std::string &file); @@ -154,8 +165,14 @@ public: // 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 &path); - static void writeProcessResult(const CProcessResult &result, const std::string &path); + static void readProcessResult(CProcessResult &result, const std::string &metaPath); + static void writeProcessResult(const CProcessResult &result, const std::string &metaPath); + + // Pathname for the output metadata file, like .../something.somedirectory.meta/path/file.projectname.pluginname.output + static std::string getOutputPath(const std::string &file, const std::string &projectName, const std::string &pluginName); + static bool readOutput(CFileOutput &output, const std::string &metaPath); + static void writeOutput(const CFileOutput &output, const std::string &metaPath); + static void eraseOutput(const std::string &metaPath); }; /* class CMetadataStorage */ diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp index 8d964bebc..fe7f2c3f9 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp @@ -624,8 +624,19 @@ public: } else // input files have changed { - // TODO: FIND IF ALL INPUT FILES HAVE A .output FILE - bool allInputFilesHaveOutputFile = (rand()) % 2 == 0; // ###################################fa + // Find out if all the input files have a .output file + bool allInputFilesHaveOutputFile = true; + for (std::vector::const_iterator it = inputPaths.begin(), end = inputPaths.end(); it != end; ++it) + { + const std::string &path = *it; + std::string outputMetaPath = CMetadataStorage::getOutputPath(path, m_ActiveProject->getName(), m_ActivePlugin.Handler); + if (!CFile::fileExists(outputMetaPath)) + { + nldebug("Found an input file that has no .output meta file"); + allInputFilesHaveOutputFile = false; + break; + } + } if (!allInputFilesHaveOutputFile) { nldebug("Not all input files have an .output files, rebuild"); @@ -668,7 +679,7 @@ public: // Do nothing // Else (no input was changed) // Input files did not change, but output may have been tampered with - // neesFurtherInfo = true; + // needsFurtherInfo = true; // Copy the .output file into the output paths // End