ENH: Improved flexibility of command by allowing specificiation of separate input and outputs source lists. Multiple input source lists are now also allowed.

This commit is contained in:
Brad King 2001-12-18 11:35:51 -05:00
parent 633041837c
commit 1f68c1be85
2 changed files with 94 additions and 64 deletions

View File

@ -52,24 +52,29 @@ cmVTKMakeInstantiatorCommand
return false; return false;
} }
std::string libName = args[0]; m_ClassName = args[0];
std::string srcListName = args[1]; m_Makefile->ExpandVariablesInString(m_ClassName);
m_ExportMacro = args[2];
std::string outSourceList = args[1];
m_Makefile->ExpandVariablesInString(outSourceList);
std::vector<cmStdString> inSourceLists;
m_ExportMacro = "-";
unsigned int groupSize = 10; unsigned int groupSize = 10;
// Find the path of the files to be generated. // Find the path of the files to be generated.
std::string filePath = m_Makefile->GetCurrentOutputDirectory(); std::string filePath = m_Makefile->GetCurrentOutputDirectory();
std::string headerPath = filePath; std::string headerPath = filePath;
if(args.size() > 3) for(unsigned int i=2;i < args.size();++i)
{
for(unsigned int i=3;i < args.size();++i)
{ {
if(args[i] == "GROUP_SIZE") if(args[i] == "GROUP_SIZE")
{ {
if(++i < args.size()) if(++i < args.size())
{ {
groupSize = atoi(args[i].c_str()); std::string gSize = args[i].c_str();
m_Makefile->ExpandVariablesInString(gSize);
groupSize = atoi(gSize.c_str());
} }
else else
{ {
@ -90,23 +95,47 @@ cmVTKMakeInstantiatorCommand
return false; return false;
} }
} }
} else if(args[i] == "EXPORT_MACRO")
}
m_Makefile->ExpandVariablesInString(srcListName);
// Find the source list specified.
cmMakefile::SourceMap::iterator srcListIter =
m_Makefile->GetSources().find(srcListName);
if(srcListIter == m_Makefile->GetSources().end())
{ {
std::string errStr = "No source list named " + srcListName; if(++i < args.size())
this->SetError(errStr.c_str()); {
m_ExportMacro = args[i];
m_Makefile->ExpandVariablesInString(m_ExportMacro);
}
else
{
this->SetError("EXPORT_MACRO option used without value.");
return false;
}
}
// If not an option, it must be another input source list name.
else
{
std::string s = args[i];
m_Makefile->ExpandVariablesInString(s);
inSourceLists.push_back(s);
}
}
if(m_ExportMacro == "-")
{
this->SetError("No EXPORT_MACRO option given.");
return false; return false;
} }
m_ClassName = libName+"Instantiator"; for(std::vector<cmStdString>::const_iterator s = inSourceLists.begin();
s != inSourceLists.end(); ++s)
{
// Find the source list specified.
cmMakefile::SourceMap::iterator srcListIter =
m_Makefile->GetSources().find(*s);
if(srcListIter == m_Makefile->GetSources().end())
{
std::string errStr = "No source list named " + *s;
this->SetError(errStr.c_str());
return false;
}
std::vector<cmSourceFile>& srcList = srcListIter->second; std::vector<cmSourceFile>& srcList = srcListIter->second;
@ -124,6 +153,7 @@ cmVTKMakeInstantiatorCommand
m_Classes.push_back(src->GetSourceName()); m_Classes.push_back(src->GetSourceName());
} }
} }
}
// Generate the header with the class declaration. // Generate the header with the class declaration.
{ {
@ -157,7 +187,7 @@ cmVTKMakeInstantiatorCommand
file.SetName(fileName.c_str(), filePath.c_str(), file.SetName(fileName.c_str(), filePath.c_str(),
m_Makefile->GetSourceExtensions(), m_Makefile->GetSourceExtensions(),
m_Makefile->GetHeaderExtensions()); m_Makefile->GetHeaderExtensions());
m_Makefile->AddSource(file, srcListName.c_str()); m_Makefile->AddSource(file, outSourceList.c_str());
} }
unsigned int numClasses = m_Classes.size(); unsigned int numClasses = m_Classes.size();
@ -191,7 +221,7 @@ cmVTKMakeInstantiatorCommand
file.SetName(fileName.c_str(), filePath.c_str(), file.SetName(fileName.c_str(), filePath.c_str(),
m_Makefile->GetSourceExtensions(), m_Makefile->GetSourceExtensions(),
m_Makefile->GetHeaderExtensions()); m_Makefile->GetHeaderExtensions());
m_Makefile->AddSource(file, srcListName.c_str()); m_Makefile->AddSource(file, outSourceList.c_str());
} }
return true; return true;

View File

@ -69,24 +69,24 @@ public:
/** Succinct documentation. */ /** Succinct documentation. */
virtual const char* GetTerseDocumentation() virtual const char* GetTerseDocumentation()
{ {
return "Setup a library's classes to be created by vtkInstantiator"; return "Register classes for creation by vtkInstantiator";
} }
/** More documentation. */ /** More documentation. */
virtual const char* GetFullDocumentation() virtual const char* GetFullDocumentation()
{ {
return return
"VTK_MAKE_INSTANTIATOR(libName srcList exportMacro\n" "VTK_MAKE_INSTANTIATOR(className outSourceList\n"
" src-list1 [src-list2 ..]\n"
" EXPORT_MACRO exportMacro\n"
" [HEADER_LOCATION dir] [GROUP_SIZE groupSize])\n" " [HEADER_LOCATION dir] [GROUP_SIZE groupSize])\n"
"Generates a new class for the given library to allow its other\n" "Generates a new class with the given name and adds its files to the\n"
"classes to be created by vtkInstantiator. Functions to create\n" "given outSourceList. It registers the classes from the other given\n"
"classes listed in srcList are registered with vtkInstantiator, and\n" "source lists with vtkInstantiator when it is loaded. The output\n"
"the new class containing this code is added to the srcList for\n" "source list should be added to the library with the classes it\n"
"inclusion in the library. The libName argument is used to generate\n" "registers.\n"
"the filename and name of the class used to register the functions\n" "The EXPORT_MACRO argument must be given and followed by the export\n"
"when the library is loaded. The exportMacro is the name of the\n" "macro to use when generating the class (ex. VTK_COMMON_EXPORT).\n"
"DLL export macro to use in the class definition\n"
"(ex. VTK_COMMON_EXPORT).\n"
"The HEADER_LOCATION option must be followed by a path. It specifies\n" "The HEADER_LOCATION option must be followed by a path. It specifies\n"
"the directory in which to place the generated class's header file.\n" "the directory in which to place the generated class's header file.\n"
"The generated class implementation files always go in the build\n" "The generated class implementation files always go in the build\n"