cmCTestConfigureHandler.cxx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. //clearly it would be nice if this were broken up into a few smaller
  24. //functions and commented...
  25. int cmCTestConfigureHandler::ProcessHandler()
  26. {
  27. cmCTestLog(m_CTest, HANDLER_OUTPUT, "Configure project" << std::endl);
  28. std::string cCommand = m_CTest->GetCTestConfiguration("ConfigureCommand");
  29. if ( cCommand.size() == 0 )
  30. {
  31. cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find ConfigureCommand key in the DartConfiguration.tcl"
  32. << std::endl);
  33. return -1;
  34. }
  35. std::string buildDirectory = m_CTest->GetCTestConfiguration("BuildDirectory");
  36. if ( buildDirectory.size() == 0 )
  37. {
  38. cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot find BuildDirectory key in the DartConfiguration.tcl" << std::endl);
  39. return -1;
  40. }
  41. double elapsed_time_start = cmSystemTools::GetTime();
  42. std::string output;
  43. int retVal = 0;
  44. int res = 0;
  45. if ( !m_CTest->GetShowOnly() )
  46. {
  47. cmGeneratedFileStream os;
  48. if ( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), "Configure.xml", os, true) )
  49. {
  50. cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open configure file" << std::endl);
  51. return 1;
  52. }
  53. std::string start_time = m_CTest->CurrentTime();
  54. cmGeneratedFileStream ofs;
  55. m_CTest->OpenOutputFile("Temporary", "LastConfigure.log", ofs);
  56. res = m_CTest->RunMakeCommand(cCommand.c_str(), &output,
  57. &retVal, buildDirectory.c_str(),
  58. 0, ofs);
  59. if ( ofs )
  60. {
  61. ofs.close();
  62. }
  63. if ( os )
  64. {
  65. m_CTest->StartXML(os);
  66. os << "<Configure>\n"
  67. << "\t<StartDateTime>" << start_time << "</StartDateTime>" << std::endl;
  68. if ( res == cmsysProcess_State_Exited && retVal )
  69. {
  70. os << retVal;
  71. }
  72. os << "<ConfigureCommand>" << cCommand.c_str() << "</ConfigureCommand>" << std::endl;
  73. cmCTestLog(m_CTest, DEBUG, "End" << std::endl);
  74. os << "<Log>" << cmCTest::MakeXMLSafe(output) << "</Log>" << std::endl;
  75. std::string end_time = m_CTest->CurrentTime();
  76. os << "\t<ConfigureStatus>" << retVal << "</ConfigureStatus>\n"
  77. << "\t<EndDateTime>" << end_time << "</EndDateTime>\n"
  78. << "<ElapsedMinutes>"
  79. << static_cast<int>(
  80. (cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0
  81. << "</ElapsedMinutes>"
  82. << "</Configure>" << std::endl;
  83. m_CTest->EndXML(os);
  84. }
  85. }
  86. else
  87. {
  88. cmCTestLog(m_CTest, DEBUG, "Configure with command: " << cCommand << std::endl);
  89. }
  90. if (! res || retVal )
  91. {
  92. cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) when updating the project" << std::endl);
  93. return -1;
  94. }
  95. return 0;
  96. }