From 572035ffcd0e4f7313bab23d375d63008ebbe5a3 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 14 May 2019 09:45:27 +0200 Subject: delayed creation and update of .md5 files after successful creation of output files --- src/dot.cpp | 86 +++++++++++++++++++++++++++++++++++++------------------------ src/dot.h | 5 ++-- 2 files changed, 55 insertions(+), 36 deletions(-) diff --git a/src/dot.cpp b/src/dot.cpp index 5aca277..ae51fb0 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -747,11 +747,10 @@ static void removeDotGraph(const QCString &dotName) /*! Checks if a file "baseName".md5 exists. If so the contents - * are compared with \a md5. If equal FALSE is returned. If the .md5 - * file does not exist or its contents are not equal to \a md5, - * a new .md5 is generated with the \a md5 string as contents. + * are compared with \a md5. If equal FALSE is returned. + * The .md5 is created or updated after successful creation of the output file. */ -static bool checkAndUpdateMd5Signature(const QCString &baseName, +static bool checkMd5Signature(const QCString &baseName, const QCString &md5) { QFile f(baseName+".md5"); @@ -769,12 +768,6 @@ static bool checkAndUpdateMd5Signature(const QCString &baseName, } } f.close(); - // create checksum file - if (f.open(IO_WriteOnly)) - { - f.writeBlock(md5.data(),32); - f.close(); - } return TRUE; } @@ -813,12 +806,12 @@ int DotNodeList::compareValues(const DotNode *n1,const DotNode *n2) const //-------------------------------------------------------------------- -DotRunner::DotRunner(const QCString &file,const QCString &path, - bool checkResult,const QCString &imageName) +DotRunner::DotRunner(const QCString& file, const QCString& path, const QCString& md5Hash, + bool checkResult, const QCString& imageName) : m_dotExe(Config_getString(DOT_PATH)+"dot"), m_file(file), m_path(path), m_checkResult(checkResult), m_imageName(imageName), - m_imgExt(getDotImageExtension()) + m_imgExt(getDotImageExtension()), m_md5Hash(md5Hash) { static bool dotCleanUp = Config_getBool(DOT_CLEANUP); static bool dotMultiTargets = Config_getBool(DOT_MULTI_TARGETS); @@ -910,6 +903,25 @@ bool DotRunner::run() m_cleanupItem.file.set(m_file.data()); m_cleanupItem.path.set(m_path.data()); } + if (!m_md5Hash.isEmpty()) { + // create checksum file + int dotPosition = QCString(m_file.data()).findRev('.'); + QCString md5Name; + if (dotPosition == -1) + { + md5Name = QCString(m_file.data()) + ".md5"; + } + else + { + md5Name = QCString(m_file.data()).left(dotPosition) + ".md5"; + } + QFile f(md5Name); + if (f.open(IO_WriteOnly)) + { + f.writeBlock(m_md5Hash.data(),32); + f.close(); + } + } return TRUE; error: err("Problems running dot: exit code=%d, command='%s', arguments='%s'\n", @@ -2389,7 +2401,7 @@ void DotGfxHierarchyTable::createGraph(DotNode *n,FTextStream &out, MD5Buffer((const unsigned char *)theGraph.data(),theGraph.length(),md5_sig); MD5SigToString(md5_sig,sigStr.rawData(),33); bool regenerate=FALSE; - if (checkAndUpdateMd5Signature(absBaseName,sigStr) || + if (checkMd5Signature(absBaseName,sigStr) || !checkDeliverables(absImgName,absMapName)) { regenerate=TRUE; @@ -2401,7 +2413,7 @@ void DotGfxHierarchyTable::createGraph(DotNode *n,FTextStream &out, t << theGraph; f.close(); - DotRunner *dotRun = new DotRunner(dotName,d.absPath().data(),TRUE,absImgName); + DotRunner *dotRun = new DotRunner(dotName,d.absPath().data(),sigStr,TRUE,absImgName); dotRun->addJob(imgFmt,absImgName); dotRun->addJob(MAP_CMD,absMapName); DotManager::instance()->addRun(dotRun); @@ -3168,12 +3180,13 @@ static bool updateDotGraph(DotNode *root, const QCString &rank, bool renderParents, bool backArrows, + QCString & sigStr, const QCString &title=QCString() ) { QCString theGraph; // TODO: write graph to theGraph, then compute md5 checksum - QCString md5 = computeMd5Signature( + sigStr = computeMd5Signature( root,gt,format,rank,renderParents, backArrows,title,theGraph); QFile f(baseName+".dot"); @@ -3182,7 +3195,7 @@ static bool updateDotGraph(DotNode *root, FTextStream t(&f); t << theGraph; } - return checkAndUpdateMd5Signature(baseName,md5); // graph needs to be regenerated + return checkMd5Signature(baseName,sigStr); // graph needs to be regenerated } QCString DotClassGraph::writeGraph(FTextStream &out, @@ -3231,6 +3244,7 @@ QCString DotClassGraph::writeGraph(FTextStream &out, QCString absImgName = absBaseName+"."+imgExt; bool regenerate = FALSE; + QCString sigStr; if (updateDotGraph(m_startNode, m_graphType, absBaseName, @@ -3238,6 +3252,7 @@ QCString DotClassGraph::writeGraph(FTextStream &out, m_lrRank ? "LR" : "", m_graphType==DotNode::Inheritance, TRUE, + sigStr, m_startNode->label() ) || !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName : @@ -3249,7 +3264,7 @@ QCString DotClassGraph::writeGraph(FTextStream &out, if (graphFormat==GOF_BITMAP) // run dot to create a bitmap image { DotRunner *dotRun = new DotRunner(absDotName, - d.absPath().data(),TRUE,absImgName); + d.absPath().data(), sigStr, TRUE,absImgName); dotRun->addJob(imgFmt,absImgName); if (generateImageMap) dotRun->addJob(MAP_CMD,absMapName); DotManager::instance()->addRun(dotRun); @@ -3257,7 +3272,7 @@ QCString DotClassGraph::writeGraph(FTextStream &out, } else if (graphFormat==GOF_EPS) // run dot to create a .eps image { - DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),FALSE); + DotRunner *dotRun = new DotRunner(absDotName, d.absPath().data(), sigStr, FALSE); if (usePDFLatex) { dotRun->addJob("pdf",absPdfName,absBaseName); @@ -3570,6 +3585,7 @@ QCString DotInclDepGraph::writeGraph(FTextStream &out, QCString absImgName = absBaseName+"."+imgExt; bool regenerate = FALSE; + QCString sigStr; if (updateDotGraph(m_startNode, DotNode::Dependency, absBaseName, @@ -3577,6 +3593,7 @@ QCString DotInclDepGraph::writeGraph(FTextStream &out, "", // lrRank FALSE, // renderParents m_inverse, // backArrows + sigStr, m_startNode->label() ) || !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName : @@ -3588,14 +3605,14 @@ QCString DotInclDepGraph::writeGraph(FTextStream &out, if (graphFormat==GOF_BITMAP) { // run dot to create a bitmap image - DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),TRUE,absImgName); + DotRunner *dotRun = new DotRunner(absDotName, d.absPath().data(), sigStr, TRUE, absImgName); dotRun->addJob(imgFmt,absImgName); if (generateImageMap) dotRun->addJob(MAP_CMD,absMapName); DotManager::instance()->addRun(dotRun); } else if (graphFormat==GOF_EPS) { - DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),FALSE); + DotRunner *dotRun = new DotRunner(absDotName, d.absPath().data(), sigStr, FALSE); if (usePDFLatex) { dotRun->addJob("pdf",absPdfName,absBaseName); @@ -3879,7 +3896,7 @@ QCString DotCallGraph::writeGraph(FTextStream &out, GraphOutputFormat graphForma QCString absImgName = absBaseName+"."+imgExt; bool regenerate = FALSE; - + QCString sigStr; if (updateDotGraph(m_startNode, DotNode::CallGraph, absBaseName, @@ -3887,6 +3904,7 @@ QCString DotCallGraph::writeGraph(FTextStream &out, GraphOutputFormat graphForma m_inverse ? "RL" : "LR", // lrRank FALSE, // renderParents m_inverse, // backArrows + sigStr, m_startNode->label() ) || !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName : @@ -3898,7 +3916,7 @@ QCString DotCallGraph::writeGraph(FTextStream &out, GraphOutputFormat graphForma if (graphFormat==GOF_BITMAP) { // run dot to create a bitmap image - DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),TRUE,absImgName); + DotRunner *dotRun = new DotRunner(absDotName, d.absPath().data(), sigStr, TRUE, absImgName); dotRun->addJob(imgFmt,absImgName); if (generateImageMap) dotRun->addJob(MAP_CMD,absMapName); DotManager::instance()->addRun(dotRun); @@ -3907,7 +3925,7 @@ QCString DotCallGraph::writeGraph(FTextStream &out, GraphOutputFormat graphForma else if (graphFormat==GOF_EPS) { // run dot to create a .eps image - DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),FALSE); + DotRunner *dotRun = new DotRunner(absDotName, d.absPath().data(), sigStr, FALSE); if (usePDFLatex) { dotRun->addJob("pdf",absPdfName,absBaseName); @@ -4044,7 +4062,7 @@ QCString DotDirDeps::writeGraph(FTextStream &out, MD5Buffer((const unsigned char *)theGraph.data(),theGraph.length(),md5_sig); MD5SigToString(md5_sig,sigStr.rawData(),33); bool regenerate=FALSE; - if (checkAndUpdateMd5Signature(absBaseName,sigStr) || + if (checkMd5Signature(absBaseName,sigStr) || !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName : usePDFLatex ? absPdfName : absEpsName, graphFormat==GOF_BITMAP && generateImageMap ? absMapName : QCString()) @@ -4064,14 +4082,14 @@ QCString DotDirDeps::writeGraph(FTextStream &out, if (graphFormat==GOF_BITMAP) { // run dot to create a bitmap image - DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),TRUE,absImgName); + DotRunner *dotRun = new DotRunner(absDotName, d.absPath().data(), sigStr, TRUE, absImgName); dotRun->addJob(imgFmt,absImgName); if (generateImageMap) dotRun->addJob(MAP_CMD,absMapName); DotManager::instance()->addRun(dotRun); } else if (graphFormat==GOF_EPS) { - DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),FALSE); + DotRunner *dotRun = new DotRunner(absDotName, d.absPath().data(), sigStr, FALSE); if (usePDFLatex) { dotRun->addJob("pdf",absPdfName,absBaseName); @@ -4192,7 +4210,7 @@ void generateGraphLegend(const char *path) QCString imgFmt = Config_getEnum(DOT_IMAGE_FORMAT); QCString imgName = "graph_legend."+imgExt; QCString absImgName = absBaseName+"."+imgExt; - if (checkAndUpdateMd5Signature(absBaseName,sigStr) || + if (checkMd5Signature(absBaseName,sigStr) || !checkDeliverables(absImgName)) { QFile dotFile(absDotName); @@ -4208,7 +4226,7 @@ void generateGraphLegend(const char *path) // run dot to generate the a bitmap image from the graph - DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),TRUE,absImgName); + DotRunner *dotRun = new DotRunner(absDotName, d.absPath().data(),sigStr,TRUE,absImgName); dotRun->addJob(imgFmt,absImgName); DotManager::instance()->addRun(dotRun); } @@ -4243,7 +4261,7 @@ void writeDotGraphFromFile(const char *inFile,const char *outDir, QCString absImgName = d.absPath().utf8()+"/"+imgName; QCString absOutFile = d.absPath().utf8()+"/"+outFile; - DotRunner dotRun(inFile,d.absPath().data(),FALSE,absImgName); + DotRunner dotRun(inFile,d.absPath().data(),QCString(),FALSE,absImgName); if (format==GOF_BITMAP) dotRun.addJob(imgFmt,absImgName); else // format==GOF_EPS @@ -4298,7 +4316,7 @@ void writeDotImageMapFromFile(FTextStream &t, QCString imgName = baseName+"."+imgExt; QCString absOutFile = d.absPath().utf8()+"/"+mapName; - DotRunner dotRun(inFile,d.absPath().data(),FALSE); + DotRunner dotRun(inFile,d.absPath().data(),QCString(),FALSE); dotRun.addJob(MAP_CMD,absOutFile); dotRun.preventCleanUp(); if (!dotRun.run()) @@ -4605,7 +4623,7 @@ QCString DotGroupCollaboration::writeGraph( FTextStream &t, QCString absPdfName = absBaseName+".pdf"; QCString absEpsName = absBaseName+".eps"; bool regenerate=FALSE; - if (checkAndUpdateMd5Signature(absBaseName,sigStr) || + if (checkMd5Signature(absBaseName,sigStr) || !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName : usePDFLatex ? absPdfName : absEpsName, graphFormat==GOF_BITMAP /*&& generateImageMap*/ ? absMapName : QCString()) @@ -4623,7 +4641,7 @@ QCString DotGroupCollaboration::writeGraph( FTextStream &t, if (graphFormat==GOF_BITMAP) // run dot to create a bitmap image { - DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),FALSE); + DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),sigStr,FALSE); dotRun->addJob(imgFmt,absImgName); if (writeImageMap) dotRun->addJob(MAP_CMD,absMapName); DotManager::instance()->addRun(dotRun); @@ -4631,7 +4649,7 @@ QCString DotGroupCollaboration::writeGraph( FTextStream &t, } else if (graphFormat==GOF_EPS) { - DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),FALSE); + DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),sigStr,FALSE); if (usePDFLatex) { dotRun->addJob("pdf",absPdfName,absBaseName); diff --git a/src/dot.h b/src/dot.h index d63dd05..4460ac2 100644 --- a/src/dot.h +++ b/src/dot.h @@ -400,8 +400,8 @@ class DotRunner }; /** Creates a runner for a dot \a file. */ - DotRunner(const QCString &file,const QCString &fontPath,bool checkResult, - const QCString &imageName = QCString()); + DotRunner(const QCString& file, const QCString& path, const QCString& md5Hash, + bool checkResult, const QCString &imageName = QCString()); /** Adds an additional job to the run. * Performing multiple jobs one file can be faster. @@ -429,6 +429,7 @@ class DotRunner DotConstString m_imgExt; bool m_cleanUp; CleanupItem m_cleanupItem; + DotConstString m_md5Hash; }; /** Helper class to insert a set of map file into an output file */ -- cgit v0.12