cmCTestBuildHandler.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. class cmMakefile;
  16. /** \class cmCTestBuildHandler
  17. * \brief A class that handles ctest -S invocations
  18. *
  19. */
  20. class cmCTestBuildHandler : public cmCTestGenericHandler
  21. {
  22. public:
  23. cmTypeMacro(cmCTestBuildHandler, cmCTestGenericHandler);
  24. /*
  25. * The main entry point for this class
  26. */
  27. int ProcessHandler();
  28. cmCTestBuildHandler();
  29. void PopulateCustomVectors(cmMakefile *mf);
  30. /**
  31. * Initialize handler
  32. */
  33. virtual void Initialize();
  34. int GetTotalErrors() { return this->TotalErrors;}
  35. int GetTotalWarnings() { return this->TotalWarnings;}
  36. private:
  37. //! Run command specialized for make and configure. Returns process status
  38. // and retVal is return value or exception.
  39. int RunMakeCommand(const char* command,
  40. int* retVal, const char* dir, int timeout,
  41. std::ofstream& ofs);
  42. enum {
  43. b_REGULAR_LINE,
  44. b_WARNING_LINE,
  45. b_ERROR_LINE
  46. };
  47. class cmCTestCompileErrorWarningRex
  48. {
  49. public:
  50. cmCTestCompileErrorWarningRex() {}
  51. int FileIndex;
  52. int LineIndex;
  53. cmsys::RegularExpression RegularExpression;
  54. };
  55. struct cmCTestBuildErrorWarning
  56. {
  57. bool Error;
  58. int LogLine;
  59. std::string Text;
  60. std::string SourceFile;
  61. std::string SourceFileTail;
  62. int LineNumber;
  63. std::string PreContext;
  64. std::string PostContext;
  65. };
  66. // generate the XML output
  67. void GenerateXMLHeader(std::ostream& os);
  68. void GenerateXMLLaunched(std::ostream& os);
  69. void GenerateXMLLogScraped(std::ostream& os);
  70. void GenerateXMLFooter(std::ostream& os, double elapsed_build_time);
  71. void GenerateXMLLaunchedFragment(std::ostream& os, const char* fname);
  72. bool IsLaunchedErrorFile(const char* fname);
  73. bool IsLaunchedWarningFile(const char* fname);
  74. std::string StartBuild;
  75. std::string EndBuild;
  76. double StartBuildTime;
  77. double EndBuildTime;
  78. std::vector<cmStdString> CustomErrorMatches;
  79. std::vector<cmStdString> CustomErrorExceptions;
  80. std::vector<cmStdString> CustomWarningMatches;
  81. std::vector<cmStdString> CustomWarningExceptions;
  82. std::vector<std::string> ReallyCustomWarningMatches;
  83. std::vector<std::string> ReallyCustomWarningExceptions;
  84. std::vector<cmCTestCompileErrorWarningRex> ErrorWarningFileLineRegex;
  85. std::vector<cmsys::RegularExpression> ErrorMatchRegex;
  86. std::vector<cmsys::RegularExpression> ErrorExceptionRegex;
  87. std::vector<cmsys::RegularExpression> WarningMatchRegex;
  88. std::vector<cmsys::RegularExpression> WarningExceptionRegex;
  89. typedef std::deque<char> t_BuildProcessingQueueType;
  90. void ProcessBuffer(const char* data, int length, size_t& tick,
  91. size_t tick_len, std::ofstream& ofs, t_BuildProcessingQueueType* queue);
  92. int ProcessSingleLine(const char* data);
  93. t_BuildProcessingQueueType BuildProcessingQueue;
  94. t_BuildProcessingQueueType BuildProcessingErrorQueue;
  95. size_t BuildOutputLogSize;
  96. std::vector<char> CurrentProcessingLine;
  97. cmStdString SimplifySourceDir;
  98. cmStdString SimplifyBuildDir;
  99. size_t OutputLineCounter;
  100. typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector;
  101. t_ErrorsAndWarningsVector ErrorsAndWarnings;
  102. t_ErrorsAndWarningsVector::iterator LastErrorOrWarning;
  103. size_t PostContextCount;
  104. size_t MaxPreContext;
  105. size_t MaxPostContext;
  106. std::deque<cmStdString> PreContext;
  107. int TotalErrors;
  108. int TotalWarnings;
  109. char LastTickChar;
  110. bool ErrorQuotaReached;
  111. bool WarningQuotaReached;
  112. int MaxErrors;
  113. int MaxWarnings;
  114. bool UseCTestLaunch;
  115. std::string CTestLaunchDir;
  116. class LaunchHelper;
  117. friend class LaunchHelper;
  118. class FragmentCompare;
  119. };
  120. #endif