cmCTestBuildHandler.h 4.22 KB
Newer Older
1 2 3
/*============================================================================
  CMake - Cross Platform Makefile Generator
  Copyright 2000-2009 Kitware, Inc.
Ken Martin's avatar
Ken Martin committed
4

5 6
  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.
Ken Martin's avatar
Ken Martin committed
7

8 9 10 11
  This software is distributed WITHOUT ANY WARRANTY; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the License for more information.
============================================================================*/
Ken Martin's avatar
Ken Martin committed
12 13 14 15

#ifndef cmCTestBuildHandler_h
#define cmCTestBuildHandler_h

16
#include "cmCTestGenericHandler.h"
Brad King's avatar
Brad King committed
17

Ken Martin's avatar
Ken Martin committed
18 19
#include "cmListFileCache.h"

20 21
#include <cmsys/RegularExpression.hxx>

22 23
#include <deque>

Ken Martin's avatar
Ken Martin committed
24
class cmMakefile;
25
class cmXMLWriter;
Ken Martin's avatar
Ken Martin committed
26 27 28 29 30

/** \class cmCTestBuildHandler
 * \brief A class that handles ctest -S invocations
 *
 */
31
class cmCTestBuildHandler : public cmCTestGenericHandler
Ken Martin's avatar
Ken Martin committed
32 33
{
public:
34
  cmTypeMacro(cmCTestBuildHandler, cmCTestGenericHandler);
Ken Martin's avatar
Ken Martin committed
35 36 37 38

  /*
   * The main entry point for this class
   */
39
  int ProcessHandler() CM_OVERRIDE;
Andy Cedilnik's avatar
Andy Cedilnik committed
40

Ken Martin's avatar
Ken Martin committed
41
  cmCTestBuildHandler();
Andy Cedilnik's avatar
Andy Cedilnik committed
42

43
  void PopulateCustomVectors(cmMakefile* mf) CM_OVERRIDE;
Ken Martin's avatar
Ken Martin committed
44

45 46 47
  /**
   * Initialize handler
   */
48
  void Initialize() CM_OVERRIDE;
Andy Cedilnik's avatar
Andy Cedilnik committed
49

50 51
  int GetTotalErrors() { return this->TotalErrors; }
  int GetTotalWarnings() { return this->TotalWarnings; }
52

53
private:
54 55
  std::string GetMakeCommand();

56 57
  //! Run command specialized for make and configure. Returns process status
  // and retVal is return value or exception.
58 59
  int RunMakeCommand(const char* command, int* retVal, const char* dir,
                     int timeout, std::ostream& ofs);
60

61 62
  enum
  {
63 64 65 66 67
    b_REGULAR_LINE,
    b_WARNING_LINE,
    b_ERROR_LINE
  };

68
  class cmCTestCompileErrorWarningRex
69
  {
70 71
  public:
    cmCTestCompileErrorWarningRex() {}
Andy Cedilnik's avatar
Andy Cedilnik committed
72 73 74
    int FileIndex;
    int LineIndex;
    cmsys::RegularExpression RegularExpression;
75
  };
Andy Cedilnik's avatar
Andy Cedilnik committed
76

Ken Martin's avatar
Ken Martin committed
77 78
  struct cmCTestBuildErrorWarning
  {
79 80
    bool Error;
    int LogLine;
Andy Cedilnik's avatar
Andy Cedilnik committed
81 82 83
    std::string Text;
    std::string SourceFile;
    std::string SourceFileTail;
84
    int LineNumber;
Andy Cedilnik's avatar
Andy Cedilnik committed
85 86
    std::string PreContext;
    std::string PostContext;
Ken Martin's avatar
Ken Martin committed
87 88 89
  };

  // generate the XML output
90 91 92 93
  void GenerateXMLHeader(cmXMLWriter& xml);
  void GenerateXMLLaunched(cmXMLWriter& xml);
  void GenerateXMLLogScraped(cmXMLWriter& xml);
  void GenerateXMLFooter(cmXMLWriter& xml, double elapsed_build_time);
94 95
  bool IsLaunchedErrorFile(const char* fname);
  bool IsLaunchedWarningFile(const char* fname);
Ken Martin's avatar
Ken Martin committed
96

97 98 99 100
  std::string StartBuild;
  std::string EndBuild;
  double StartBuildTime;
  double EndBuildTime;
Andy Cedilnik's avatar
Andy Cedilnik committed
101

102 103 104 105
  std::vector<std::string> CustomErrorMatches;
  std::vector<std::string> CustomErrorExceptions;
  std::vector<std::string> CustomWarningMatches;
  std::vector<std::string> CustomWarningExceptions;
106 107
  std::vector<std::string> ReallyCustomWarningMatches;
  std::vector<std::string> ReallyCustomWarningExceptions;
Andy Cedilnik's avatar
Andy Cedilnik committed
108
  std::vector<cmCTestCompileErrorWarningRex> ErrorWarningFileLineRegex;
109

Andy Cedilnik's avatar
Andy Cedilnik committed
110 111 112 113
  std::vector<cmsys::RegularExpression> ErrorMatchRegex;
  std::vector<cmsys::RegularExpression> ErrorExceptionRegex;
  std::vector<cmsys::RegularExpression> WarningMatchRegex;
  std::vector<cmsys::RegularExpression> WarningExceptionRegex;
114

115 116
  typedef std::deque<char> t_BuildProcessingQueueType;

Andy Cedilnik's avatar
Andy Cedilnik committed
117
  void ProcessBuffer(const char* data, int length, size_t& tick,
118 119
                     size_t tick_len, std::ostream& ofs,
                     t_BuildProcessingQueueType* queue);
120 121
  int ProcessSingleLine(const char* data);

122 123 124 125
  t_BuildProcessingQueueType BuildProcessingQueue;
  t_BuildProcessingQueueType BuildProcessingErrorQueue;
  size_t BuildOutputLogSize;
  std::vector<char> CurrentProcessingLine;
126

127 128 129
  std::string SimplifySourceDir;
  std::string SimplifyBuildDir;
  size_t OutputLineCounter;
130
  typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector;
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
  t_ErrorsAndWarningsVector ErrorsAndWarnings;
  t_ErrorsAndWarningsVector::iterator LastErrorOrWarning;
  size_t PostContextCount;
  size_t MaxPreContext;
  size_t MaxPostContext;
  std::deque<std::string> PreContext;

  int TotalErrors;
  int TotalWarnings;
  char LastTickChar;

  bool ErrorQuotaReached;
  bool WarningQuotaReached;

  int MaxErrors;
  int MaxWarnings;
147 148 149 150 151 152

  bool UseCTestLaunch;
  std::string CTestLaunchDir;
  class LaunchHelper;
  friend class LaunchHelper;
  class FragmentCompare;
Ken Martin's avatar
Ken Martin committed
153 154 155
};

#endif