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:
parent
633041837c
commit
1f68c1be85
@ -52,78 +52,108 @@ cmVTKMakeInstantiatorCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string libName = args[0];
|
||||
std::string srcListName = args[1];
|
||||
m_ExportMacro = args[2];
|
||||
m_ClassName = args[0];
|
||||
m_Makefile->ExpandVariablesInString(m_ClassName);
|
||||
|
||||
std::string outSourceList = args[1];
|
||||
m_Makefile->ExpandVariablesInString(outSourceList);
|
||||
|
||||
std::vector<cmStdString> inSourceLists;
|
||||
m_ExportMacro = "-";
|
||||
unsigned int groupSize = 10;
|
||||
|
||||
// Find the path of the files to be generated.
|
||||
std::string filePath = m_Makefile->GetCurrentOutputDirectory();
|
||||
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());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->SetError("GROUP_SIZE option used without value.");
|
||||
return false;
|
||||
}
|
||||
std::string gSize = args[i].c_str();
|
||||
m_Makefile->ExpandVariablesInString(gSize);
|
||||
groupSize = atoi(gSize.c_str());
|
||||
}
|
||||
else if(args[i] == "HEADER_LOCATION")
|
||||
else
|
||||
{
|
||||
if(++i < args.size())
|
||||
{
|
||||
headerPath = args[i];
|
||||
m_Makefile->ExpandVariablesInString(headerPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->SetError("HEADER_LOCATION option used without value.");
|
||||
return false;
|
||||
}
|
||||
this->SetError("GROUP_SIZE option used without value.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(args[i] == "HEADER_LOCATION")
|
||||
{
|
||||
if(++i < args.size())
|
||||
{
|
||||
headerPath = args[i];
|
||||
m_Makefile->ExpandVariablesInString(headerPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->SetError("HEADER_LOCATION option used without value.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(args[i] == "EXPORT_MACRO")
|
||||
{
|
||||
if(++i < args.size())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
m_Makefile->ExpandVariablesInString(srcListName);
|
||||
|
||||
// Find the source list specified.
|
||||
cmMakefile::SourceMap::iterator srcListIter =
|
||||
m_Makefile->GetSources().find(srcListName);
|
||||
|
||||
if(srcListIter == m_Makefile->GetSources().end())
|
||||
if(m_ExportMacro == "-")
|
||||
{
|
||||
std::string errStr = "No source list named " + srcListName;
|
||||
this->SetError(errStr.c_str());
|
||||
this->SetError("No EXPORT_MACRO option given.");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ClassName = libName+"Instantiator";
|
||||
|
||||
std::vector<cmSourceFile>& srcList = srcListIter->second;
|
||||
|
||||
// Collect the names of the classes.
|
||||
for(std::vector<cmSourceFile>::iterator src = srcList.begin();
|
||||
src != srcList.end();++src)
|
||||
for(std::vector<cmStdString>::const_iterator s = inSourceLists.begin();
|
||||
s != inSourceLists.end(); ++s)
|
||||
{
|
||||
// Wrap-excluded and abstract classes do not have a New() method.
|
||||
// vtkIndent and vtkTimeStamp are special cases and are not
|
||||
// vtkObject subclasses.
|
||||
if(!src->GetWrapExclude() && !src->GetIsAnAbstractClass()
|
||||
&& (src->GetSourceName() != "vtkIndent")
|
||||
&& (src->GetSourceName() != "vtkTimeStamp"))
|
||||
// Find the source list specified.
|
||||
cmMakefile::SourceMap::iterator srcListIter =
|
||||
m_Makefile->GetSources().find(*s);
|
||||
|
||||
if(srcListIter == m_Makefile->GetSources().end())
|
||||
{
|
||||
m_Classes.push_back(src->GetSourceName());
|
||||
std::string errStr = "No source list named " + *s;
|
||||
this->SetError(errStr.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<cmSourceFile>& srcList = srcListIter->second;
|
||||
|
||||
// Collect the names of the classes.
|
||||
for(std::vector<cmSourceFile>::iterator src = srcList.begin();
|
||||
src != srcList.end();++src)
|
||||
{
|
||||
// Wrap-excluded and abstract classes do not have a New() method.
|
||||
// vtkIndent and vtkTimeStamp are special cases and are not
|
||||
// vtkObject subclasses.
|
||||
if(!src->GetWrapExclude() && !src->GetIsAnAbstractClass()
|
||||
&& (src->GetSourceName() != "vtkIndent")
|
||||
&& (src->GetSourceName() != "vtkTimeStamp"))
|
||||
{
|
||||
m_Classes.push_back(src->GetSourceName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate the header with the class declaration.
|
||||
{
|
||||
@ -157,7 +187,7 @@ cmVTKMakeInstantiatorCommand
|
||||
file.SetName(fileName.c_str(), filePath.c_str(),
|
||||
m_Makefile->GetSourceExtensions(),
|
||||
m_Makefile->GetHeaderExtensions());
|
||||
m_Makefile->AddSource(file, srcListName.c_str());
|
||||
m_Makefile->AddSource(file, outSourceList.c_str());
|
||||
}
|
||||
|
||||
unsigned int numClasses = m_Classes.size();
|
||||
@ -190,8 +220,8 @@ cmVTKMakeInstantiatorCommand
|
||||
file.SetIsAnAbstractClass(false);
|
||||
file.SetName(fileName.c_str(), filePath.c_str(),
|
||||
m_Makefile->GetSourceExtensions(),
|
||||
m_Makefile->GetHeaderExtensions());
|
||||
m_Makefile->AddSource(file, srcListName.c_str());
|
||||
m_Makefile->GetHeaderExtensions());
|
||||
m_Makefile->AddSource(file, outSourceList.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -69,24 +69,24 @@ public:
|
||||
/** Succinct documentation. */
|
||||
virtual const char* GetTerseDocumentation()
|
||||
{
|
||||
return "Setup a library's classes to be created by vtkInstantiator";
|
||||
return "Register classes for creation by vtkInstantiator";
|
||||
}
|
||||
|
||||
/** More documentation. */
|
||||
virtual const char* GetFullDocumentation()
|
||||
{
|
||||
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"
|
||||
"Generates a new class for the given library to allow its other\n"
|
||||
"classes to be created by vtkInstantiator. Functions to create\n"
|
||||
"classes listed in srcList are registered with vtkInstantiator, and\n"
|
||||
"the new class containing this code is added to the srcList for\n"
|
||||
"inclusion in the library. The libName argument is used to generate\n"
|
||||
"the filename and name of the class used to register the functions\n"
|
||||
"when the library is loaded. The exportMacro is the name of the\n"
|
||||
"DLL export macro to use in the class definition\n"
|
||||
"(ex. VTK_COMMON_EXPORT).\n"
|
||||
"Generates a new class with the given name and adds its files to the\n"
|
||||
"given outSourceList. It registers the classes from the other given\n"
|
||||
"source lists with vtkInstantiator when it is loaded. The output\n"
|
||||
"source list should be added to the library with the classes it\n"
|
||||
"registers.\n"
|
||||
"The EXPORT_MACRO argument must be given and followed by the export\n"
|
||||
"macro to use when generating the class (ex. VTK_COMMON_EXPORT).\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 generated class implementation files always go in the build\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user