1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestConfigureHandler.cxx,v $
6 Date: $Date: 2009-02-05 21:31:37 $
7 Version: $Revision: 1.18 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
18 #include "cmCTestConfigureHandler.h"
21 #include "cmGeneratedFileStream.h"
23 #include "cmXMLSafe.h"
24 #include <cmsys/Process.h>
27 //----------------------------------------------------------------------
28 cmCTestConfigureHandler::cmCTestConfigureHandler()
32 //----------------------------------------------------------------------
33 void cmCTestConfigureHandler::Initialize()
35 this->Superclass::Initialize();
38 //----------------------------------------------------------------------
39 //clearly it would be nice if this were broken up into a few smaller
40 //functions and commented...
41 int cmCTestConfigureHandler::ProcessHandler()
43 cmCTestLog(this->CTest
, HANDLER_OUTPUT
, "Configure project" << std::endl
);
45 = this->CTest
->GetCTestConfiguration("ConfigureCommand");
46 if ( cCommand
.size() == 0 )
48 cmCTestLog(this->CTest
, ERROR_MESSAGE
,
49 "Cannot find ConfigureCommand key in the DartConfiguration.tcl"
54 std::string buildDirectory
55 = this->CTest
->GetCTestConfiguration("BuildDirectory");
56 if ( buildDirectory
.size() == 0 )
58 cmCTestLog(this->CTest
, ERROR_MESSAGE
,
59 "Cannot find BuildDirectory key in the DartConfiguration.tcl"
64 double elapsed_time_start
= cmSystemTools::GetTime();
68 if ( !this->CTest
->GetShowOnly() )
70 cmGeneratedFileStream os
;
71 if(!this->StartResultingXML(cmCTest::PartConfigure
, "Configure", os
))
73 cmCTestLog(this->CTest
, ERROR_MESSAGE
, "Cannot open configure file"
77 std::string start_time
= this->CTest
->CurrentTime();
78 unsigned int start_time_time
= static_cast<unsigned int>(
79 cmSystemTools::GetTime());
81 cmGeneratedFileStream ofs
;
82 this->StartLogFile("Configure", ofs
);
83 cmCTestLog(this->CTest
, HANDLER_VERBOSE_OUTPUT
, "Configure with command: "
84 << cCommand
.c_str() << std::endl
);
85 res
= this->CTest
->RunMakeCommand(cCommand
.c_str(), &output
,
86 &retVal
, buildDirectory
.c_str(),
96 this->CTest
->StartXML(os
, this->AppendXML
);
98 << "\t<StartDateTime>" << start_time
<< "</StartDateTime>"
100 << "\t<StartConfigureTime>" << start_time_time
101 << "</StartConfigureTime>\n";
103 if ( res
== cmsysProcess_State_Exited
&& retVal
)
107 os
<< "<ConfigureCommand>" << cCommand
.c_str() << "</ConfigureCommand>"
109 cmCTestLog(this->CTest
, DEBUG
, "End" << std::endl
);
110 os
<< "<Log>" << cmXMLSafe(output
) << "</Log>" << std::endl
;
111 std::string end_time
= this->CTest
->CurrentTime();
112 os
<< "\t<ConfigureStatus>" << retVal
<< "</ConfigureStatus>\n"
113 << "\t<EndDateTime>" << end_time
<< "</EndDateTime>\n"
114 << "\t<EndConfigureTime>" <<
115 static_cast<unsigned int>(cmSystemTools::GetTime())
116 << "</EndConfigureTime>\n"
117 << "<ElapsedMinutes>"
119 (cmSystemTools::GetTime() - elapsed_time_start
)/6)/10.0
120 << "</ElapsedMinutes>"
121 << "</Configure>" << std::endl
;
122 this->CTest
->EndXML(os
);
127 cmCTestLog(this->CTest
, DEBUG
, "Configure with command: " << cCommand
130 if (! res
|| retVal
)
132 cmCTestLog(this->CTest
, ERROR_MESSAGE
,
133 "Error(s) when configuring the project" << std::endl
);