Commit e4cd5024 authored by Brad King's avatar Brad King 💬
Browse files

BUG: Fixed init function export on cygwin.

parent 3ef9221b
...@@ -10,6 +10,18 @@ static void CreateInitFile(const char *libName, ...@@ -10,6 +10,18 @@ static void CreateInitFile(const char *libName,
{ {
int i; int i;
#if defined(_WIN32) && !defined(__CYGWIN__)
const char* prefix = "";
#else
const char* prefix = "lib";
#endif
#if defined(_WIN32)
const char* dllexp = "__declspec(dllexport) ";
#else
const char* dllexp = "";
#endif
fprintf(fout,"// Generated by vtkWrapPythonInit in VTK/Wrapping\n"); fprintf(fout,"// Generated by vtkWrapPythonInit in VTK/Wrapping\n");
fprintf(fout,"#include \"vtkPython.h\"\n\n"); fprintf(fout,"#include \"vtkPython.h\"\n\n");
fprintf(fout,"#include \"vtkSystemIncludes.h\"\n"); fprintf(fout,"#include \"vtkSystemIncludes.h\"\n");
...@@ -21,33 +33,18 @@ static void CreateInitFile(const char *libName, ...@@ -21,33 +33,18 @@ static void CreateInitFile(const char *libName,
for (i = 0; i < numConcrete; i++) for (i = 0; i < numConcrete; i++)
{ {
#ifdef _WIN32 fprintf(fout,"extern \"C\" {%sPyObject *PyVTKClass_%sNew(char *); }\n", dllexp, concrete[i]);
fprintf(fout,"extern \"C\" {__declspec( dllexport) PyObject *PyVTKClass_%sNew(char *); }\n", concrete[i]);
#else
fprintf(fout,"extern \"C\" {PyObject *PyVTKClass_%sNew(char *); }\n",concrete[i]);
#endif
} }
fprintf(fout,"\nstatic PyMethodDef Py%s_ClassMethods[] = {\n", fprintf(fout,"\nstatic PyMethodDef Py%s_ClassMethods[] = {\n", libName);
libName);
fprintf(fout,"{NULL, NULL, 0, NULL}};\n\n"); fprintf(fout,"{NULL, NULL, 0, NULL}};\n\n");
#ifdef _WIN32 fprintf(fout,"extern \"C\" {%svoid init%s%s();}\n\n", dllexp, prefix, libName);
fprintf(fout,"extern \"C\" {__declspec( dllexport) void init%s();}\n\n",libName); fprintf(fout,"void init%s%s()\n{\n", prefix, libName);
fprintf(fout,"void init%s()\n{\n",libName);
#else
fprintf(fout,"extern \"C\" {void initlib%s();}\n\n",libName);
fprintf(fout,"void initlib%s()\n{\n",libName);
#endif
/* module init function */ /* module init function */
fprintf(fout," PyObject *m, *d, *c;\n\n"); fprintf(fout," PyObject *m, *d, *c;\n\n");
#ifdef _WIN32 fprintf(fout," static const char modulename[] = \"%s%s\";\n", prefix, libName);
fprintf(fout," static const char modulename[] = \"%s\";\n",libName);
#else
fprintf(fout," static const char modulename[] = \"lib%s\";\n",libName);
#endif
fprintf(fout," m = Py_InitModule((char*)modulename, Py%s_ClassMethods);\n", fprintf(fout," m = Py_InitModule((char*)modulename, Py%s_ClassMethods);\n",
libName); libName);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment