cmCTestBuildHandler.h 4.8 KB

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