GNOME Bugzilla – Bug 752952
Enable the Sources to Build On Visual Studio
Last modified: 2015-08-06 16:54:03 UTC
Hi, As requested by Nacho, I was trying to see whether libsoup was buildable on Visual Studio, and it seems that surprisingly, it was not overly complicated. I will attach patches to the code to make this work, along with an enhancement for all Windows builds to make the libsoup DLL more relocatable. p.s. However, as there isn't a build of glib-networking for Visual Studio, it will be so that some features of libsoup will not be working, notably TLS (harder due to the use of GNUTLS) and proxy (should be easier though), which is provided by glib-networking. As a result, this would not contain MSVC project files for building libsoup on Visual Studio at the moment. With blessings, thank you!
Created attachment 308286 [details] [review] soup-xmlrpc.c: Use g_snprintf() Hi, First up is the changes to the soup-xmlrpc.c to make it use g_snprintf() instead of snprintf(), as snprintf() is not universally available...
Created attachment 308287 [details] [review] soup-websocket.c: Avoid VLAs Hi, Visual Studio does not like any array with 0-lengths or VLAs of any sort, even if the length is a const int (or so), so we need to #define a macro/value for it, as that is the value used for that function...
Created attachment 308288 [details] [review] soup_init(): Don't Hardcode Paths on Windows Hi, This is an enhancement for all Windows builds so that the localedir can be acquired at run-time, instead of using the LOCALEDIR which is hard-coded at build-time. With blessings, thank you!
Review of attachment 308288 [details] [review]: Hey Fan, could you fix the coding style here? It seems you use the gnu one while it should be the linux one.
Comment on attachment 308288 [details] [review] soup_init(): Don't Hardcode Paths on Windows >+BOOL WINAPI >+DllMain (HINSTANCE hinstDLL, Could this be done with G_DEFINE_CONSTRUCTOR instead? >+ gchar* basedir = g_win32_get_package_installation_directory_of_module (soup_dll); >+ gchar* localedir = g_build_filename (basedir, "share", "locale", NULL); Just "char", not "gchar" please.
Created attachment 308806 [details] [review] soup_init(): Don't Hardcode Paths on Windows, take 2 Hi Dan, Thanks for the reviews, the patches were pushed as follows: attachment 308286 [details] [review]: a83276a attachment 308287 [details] [review]: 407985a (In reply to Dan Winship from comment #5) > Could this be done with G_DEFINE_CONSTRUCTOR instead? Not really. The Windows relocatable functions (i.e. g_win32_get_package_installation_directory_of_module()) when used against a library DLL looks for a HMODULE that comes from the HINSTANCE that comes from the DllMain() when the process is being attached. This is similar to what is done in GLib and GTK+ and so, so this is different from G_DEFINE_CONSTRUCTOR, which is used more for GResource. > Just "char", not "gchar" please. Did that in the new patch, along with Nacho's suggestions. With blessings, thank you!
Review of attachment 308806 [details] [review]: See the other minor issue. ::: libsoup/soup-session.c @@ +107,3 @@ { +#ifdef G_OS_WIN32 + char* basedir = g_win32_get_package_installation_directory_of_module (soup_dll); minor thing here: char *basedir instead of char* basedir, same for the other variable
Created attachment 308844 [details] [review] soup_init(): Don't Hardcode Paths on Windows, take 2.1 Hi Nacho, (In reply to Ignacio Casal Quinteiro (nacho) from comment #7) > minor thing here: char *basedir instead of char* basedir, same for the other > variable Oops :| Got it. Thanks though, with blessings.
Comment on attachment 308844 [details] [review] soup_init(): Don't Hardcode Paths on Windows, take 2.1 looks good. (Well, if you want, you could unindent the two "case" lines and the "default" line by one level :-)
Hi Dan, Thanks for the review, the patch (with the indentation updated :) ) was pushed as f58c987. With blessings, thank you!