cmCTestBuildHandler.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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, int* retVal, const char* dir,
  43. int timeout, std::ostream& ofs);
  44. enum
  45. {
  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,
  94. 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. std::string SimplifySourceDir;
  101. std::string 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<std::string> 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