cmCTestBuildHandler.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc.
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmCTestBuildHandler_h
  11. #define cmCTestBuildHandler_h
  12. #include "cmCTestGenericHandler.h"
  13. #include "cmListFileCache.h"
  14. #include <cmsys/RegularExpression.hxx>
  15. #include <deque>
  16. class cmMakefile;
  17. class cmXMLWriter;
  18. /** \class cmCTestBuildHandler
  19. * \brief A class that handles ctest -S invocations
  20. *
  21. */
  22. class cmCTestBuildHandler : public cmCTestGenericHandler
  23. {
  24. public:
  25. cmTypeMacro(cmCTestBuildHandler, cmCTestGenericHandler);
  26. /*
  27. * The main entry point for this class
  28. */
  29. int ProcessHandler();
  30. cmCTestBuildHandler();
  31. void PopulateCustomVectors(cmMakefile *mf);
  32. /**
  33. * Initialize handler
  34. */
  35. virtual void Initialize();
  36. int GetTotalErrors() { return this->TotalErrors;}
  37. int GetTotalWarnings() { return this->TotalWarnings;}
  38. private:
  39. std::string GetMakeCommand();
  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::ostream& 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(cmXMLWriter& xml);
  71. void GenerateXMLLaunched(cmXMLWriter& xml);
  72. void GenerateXMLLogScraped(cmXMLWriter& xml);
  73. void GenerateXMLFooter(cmXMLWriter& xml, double elapsed_build_time);
  74. bool IsLaunchedErrorFile(const char* fname);
  75. bool IsLaunchedWarningFile(const char* fname);
  76. std::string StartBuild;
  77. std::string EndBuild;
  78. double StartBuildTime;
  79. double EndBuildTime;
  80. std::vector<std::string> CustomErrorMatches;
  81. std::vector<std::string> CustomErrorExceptions;
  82. std::vector<std::string> CustomWarningMatches;
  83. std::vector<std::string> CustomWarningExceptions;
  84. std::vector<std::string> ReallyCustomWarningMatches;
  85. std::vector<std::string> ReallyCustomWarningExceptions;
  86. std::vector<cmCTestCompileErrorWarningRex> ErrorWarningFileLineRegex;
  87. std::vector<cmsys::RegularExpression> ErrorMatchRegex;
  88. std::vector<cmsys::RegularExpression> ErrorExceptionRegex;
  89. std::vector<cmsys::RegularExpression> WarningMatchRegex;
  90. std::vector<cmsys::RegularExpression> WarningExceptionRegex;
  91. typedef std::deque<char> t_BuildProcessingQueueType;
  92. void ProcessBuffer(const char* data, int length, size_t& tick,
  93. size_t tick_len, std::ostream& ofs, t_BuildProcessingQueueType* queue);
  94. int ProcessSingleLine(const char* data);
  95. t_BuildProcessingQueueType BuildProcessingQueue;
  96. t_BuildProcessingQueueType BuildProcessingErrorQueue;
  97. size_t BuildOutputLogSize;
  98. std::vector<char> CurrentProcessingLine;
  99. std::string SimplifySourceDir;
  100. std::string SimplifyBuildDir;
  101. size_t OutputLineCounter;
  102. typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector;
  103. t_ErrorsAndWarningsVector ErrorsAndWarnings;
  104. t_ErrorsAndWarningsVector::iterator LastErrorOrWarning;
  105. size_t PostContextCount;
  106. size_t MaxPreContext;
  107. size_t MaxPostContext;
  108. std::deque<std::string> PreContext;
  109. int TotalErrors;
  110. int TotalWarnings;
  111. char LastTickChar;
  112. bool ErrorQuotaReached;
  113. bool WarningQuotaReached;
  114. int MaxErrors;
  115. int MaxWarnings;
  116. bool UseCTestLaunch;
  117. std::string CTestLaunchDir;
  118. class LaunchHelper;
  119. friend class LaunchHelper;
  120. class FragmentCompare;
  121. };
  122. #endif