1. Momchil Velikov
  2. glLoadGen

Commits

Momchil Velikov  committed 6522ad9

Allow to build generated source as a DLL

  • Participants
  • Parent commits a55a83f
  • Branches default

Comments (0)

Files changed (4)

File data/gl_specinit.lua

View file
 	#define GLAPI extern
 #endif
 
+#if defined(_WIN32)
+	#if defined(GLLOADGEN_STATIC)
+		#define GLLOADGEN_FUNC
+	#else
+		#if defined(GLLOADGEN_EXPORTS)
+			#define GLLOADGEN_FUNC __declspec(dllexport)
+		#else
+			#define GLLOADGEN_FUNC __declspec(dllimport)
+		#endif
+	#endif
+#else
+	#define GLLOADGEN_FUNC
+#endif
 ]]

File modules/StyleGLLoad.lua

View file
 end
 
 function ext_hdr.WriteFuncDecl(hFile, func, typemap, spec, options)
-	hFile:fmt("extern %s %s;\n",
+	hFile:fmt("extern GLLOADGEN_FUNC %s %s;\n",
 		glload.GetFuncTypedefName(func, spec, options),
 		glload.GetFuncPtrName(func, spec, options))
 	hFile:fmt("#define %s %s\n",
 end
 
 function core_hdr.WriteFuncDecl(hFile, func, typemap, spec, options)
-	hFile:fmt("extern %s %s;\n",
+	hFile:fmt("extern GLLOADGEN_FUNC %s %s;\n",
 		glload.GetFuncTypedefName(func, spec, options),
 		glload.GetFuncPtrName(func, spec, options))
 	hFile:fmt("#define %s %s\n",
 end
 
 function cpp.ext_hdr.WriteFuncDecl(hFile, func, typemap, spec, options)
-	hFile:fmt("extern %s::%s %s;\n",
+	hFile:fmt("extern GLLOADGEN_FUNC %s::%s %s;\n",
 		glload.GetFuncPtrTypedefNamespace(),
 		glload.GetFuncTypedefName(func, spec, options),
 		func.name)

File modules/StylePointerC.lua

View file
 
 function my_style.header.WriteFuncDecl(hFile, func, typemap, spec, options)
 	--Declare the function pointer.
-	hFile:write("extern ",
+	hFile:write("extern GLLOADGEN_FUNC ",
 		GetFuncPtrDef(hFile, func, typemap, spec, options),
 		";\n")
 	
 		return
 	end
 	
-	hFile:fmt("int %s();\n", DecorateFuncName("GetMinorVersion", spec, options))
-	hFile:fmt("int %s();\n", DecorateFuncName("GetMajorVersion", spec, options))
-	hFile:fmt("int %s(int majorVersion, int minorVersion);\n",
+	hFile:fmt("GLLOADGEN_FUNC int %s();\n", DecorateFuncName("GetMinorVersion", spec, options))
+	hFile:fmt("GLLOADGEN_FUNC int %s();\n", DecorateFuncName("GetMajorVersion", spec, options))
+	hFile:fmt("GLLOADGEN_FUNC int %s(int majorVersion, int minorVersion);\n",
 		DecorateFuncName("IsVersionGEQ", spec, options))
 end
 

File modules/StylePointerCPP.lua

View file
 	end
 
 function my_style.header.WriteFuncDecl(hFile, func, typemap, spec, options)
-	hFile:write("extern ",
+	hFile:write("extern GLLOADGEN_FUNC ",
 		GenFuncPtrDefDirect(func, typemap, spec, options),
 		";\n")
 end
 
 function my_style.header.WriteVersioningFuncDecls(hFile, spec, options)
 	hFile:writeblock([[
-int GetMinorVersion();
-int GetMajorVersion();
-bool IsVersionGEQ(int majorVersion, int minorVersion);
+GLLOADGEN_FUNC int GetMinorVersion();
+GLLOADGEN_FUNC int GetMajorVersion();
+GLLOADGEN_FUNC bool IsVersionGEQ(int majorVersion, int minorVersion);
 ]])
 end