cmCTestConfigureHandler.cxx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. #include "cmCTestConfigureHandler.h"
  14. #include "cmCTest.h"
  15. #include "cmGeneratedFileStream.h"
  16. #include "cmake.h"
  17. #include <cmsys/Process.h>
  18. //----------------------------------------------------------------------
  19. cmCTestConfigureHandler::cmCTestConfigureHandler()
  20. {
  21. }
  22. //----------------------------------------------------------------------
  23. void cmCTestConfigureHandler::Initialize()
  24. {
  25. this->Superclass::Initialize();
  26. }
  27. //----------------------------------------------------------------------
  28. //clearly it would be nice if this were broken up into a few smaller
  29. //functions and commented...
  30. int cmCTestConfigureHandler::ProcessHandler()
  31. {
  32. cmCTestLog(this->CTest, HANDLER_OUTPUT, "Configure project" << std::endl);
  33. std::string cCommand
  34. = this->CTest->GetCTestConfiguration("ConfigureCommand");
  35. if ( cCommand.size() == 0 )
  36. {
  37. cmCTestLog(this->CTest, ERROR_MESSAGE,
  38. "Cannot find ConfigureCommand key in the DartConfiguration.tcl"
  39. << std::endl);
  40. return -1;
  41. }
  42. std::string buildDirectory
  43. = this->CTest->GetCTestConfiguration("BuildDirectory");
  44. if ( buildDirectory.size() == 0 )
  45. {
  46. cmCTestLog(this->CTest, ERROR_MESSAGE,
  47. "Cannot find BuildDirectory key in the DartConfiguration.tcl"
  48. << std::endl);
  49. return -1;
  50. }
  51. double elapsed_time_start = cmSystemTools::GetTime();
  52. std::string output;
  53. int retVal = 0;
  54. int res = 0;
  55. if ( !this->CTest->GetShowOnly() )
  56. {
  57. cmGeneratedFileStream os;
  58. if(!this->StartResultingXML(cmCTest::PartConfigure, "Configure", os))
  59. {
  60. cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open configure file"
  61. << std::endl);
  62. return 1;
  63. }
  64. std::string start_time = this->CTest->CurrentTime();
  65. unsigned int start_time_time = static_cast<unsigned int>(
  66. cmSystemTools::GetTime());
  67. cmGeneratedFileStream ofs;
  68. this->StartLogFile("Configure", ofs);
  69. cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: "
  70. << cCommand.c_str() << std::endl);
  71. res = this->CTest->RunMakeCommand(cCommand.c_str(), &output,
  72. &retVal, buildDirectory.c_str(),
  73. 0, ofs);
  74. if ( ofs )
  75. {
  76. ofs.close();
  77. }
  78. if ( os )
  79. {
  80. this->CTest->StartXML(os, this->AppendXML);
  81. os << "<Configure>\n"
  82. << "\t<StartDateTime>" << start_time << "</StartDateTime>"
  83. << std::endl
  84. << "\t<StartConfigureTime>" << start_time_time
  85. << "</StartConfigureTime>\n";
  86. if ( res == cmsysProcess_State_Exited && retVal )
  87. {
  88. os << retVal;
  89. }
  90. os << "<ConfigureCommand>" << cCommand.c_str() << "</ConfigureCommand>"
  91. << std::endl;
  92. cmCTestLog(this->CTest, DEBUG, "End" << std::endl);
  93. os << "<Log>" << cmCTest::MakeXMLSafe(output) << "</Log>" << std::endl;
  94. std::string end_time = this->CTest->CurrentTime();
  95. os << "\t<ConfigureStatus>" << retVal << "</ConfigureStatus>\n"
  96. << "\t<EndDateTime>" << end_time << "</EndDateTime>\n"
  97. << "\t<EndConfigureTime>" <<
  98. static_cast<unsigned int>(cmSystemTools::GetTime())
  99. << "</EndConfigureTime>\n"
  100. << "<ElapsedMinutes>"
  101. << static_cast<int>(
  102. (cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0
  103. << "</ElapsedMinutes>"
  104. << "</Configure>" << std::endl;
  105. this->CTest->EndXML(os);
  106. }
  107. }
  108. else
  109. {
  110. cmCTestLog(this->CTest, DEBUG, "Configure with command: " << cCommand
  111. << std::endl);
  112. }
  113. if (! res || retVal )
  114. {
  115. cmCTestLog(this->CTest, ERROR_MESSAGE,
  116. "Error(s) when configuring the project" << std::endl);
  117. return -1;
  118. }
  119. return 0;
  120. }