cmCTestConfigureHandler.cxx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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(m_CTest, HANDLER_OUTPUT, "Configure project" << std::endl);
  33. std::string cCommand = m_CTest->GetCTestConfiguration("ConfigureCommand");
  34. if ( cCommand.size() == 0 )
  35. {
  36. cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find ConfigureCommand key in the DartConfiguration.tcl"
  37. << std::endl);
  38. return -1;
  39. }
  40. std::string buildDirectory = m_CTest->GetCTestConfiguration("BuildDirectory");
  41. if ( buildDirectory.size() == 0 )
  42. {
  43. cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find BuildDirectory key in the DartConfiguration.tcl" << std::endl);
  44. return -1;
  45. }
  46. double elapsed_time_start = cmSystemTools::GetTime();
  47. std::string output;
  48. int retVal = 0;
  49. int res = 0;
  50. if ( !m_CTest->GetShowOnly() )
  51. {
  52. cmGeneratedFileStream os;
  53. if ( !this->StartResultingXML("Configure", os) )
  54. {
  55. cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open configure file" << std::endl);
  56. return 1;
  57. }
  58. std::string start_time = m_CTest->CurrentTime();
  59. cmGeneratedFileStream ofs;
  60. this->StartLogFile("Configure", ofs);
  61. cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " << cCommand.c_str() << std::endl);
  62. res = m_CTest->RunMakeCommand(cCommand.c_str(), &output,
  63. &retVal, buildDirectory.c_str(),
  64. 0, ofs);
  65. if ( ofs )
  66. {
  67. ofs.close();
  68. }
  69. if ( os )
  70. {
  71. m_CTest->StartXML(os);
  72. os << "<Configure>\n"
  73. << "\t<StartDateTime>" << start_time << "</StartDateTime>" << std::endl;
  74. if ( res == cmsysProcess_State_Exited && retVal )
  75. {
  76. os << retVal;
  77. }
  78. os << "<ConfigureCommand>" << cCommand.c_str() << "</ConfigureCommand>" << std::endl;
  79. cmCTestLog(m_CTest, DEBUG, "End" << std::endl);
  80. os << "<Log>" << cmCTest::MakeXMLSafe(output) << "</Log>" << std::endl;
  81. std::string end_time = m_CTest->CurrentTime();
  82. os << "\t<ConfigureStatus>" << retVal << "</ConfigureStatus>\n"
  83. << "\t<EndDateTime>" << end_time << "</EndDateTime>\n"
  84. << "<ElapsedMinutes>"
  85. << static_cast<int>(
  86. (cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0
  87. << "</ElapsedMinutes>"
  88. << "</Configure>" << std::endl;
  89. m_CTest->EndXML(os);
  90. }
  91. }
  92. else
  93. {
  94. cmCTestLog(m_CTest, DEBUG, "Configure with command: " << cCommand << std::endl);
  95. }
  96. if (! res || retVal )
  97. {
  98. cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) when updating the project" << std::endl);
  99. return -1;
  100. }
  101. return 0;
  102. }