cmCTestConfigureHandler.cxx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  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. #include "cmCTestConfigureHandler.h"
  11. #include "cmCTest.h"
  12. #include "cmGeneratedFileStream.h"
  13. #include "cmXMLWriter.h"
  14. #include "cmake.h"
  15. #include <cmsys/Process.h>
  16. cmCTestConfigureHandler::cmCTestConfigureHandler()
  17. {
  18. }
  19. void cmCTestConfigureHandler::Initialize()
  20. {
  21. this->Superclass::Initialize();
  22. }
  23. // clearly it would be nice if this were broken up into a few smaller
  24. // functions and commented...
  25. int cmCTestConfigureHandler::ProcessHandler()
  26. {
  27. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  28. "Configure project" << std::endl, this->Quiet);
  29. std::string cCommand =
  30. this->CTest->GetCTestConfiguration("ConfigureCommand");
  31. if (cCommand.empty()) {
  32. cmCTestLog(this->CTest, ERROR_MESSAGE,
  33. "Cannot find ConfigureCommand key in the DartConfiguration.tcl"
  34. << std::endl);
  35. return -1;
  36. }
  37. std::string buildDirectory =
  38. this->CTest->GetCTestConfiguration("BuildDirectory");
  39. if (buildDirectory.empty()) {
  40. cmCTestLog(this->CTest, ERROR_MESSAGE,
  41. "Cannot find BuildDirectory key in the DartConfiguration.tcl"
  42. << std::endl);
  43. return -1;
  44. }
  45. double elapsed_time_start = cmSystemTools::GetTime();
  46. std::string output;
  47. int retVal = 0;
  48. int res = 0;
  49. if (!this->CTest->GetShowOnly()) {
  50. cmGeneratedFileStream os;
  51. if (!this->StartResultingXML(cmCTest::PartConfigure, "Configure", os)) {
  52. cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open configure file"
  53. << std::endl);
  54. return 1;
  55. }
  56. std::string start_time = this->CTest->CurrentTime();
  57. unsigned int start_time_time =
  58. static_cast<unsigned int>(cmSystemTools::GetTime());
  59. cmGeneratedFileStream ofs;
  60. this->StartLogFile("Configure", ofs);
  61. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  62. "Configure with command: " << cCommand << std::endl,
  63. this->Quiet);
  64. res = this->CTest->RunMakeCommand(cCommand.c_str(), output, &retVal,
  65. buildDirectory.c_str(), 0, ofs);
  66. if (ofs) {
  67. ofs.close();
  68. }
  69. if (os) {
  70. cmXMLWriter xml(os);
  71. this->CTest->StartXML(xml, this->AppendXML);
  72. xml.StartElement("Configure");
  73. xml.Element("StartDateTime", start_time);
  74. xml.Element("StartConfigureTime", start_time_time);
  75. xml.Element("ConfigureCommand", cCommand);
  76. cmCTestOptionalLog(this->CTest, DEBUG, "End" << std::endl, this->Quiet);
  77. xml.Element("Log", output);
  78. xml.Element("ConfigureStatus", retVal);
  79. xml.Element("EndDateTime", this->CTest->CurrentTime());
  80. xml.Element("EndConfigureTime",
  81. static_cast<unsigned int>(cmSystemTools::GetTime()));
  82. xml.Element(
  83. "ElapsedMinutes",
  84. static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
  85. 10.0);
  86. xml.EndElement(); // Configure
  87. this->CTest->EndXML(xml);
  88. }
  89. } else {
  90. cmCTestOptionalLog(this->CTest, DEBUG,
  91. "Configure with command: " << cCommand << std::endl,
  92. this->Quiet);
  93. }
  94. if (!res || retVal) {
  95. cmCTestLog(this->CTest, ERROR_MESSAGE,
  96. "Error(s) when configuring the project" << std::endl);
  97. return -1;
  98. }
  99. return 0;
  100. }