ENH: Added support for including extra files in generated header to get access to export macros of derived projects.
This commit is contained in:
parent
3da299a796
commit
ac74d51382
@ -37,6 +37,7 @@ cmVTKMakeInstantiatorCommand
|
|||||||
std::vector<cmStdString> inSourceLists;
|
std::vector<cmStdString> inSourceLists;
|
||||||
m_ExportMacro = "-";
|
m_ExportMacro = "-";
|
||||||
unsigned int groupSize = 10;
|
unsigned int groupSize = 10;
|
||||||
|
bool includesMode = false;
|
||||||
|
|
||||||
// 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();
|
||||||
@ -46,6 +47,7 @@ cmVTKMakeInstantiatorCommand
|
|||||||
{
|
{
|
||||||
if(args[i] == "GROUP_SIZE")
|
if(args[i] == "GROUP_SIZE")
|
||||||
{
|
{
|
||||||
|
includesMode = false;
|
||||||
if(++i < args.size())
|
if(++i < args.size())
|
||||||
{
|
{
|
||||||
std::string gSize = args[i].c_str();
|
std::string gSize = args[i].c_str();
|
||||||
@ -60,6 +62,7 @@ cmVTKMakeInstantiatorCommand
|
|||||||
}
|
}
|
||||||
else if(args[i] == "HEADER_LOCATION")
|
else if(args[i] == "HEADER_LOCATION")
|
||||||
{
|
{
|
||||||
|
includesMode = false;
|
||||||
if(++i < args.size())
|
if(++i < args.size())
|
||||||
{
|
{
|
||||||
headerPath = args[i];
|
headerPath = args[i];
|
||||||
@ -73,6 +76,7 @@ cmVTKMakeInstantiatorCommand
|
|||||||
}
|
}
|
||||||
else if(args[i] == "EXPORT_MACRO")
|
else if(args[i] == "EXPORT_MACRO")
|
||||||
{
|
{
|
||||||
|
includesMode = false;
|
||||||
if(++i < args.size())
|
if(++i < args.size())
|
||||||
{
|
{
|
||||||
m_ExportMacro = args[i];
|
m_ExportMacro = args[i];
|
||||||
@ -84,12 +88,24 @@ cmVTKMakeInstantiatorCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If not an option, it must be another input source list name.
|
else if(args[i] == "INCLUDES")
|
||||||
|
{
|
||||||
|
includesMode = true;
|
||||||
|
}
|
||||||
|
// If not an option, it must be another input source list name or
|
||||||
|
// an include file.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string s = args[i];
|
std::string s = args[i];
|
||||||
m_Makefile->ExpandVariablesInString(s);
|
m_Makefile->ExpandVariablesInString(s);
|
||||||
inSourceLists.push_back(s);
|
if(!includesMode)
|
||||||
|
{
|
||||||
|
inSourceLists.push_back(s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Includes.push_back(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +239,12 @@ cmVTKMakeInstantiatorCommand
|
|||||||
"#ifndef __" << m_ClassName.c_str() << "_h\n"
|
"#ifndef __" << m_ClassName.c_str() << "_h\n"
|
||||||
"#define __" << m_ClassName.c_str() << "_h\n"
|
"#define __" << m_ClassName.c_str() << "_h\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#include \"vtkInstantiator.h\"\n"
|
"#include \"vtkInstantiator.h\"\n";
|
||||||
|
for(unsigned int i=0;i < m_Includes.size();++i)
|
||||||
|
{
|
||||||
|
os << "#include \"" << m_Includes[i].c_str() << "\"\n";
|
||||||
|
}
|
||||||
|
os <<
|
||||||
"\n"
|
"\n"
|
||||||
"class " << m_ClassName.c_str() << "Initialize;\n"
|
"class " << m_ClassName.c_str() << "Initialize;\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -55,7 +55,8 @@ public:
|
|||||||
"VTK_MAKE_INSTANTIATOR(className outSourceList\n"
|
"VTK_MAKE_INSTANTIATOR(className outSourceList\n"
|
||||||
" src-list1 [src-list2 ..]\n"
|
" src-list1 [src-list2 ..]\n"
|
||||||
" EXPORT_MACRO exportMacro\n"
|
" EXPORT_MACRO exportMacro\n"
|
||||||
" [HEADER_LOCATION dir] [GROUP_SIZE groupSize])\n"
|
" [HEADER_LOCATION dir] [GROUP_SIZE groupSize]\n"
|
||||||
|
" [INCLUDES [file1 file2 ..]])\n"
|
||||||
"Generates a new class with the given name and adds its files to the\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"
|
"given outSourceList. It registers the classes from the other given\n"
|
||||||
"source lists with vtkInstantiator when it is loaded. The output\n"
|
"source lists with vtkInstantiator when it is loaded. The output\n"
|
||||||
@ -71,7 +72,10 @@ public:
|
|||||||
"The GROUP_SIZE option must be followed by a positive integer.\n"
|
"The GROUP_SIZE option must be followed by a positive integer.\n"
|
||||||
"As an implementation detail, the registered creation functions may\n"
|
"As an implementation detail, the registered creation functions may\n"
|
||||||
"be split up into multiple files. The groupSize option specifies\n"
|
"be split up into multiple files. The groupSize option specifies\n"
|
||||||
"the number of classes per file. Its default is 10.";
|
"the number of classes per file. Its default is 10. The INCLUDES\n"
|
||||||
|
"option can be followed by a list of zero or more files. These files\n"
|
||||||
|
"will be #included by the generated instantiator header, and can be\n"
|
||||||
|
"used to gain access to the specified exportMacro in the C++ code.";
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTypeMacro(cmVTKMakeInstantiatorCommand, cmCommand);
|
cmTypeMacro(cmVTKMakeInstantiatorCommand, cmCommand);
|
||||||
@ -79,6 +83,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
std::string m_ClassName;
|
std::string m_ClassName;
|
||||||
std::string m_ExportMacro;
|
std::string m_ExportMacro;
|
||||||
|
std::vector<cmStdString> m_Includes;
|
||||||
std::vector<cmStdString> m_Classes;
|
std::vector<cmStdString> m_Classes;
|
||||||
|
|
||||||
std::string GenerateCreationFileName(unsigned int group);
|
std::string GenerateCreationFileName(unsigned int group);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user