cmCTestLaunch.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmCTestLaunch_h
  14. #define cmCTestLaunch_h
  15. #include "cmStandardIncludes.h"
  16. #include <cmsys/RegularExpression.hxx>
  17. /** \class cmCTestLaunch
  18. * \brief Launcher for make rules to report results for ctest
  19. *
  20. * This implements the 'ctest --launch' tool.
  21. */
  22. class cmCTestLaunch
  23. {
  24. public:
  25. /** Entry point from ctest executable main(). */
  26. static int Main(int argc, const char* const* argv);
  27. private:
  28. // Initialize the launcher from its command line.
  29. cmCTestLaunch(int argc, const char* const* argv);
  30. ~cmCTestLaunch();
  31. // Run the real command.
  32. int Run();
  33. void RunChild();
  34. // Methods to check the result of the real command.
  35. bool IsError() const;
  36. bool CheckResults();
  37. // Launcher options specified before the real command.
  38. std::string OptionOutput;
  39. std::string OptionSource;
  40. std::string OptionLanguage;
  41. std::string OptionTargetName;
  42. std::string OptionTargetType;
  43. std::string OptionBuildDir;
  44. bool ParseArguments(int argc, const char* const* argv);
  45. // The real command line appearing after launcher arguments.
  46. int RealArgC;
  47. const char* const* RealArgV;
  48. std::string CWD;
  49. // The real command line after response file expansion.
  50. std::vector<std::string> RealArgs;
  51. void HandleRealArg(const char* arg);
  52. // A hash of the real command line is unique and unlikely to collide.
  53. std::string LogHash;
  54. void ComputeFileNames();
  55. bool Passthru;
  56. struct cmsysProcess_s* Process;
  57. int ExitCode;
  58. // Temporary log files for stdout and stderr of real command.
  59. std::string LogDir;
  60. std::string LogOut;
  61. std::string LogErr;
  62. bool HaveOut;
  63. bool HaveErr;
  64. // Labels associated with the build rule.
  65. std::set<cmStdString> Labels;
  66. void LoadLabels();
  67. bool SourceMatches(std::string const& lhs,
  68. std::string const& rhs);
  69. // Regular expressions to match warnings and their exceptions.
  70. bool ScrapeRulesLoaded;
  71. std::vector<cmsys::RegularExpression> RegexWarning;
  72. std::vector<cmsys::RegularExpression> RegexWarningSuppress;
  73. void LoadScrapeRules();
  74. void LoadScrapeRules(const char* purpose,
  75. std::vector<cmsys::RegularExpression>& regexps);
  76. bool ScrapeLog(std::string const& fname);
  77. bool Match(std::string const& line,
  78. std::vector<cmsys::RegularExpression>& regexps);
  79. // Methods to generate the xml fragment.
  80. void WriteXML();
  81. void WriteXMLAction(std::ostream& fxml);
  82. void WriteXMLCommand(std::ostream& fxml);
  83. void WriteXMLResult(std::ostream& fxml);
  84. void WriteXMLLabels(std::ostream& fxml);
  85. void DumpFileToXML(std::ostream& fxml, std::string const& fname);
  86. // Configuration
  87. void LoadConfig();
  88. std::string SourceDir;
  89. };
  90. #endif