diff --git a/code/nel/tools/pipeline/service/build_task_queue.cpp b/code/nel/tools/pipeline/service/build_task_queue.cpp index 31e20ef85..f29ed392f 100644 --- a/code/nel/tools/pipeline/service/build_task_queue.cpp +++ b/code/nel/tools/pipeline/service/build_task_queue.cpp @@ -95,15 +95,59 @@ void CBuildTaskQueue::loadQueue(CPipelineWorkspace *workspace, bool bypassDepend m_Tasks.push_back(info); info->ProjectName = projectName; info->ProcessPluginId = processHandlerId; - // info->Dependencies + + nlassert(builtTaskByPlugin.find(processHandlerId) == builtTaskByPlugin.end()); + builtTaskByPlugin[processHandlerId] = info; } - // TODO: PROCESS DEPENDENCIES + if (processHandlers.size() == 0) + { + nlwarning("Project '%s' tries to use unknown process '%s'", projectName.c_str(), processName.c_str()); + } } - // TODO: PROJECT DEPENDENCIES + // Dependencies between processes inside a project + for (std::map::iterator it = builtTaskByPlugin.begin(), end = builtTaskByPlugin.end(); it != end; ++it) + { + CBuildTaskInfo *task = it->second; + std::vector processDependencies; + workspace->getProcessPluginDependencies(processDependencies, task->ProcessPluginId); + + for (std::vector::iterator dep_it = processDependencies.begin(), dep_end = processDependencies.end(); dep_it != dep_end; ++dep_it) + { + std::string &processName = (*dep_it); + std::vector processHandlers; + workspace->getProcessPlugins(processHandlers, processName); + + for (std::vector::iterator h_it = processHandlers.begin(), h_end = processHandlers.end(); h_it != h_end; ++h_it) + { + uint32 processHandlerId = (*h_it).Id.Global; + + std::map::iterator depIt = builtTaskByPlugin.find(processHandlerId); + if (depIt != builtTaskByPlugin.end()) + { + task->Dependencies.push_back(depIt->second->Id.Sub.Task); + } + else + { + CProcessPluginInfo badProcessPlugin; + workspace->getProcessPlugin(badProcessPlugin, task->ProcessPluginId); + nlwarning("Project '%s' task process handler '%s' depends on process '%s' which is not part of the project", projectName.c_str(), badProcessPlugin.Handler.c_str(), processName.c_str()); + } + } + + if (processHandlers.size() == 0) + { + CProcessPluginInfo badProcessPlugin; + workspace->getProcessPlugin(badProcessPlugin, task->ProcessPluginId); + nlwarning("Project '%s' task process handler '%s' depends on process '%s' which does not exist in any known plugin", projectName.c_str(), badProcessPlugin.Handler.c_str(), processName.c_str()); + } + } + } } + // TODO_TODO_TODO Dependencies between projects ************************************************************************* + m_Mutex.unlock(); } diff --git a/code/nel/tools/pipeline/service/pipeline_workspace.cpp b/code/nel/tools/pipeline/service/pipeline_workspace.cpp index 7a52fbf88..c35d493ab 100644 --- a/code/nel/tools/pipeline/service/pipeline_workspace.cpp +++ b/code/nel/tools/pipeline/service/pipeline_workspace.cpp @@ -205,6 +205,38 @@ bool CPipelineWorkspace::getProcessPlugin(CProcessPluginInfo &result, uint32 glo else return false; } +bool CPipelineWorkspace::getProcessPluginDependencies(std::vector &resultProcesses, uint32 globalId) +{ + resultProcesses.clear(); + CProcessPluginId id; + id.Global = globalId; + if (id.Sub.Plugin >= m_Plugins.size()) + { + nlwarning("Plugin id out of range"); + return false; + } + NLMISC::CRefPtr pluginForm = m_Plugins[id.Sub.Plugin]; + UFormElm *processHandlers; + if (!pluginForm->getRootNode().getNodeByName(&processHandlers, "ProcessHandlers")) return false; + UFormElm *handler; + if (!processHandlers->getArrayNode(&handler, id.Sub.Handler)) return false; + UFormElm *processDependencies; + if (!handler->getNodeByName(&processDependencies, "ProcessDependencies")) return false; + if (!processDependencies) return false; + uint nb; + if (!processDependencies->getArraySize(nb)) return false; + resultProcesses.resize(nb); + for (uint i = 0; i < nb; ++i) + { + if (!processDependencies->getArrayValue(resultProcesses[i], i)) + { + resultProcesses.clear(); + return false; + } + } + return true; +} + void CPipelineWorkspace::listAvailablePlugins(std::vector &result) { result.clear(); diff --git a/code/nel/tools/pipeline/service/pipeline_workspace.h b/code/nel/tools/pipeline/service/pipeline_workspace.h index 50afd583a..cb1069bcd 100644 --- a/code/nel/tools/pipeline/service/pipeline_workspace.h +++ b/code/nel/tools/pipeline/service/pipeline_workspace.h @@ -93,6 +93,7 @@ public: void getProcessPlugins(std::vector &resultAppend, const std::string &process); CPipelineProject *getProject(const std::string &project); bool getProcessPlugin(CProcessPluginInfo &result, uint32 globalId); + bool getProcessPluginDependencies(std::vector &resultProcesses, uint32 globalId); inline const std::map &getProjects() { return m_Projects; }