Updated formatting of documentation plus a little reorganization.
[cmake.git] / Source / CTest / cmCTestConfigureHandler.cxx
blobb3a35a89d2dc79f692d34e3e07860e42d1ec27b1
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestConfigureHandler.cxx,v $
5 Language: C++
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"
20 #include "cmCTest.h"
21 #include "cmGeneratedFileStream.h"
22 #include "cmake.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);
44 std::string cCommand
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"
50 << std::endl);
51 return -1;
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"
60 << std::endl);
61 return -1;
64 double elapsed_time_start = cmSystemTools::GetTime();
65 std::string output;
66 int retVal = 0;
67 int res = 0;
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"
74 << std::endl);
75 return 1;
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(),
87 0, ofs);
89 if ( ofs )
91 ofs.close();
94 if ( os )
96 this->CTest->StartXML(os, this->AppendXML);
97 os << "<Configure>\n"
98 << "\t<StartDateTime>" << start_time << "</StartDateTime>"
99 << std::endl
100 << "\t<StartConfigureTime>" << start_time_time
101 << "</StartConfigureTime>\n";
103 if ( res == cmsysProcess_State_Exited && retVal )
105 os << retVal;
107 os << "<ConfigureCommand>" << cCommand.c_str() << "</ConfigureCommand>"
108 << std::endl;
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>"
118 << static_cast<int>(
119 (cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0
120 << "</ElapsedMinutes>"
121 << "</Configure>" << std::endl;
122 this->CTest->EndXML(os);
125 else
127 cmCTestLog(this->CTest, DEBUG, "Configure with command: " << cCommand
128 << std::endl);
130 if (! res || retVal )
132 cmCTestLog(this->CTest, ERROR_MESSAGE,
133 "Error(s) when configuring the project" << std::endl);
134 return -1;
136 return 0;