So i finally defeated my 'inner Schweinehund' and set up a working Windows development system again. Using the Visual Studio C++ 2008 Express edition i'm now able to compile UDF projects generated by CodeGen_MySQL_UDF aka. udf-gen, and the udf-gen script now works natively on Windows, too.
To make the udf-gen script work on Windows, too, i added wrapper scripts udf-gen.bat and udf-gen.sh now instead of just relying on Unix-only hashbang 'magic'. The PEAR installer is now clever enough to only install the wrapper script needed for the platform it installs on, it also strips the .sh script ending on Unix so that it still can be invoked as udf-gen without extension on all platforms.
The actual code generation was supposed to be Windows aware already, but actually testing it now revealed three small issues:
- DLLEXP was added in front of the UDF library function definitions but was missing from the prototypes generated for these
- DBUG_ENTER() macro calls needed to be moved so that they are only generated after local variable declarations
- DBUG_OFF is always declared for Windows builds for now as i still have to figure out how to make the my_dbug library work on windows builds
Generating and compiling a udf-gen based function library now requires the following steps:
> udf-gen my-udf.xml
> cd my-udf
> cmake -G "Visual Studio 9 2008"
- open the generated my-udf.sln solution file with VisualStudio and build it
- copy the .DLL file from the Release or Debug subdir to your servers plugin dir
- load and use the UDF function as usual
