cmCTestBuildHandler.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmCTestBuildHandler_h
  14. #define cmCTestBuildHandler_h
  15. #include "cmCTestGenericHandler.h"
  16. #include "cmListFileCache.h"
  17. #include <cmsys/RegularExpression.hxx>
  18. class cmMakefile;
  19. /** \class cmCTestBuildHandler
  20. * \brief A class that handles ctest -S invocations
  21. *
  22. */
  23. class cmCTestBuildHandler : public cmCTestGenericHandler
  24. {
  25. public:
  26. cmTypeMacro(cmCTestBuildHandler, cmCTestGenericHandler);
  27. /*
  28. * The main entry point for this class
  29. */
  30. int ProcessHandler();
  31. cmCTestBuildHandler();
  32. void PopulateCustomVectors(cmMakefile *mf);
  33. /**
  34. * Initialize handler
  35. */
  36. virtual void Initialize();
  37. int GetTotalErrors() { return this->TotalErrors;}
  38. int GetTotalWarnings() { return this->TotalWarnings;}
  39. private:
  40. //! Run command specialized for make and configure. Returns process status
  41. // and retVal is return value or exception.
  42. int RunMakeCommand(const char* command,
  43. int* retVal, const char* dir, int timeout,
  44. std::ofstream& ofs);
  45. enum {
  46. b_REGULAR_LINE,
  47. b_WARNING_LINE,
  48. b_ERROR_LINE
  49. };
  50. class cmCTestCompileErrorWarningRex
  51. {
  52. public:
  53. cmCTestCompileErrorWarningRex() {}
  54. int FileIndex;
  55. int LineIndex;
  56. cmsys::RegularExpression RegularExpression;
  57. };
  58. struct cmCTestBuildErrorWarning
  59. {
  60. bool Error;
  61. int LogLine;
  62. std::string Text;
  63. std::string SourceFile;
  64. std::string SourceFileTail;
  65. int LineNumber;
  66. std::string PreContext;
  67. std::string PostContext;
  68. };
  69. // generate the XML output
  70. void GenerateXMLHeader(std::ostream& os);
  71. void GenerateXMLLaunched(std::ostream& os);
  72. void GenerateXMLLogScraped(std::ostream& os);
  73. void GenerateXMLFooter(std::ostream& os, double elapsed_build_time);
  74. void GenerateXMLLaunchedFragment(std::ostream& os, const char* fname);
  75. bool IsLaunchedErrorFile(const char* fname);
  76. bool IsLaunchedWarningFile(const char* fname);
  77. std::string StartBuild;
  78. std::string EndBuild;
  79. double StartBuildTime;
  80. double EndBuildTime;
  81. std::vector<cmStdString> CustomErrorMatches;
  82. std::vector<cmStdString> CustomErrorExceptions;
  83. std::vector<cmStdString> CustomWarningMatches;
  84. std::vector<cmStdString> CustomWarningExceptions;
  85. std::vector<std::string> ReallyCustomWarningMatches;
  86. std::vector<std::string> ReallyCustomWarningExceptions;
  87. std::vector<cmCTestCompileErrorWarningRex> ErrorWarningFileLineRegex;
  88. std::vector<cmsys::RegularExpression> ErrorMatchRegex;
  89. std::vector<cmsys::RegularExpression> ErrorExceptionRegex;
  90. std::vector<cmsys::RegularExpression> WarningMatchRegex;
  91. std::vector<cmsys::RegularExpression> WarningExceptionRegex;
  92. typedef std::deque<char> t_BuildProcessingQueueType;
  93. void ProcessBuffer(const char* data, int length, size_t& tick,
  94. size_t tick_len, std::ofstream& ofs, t_BuildProcessingQueueType* queue);
  95. int ProcessSingleLine(const char* data);
  96. t_BuildProcessingQueueType BuildProcessingQueue;
  97. t_BuildProcessingQueueType BuildProcessingErrorQueue;
  98. size_t BuildOutputLogSize;
  99. std::vector<char> CurrentProcessingLine;
  100. cmStdString SimplifySourceDir;
  101. cmStdString SimplifyBuildDir;
  102. size_t OutputLineCounter;
  103. typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector;
  104. t_ErrorsAndWarningsVector ErrorsAndWarnings;
  105. t_ErrorsAndWarningsVector::iterator LastErrorOrWarning;
  106. size_t PostContextCount;
  107. size_t MaxPreContext;
  108. size_t MaxPostContext;
  109. std::deque<cmStdString> PreContext;
  110. int TotalErrors;
  111. int TotalWarnings;
  112. char LastTickChar;
  113. bool ErrorQuotaReached;
  114. bool WarningQuotaReached;
  115. int MaxErrors;
  116. int MaxWarnings;
  117. bool UseCTestLaunch;
  118. std::string CTestLaunchDir;
  119. class LaunchHelper;
  120. friend class LaunchHelper;
  121. class FragmentCompare;
  122. };
  123. #endif