STYLE: create command documentation for ctest

I think some of the cmake commands should be removed from ctest if possible,
like add_executable etc.

Alex
This commit is contained in:
Alexander Neundorf 2007-06-08 16:06:33 -04:00
parent d1c4a0bf9e
commit e37f8e2964
4 changed files with 70 additions and 45 deletions

View File

@ -283,6 +283,46 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
return retVal;
}
void cmCTestScriptHandler::CreateCMake()
{
// create a cmake instance to read the configuration script
if (this->CMake)
{
delete this->CMake;
delete this->GlobalGenerator;
delete this->LocalGenerator;
}
this->CMake = new cmake;
this->CMake->AddCMakePaths(this->CTest->GetCTestExecutable());
this->GlobalGenerator = new cmGlobalGenerator;
this->GlobalGenerator->SetCMakeInstance(this->CMake);
this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator();
this->LocalGenerator->SetGlobalGenerator(this->GlobalGenerator);
this->Makefile = this->LocalGenerator->GetMakefile();
// add any ctest specific commands, probably should have common superclass
// for ctest commands to clean this up. If a couple more commands are
// created with the same format lets do that - ken
this->AddCTestCommand(new cmCTestBuildCommand);
this->AddCTestCommand(new cmCTestConfigureCommand);
this->AddCTestCommand(new cmCTestCoverageCommand);
this->AddCTestCommand(new cmCTestEmptyBinaryDirectoryCommand);
this->AddCTestCommand(new cmCTestMemCheckCommand);
this->AddCTestCommand(new cmCTestReadCustomFilesCommand);
this->AddCTestCommand(new cmCTestRunScriptCommand);
this->AddCTestCommand(new cmCTestSleepCommand);
this->AddCTestCommand(new cmCTestStartCommand);
this->AddCTestCommand(new cmCTestSubmitCommand);
this->AddCTestCommand(new cmCTestTestCommand);
this->AddCTestCommand(new cmCTestUpdateCommand);
}
void cmCTestScriptHandler::GetCommandDocumentation(std::vector<cmDocumentationEntry>& v) const
{
this->CMake->GetCommandDocumentation(v);
}
//----------------------------------------------------------------------
// this sets up some variables for the script to use, creates the required
@ -307,22 +347,9 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
return 1;
}
// create a cmake instance to read the configuration script
// read in the list file to fill the cache
if (this->CMake)
{
delete this->CMake;
delete this->GlobalGenerator;
delete this->LocalGenerator;
}
this->CMake = new cmake;
this->CMake->AddCMakePaths(this->CTest->GetCTestExecutable());
this->GlobalGenerator = new cmGlobalGenerator;
this->GlobalGenerator->SetCMakeInstance(this->CMake);
this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator();
this->LocalGenerator->SetGlobalGenerator(this->GlobalGenerator);
this->Makefile = this->LocalGenerator->GetMakefile();
// create a cmake instance to read the configuration script
this->CreateCMake();
// set a variable with the path to the current script
this->Makefile->AddDefinition("CTEST_SCRIPT_DIRECTORY",
@ -336,22 +363,6 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true);
this->UpdateElapsedTime();
// add any ctest specific commands, probably should have common superclass
// for ctest commands to clean this up. If a couple more commands are
// created with the same format lets do that - ken
this->AddCTestCommand(new cmCTestBuildCommand);
this->AddCTestCommand(new cmCTestConfigureCommand);
this->AddCTestCommand(new cmCTestCoverageCommand);
this->AddCTestCommand(new cmCTestEmptyBinaryDirectoryCommand);
this->AddCTestCommand(new cmCTestMemCheckCommand);
this->AddCTestCommand(new cmCTestReadCustomFilesCommand);
this->AddCTestCommand(new cmCTestRunScriptCommand);
this->AddCTestCommand(new cmCTestSleepCommand);
this->AddCTestCommand(new cmCTestStartCommand);
this->AddCTestCommand(new cmCTestSubmitCommand);
this->AddCTestCommand(new cmCTestTestCommand);
this->AddCTestCommand(new cmCTestUpdateCommand);
// add the script arg if defined
if (script_arg.size())
{

View File

@ -108,6 +108,9 @@ public:
void Initialize();
void CreateCMake();
void GetCommandDocumentation(std::vector<cmDocumentationEntry>& v) const;
private:
// reads in a script
int ReadInScript(const std::string& total_script_arg);

View File

@ -301,28 +301,31 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
//----------------------------------------------------------------------------
bool cmDocumentation::CreateModulesSection()
{
this->ModulesSection.Append(cmDocumentationModulesHeader[0]);
std::string cmakeModules = this->CMakeRoot;
cmakeModules += "/Modules";
cmsys::Directory dir;
dir.Load(cmakeModules.c_str());
for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i)
if (dir.GetNumberOfFiles() > 0)
{
std::string fname = dir.GetFile(i);
if(fname.length() > 6)
this->ModulesSection.Append(cmDocumentationModulesHeader[0]);
for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i)
{
if(fname.substr(fname.length()-6, 6) == ".cmake")
std::string fname = dir.GetFile(i);
if(fname.length() > 6)
{
std::string moduleName = fname.substr(0, fname.length()-6);
std::string path = cmakeModules;
path += "/";
path += fname;
this->CreateSingleModule(path.c_str(), moduleName.c_str());
if(fname.substr(fname.length()-6, 6) == ".cmake")
{
std::string moduleName = fname.substr(0, fname.length()-6);
std::string path = cmakeModules;
path += "/";
path += fname;
this->CreateSingleModule(path.c_str(), moduleName.c_str());
}
}
}
}
cmDocumentationEntry e = { 0, 0, 0 };
this->ModulesSection.Append(e);
}
cmDocumentationEntry e = { 0, 0, 0 };
this->ModulesSection.Append(e);
}
return true;
}

View File

@ -21,6 +21,7 @@
#include "cmake.h"
#include "cmDocumentation.h"
#include "CTest/cmCTestScriptHandler.h"
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationName[] =
@ -236,11 +237,18 @@ int main (int argc, char *argv[])
if(doc.CheckOptions(argc, argv) || nocwd)
{
// Construct and print requested documentation.
std::vector<cmDocumentationEntry> commands;
cmCTestScriptHandler* ch =
static_cast<cmCTestScriptHandler*>(inst.GetHandler("script"));
ch->CreateCMake();
ch->GetCommandDocumentation(commands);
doc.SetName("ctest");
doc.SetNameSection(cmDocumentationName);
doc.SetUsageSection(cmDocumentationUsage);
doc.SetDescriptionSection(cmDocumentationDescription);
doc.SetOptionsSection(cmDocumentationOptions);
doc.SetCommandsSection(&commands[0]);
doc.SetSeeAlsoList(cmDocumentationSeeAlso);
#ifdef cout
# undef cout