cmCTestConfigureHandler.cxx 3.5 KB

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