From a9d1f318b5d1974b882b0cebc9db291f5c0d1c62 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 25 Nov 2011 19:39:30 -0800 Subject: [PATCH 1/3] Update the Windows installer creation script This now works with a straight out of the box MinGW install on OpenSUSE. A simple shell script that shows how to invoke the cross build is included. Signed-off-by: Dirk Hohndel --- packaging/windows/mingw-make.sh | 12 +++++ packaging/windows/subsurface.nsi | 85 ++++++++++++++++++-------------- 2 files changed, 59 insertions(+), 38 deletions(-) create mode 100755 packaging/windows/mingw-make.sh diff --git a/packaging/windows/mingw-make.sh b/packaging/windows/mingw-make.sh new file mode 100755 index 000000000..79e7ad5ea --- /dev/null +++ b/packaging/windows/mingw-make.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# +# just a small shell script that is used to invoke make with the right +# parameters to cross compile a binary for Windows +# +# the paths work for the default mingw32 install on OpenSUSE - adjust as +# necessary + +make CC=i686-w64-mingw32-gcc \ + PKGCONFIG=i686-w64-mingw32-pkg-config \ + PKG_CONFIG_PATH=/usr/i686-w64-mingw32/sys-root/i686-w64-mingw32/lib/pkgconfig/ \ + XML2CONFIG=/usr/i686-w64-mingw32/sys-root/mingw/bin/xml2-config NAME=subsurface.exe diff --git a/packaging/windows/subsurface.nsi b/packaging/windows/subsurface.nsi index 17b734f17..b78c98120 100644 --- a/packaging/windows/subsurface.nsi +++ b/packaging/windows/subsurface.nsi @@ -1,18 +1,30 @@ - +# this installer creator needs to be run with +# makensis subsurface.nsi +# +# it assumes that packaging/windows/dll is a symlink to +# the directory in which the required Windows DLLs are installed +# (in my case that's /usr/i686-w64-mingw32/sys-root/mingw/bin) +# # define the name of the installer outfile "subsurface-installer.exe" Name subsurface -VIProductVersion "1.1.0.0" +# some data for the package to identify itself +VIProductVersion "1.1.9.0" VIAddVersionKey ProductName subsurface +VIAddVersionKey FileDescription "subsurface diving log program" +VIAddVersionKey LegalCopyright "GPL v.2" VIAddVersionKey ProductVersion "1.1" VIAddVersionKey FileVersion "1.1" -Icon ..\share\subsurface.ico - +# icon to use for the installer +Icon .\subsurface.ico +# the installer needs to be run with admin privileges RequestExecutionLevel admin +# pop up a little dialog that tells the user that we're about to +# install subsurface Function .onInit MessageBox MB_YESNO "This will install subsurface. Do you wish to continue?" IDYES gogogo Abort @@ -42,39 +54,36 @@ writeUninstaller "$INSTDIR\subsurface-uninstall.exe" createShortCut "$SMPROGRAMS\subsurface\uninstall-subsurface.lnk" "$INSTDIR\subsurface-uninstall.exe" # define what to install and place it in the output path -file subsurface.exe -file libatk-1.0-0.dll -file libcairo-2.dll -file libdivecomputer-0.dll -file libffi-5.dll -file libfontconfig-1.dll -file libfreetype-6.dll -file libgdk_pixbuf-2.0-0.dll -file libgdk-win32-2.0-0.dll -file libgio-2.0-0.dll -file libglib-2.0-0.dll -file libgmodule-2.0-0.dll -file libgobject-2.0-0.dll -file libgthread-2.0-0.dll -file libgtk-win32-2.0-0.dll -file libintl-8.dll -file libjasper-1.dll -file libjpeg-8.dll -file libpango-1.0-0.dll -file libpangocairo-1.0-0.dll -file libpangoft2-1.0-0.dll -file libpangowin32-1.0-0.dll -file libpixman-1-0.dll -file libpng15-15.dll -file libtiff-3.dll -file libxml2-2.dll -file pthreadGC2.dll -file zlib1.dll -file /oname=subsurface.ico ..\\share\\subsurface.ico -file /oname=subsurface.bmp ..\\share\\subsurface.bmp -file /oname=subsurface.svg ..\\share\\subsurface.svg - - +file /oname=subsurface.exe ../../subsurface.exe +file /oname=subsurface.ico subsurface.ico +file /oname=subsurface.svg ../../subsurface.svg +file /oname=libatk-1.0-0.dll dll/libatk-1.0-0.dll +file /oname=libcairo-2.dll dll/libcairo-2.dll +file /oname=libdivecomputer-0.dll dll\libdivecomputer-0.dll +file /oname=libffi-5.dll dll\libffi-5.dll +file /oname=libfontconfig-1.dll dll\libfontconfig-1.dll +file /oname=libfreetype-6.dll dll\libfreetype-6.dll +file /oname=libgdk_pixbuf-2.0-0.dll dll\libgdk_pixbuf-2.0-0.dll +file /oname=libgdk-win32-2.0-0.dll dll\libgdk-win32-2.0-0.dll +file /oname=libgio-2.0-0.dll dll\libgio-2.0-0.dll +file /oname=libglib-2.0-0.dll dll\libglib-2.0-0.dll +file /oname=libgmodule-2.0-0.dll dll\libgmodule-2.0-0.dll +file /oname=libgobject-2.0-0.dll dll\libgobject-2.0-0.dll +file /oname=libgthread-2.0-0.dll dll\libgthread-2.0-0.dll +file /oname=libgtk-win32-2.0-0.dll dll\libgtk-win32-2.0-0.dll +file /oname=libintl-8.dll dll\libintl-8.dll +file /oname=libjasper-1.dll dll\libjasper-1.dll +file /oname=libjpeg-8.dll dll\libjpeg-8.dll +file /oname=libpango-1.0-0.dll dll\libpango-1.0-0.dll +file /oname=libpangocairo-1.0-0.dll dll\libpangocairo-1.0-0.dll +file /oname=libpangoft2-1.0-0.dll dll\libpangoft2-1.0-0.dll +file /oname=libpangowin32-1.0-0.dll dll\libpangowin32-1.0-0.dll +file /oname=libpixman-1-0.dll dll\libpixman-1-0.dll +file /oname=libpng15-15.dll dll\libpng15-15.dll +file /oname=libtiff-3.dll dll\libtiff-3.dll +file /oname=libxml2-2.dll dll\libxml2-2.dll +file /oname=pthreadGC2.dll dll\pthreadGC2.dll +file /oname=zlib1.dll dll\zlib1.dll sectionEnd section "uninstall" @@ -86,7 +95,7 @@ section "uninstall" delete "$SMPROGRAMS\subsurface\subsurface.lnk" RMDir "$SMPROGRAMS\subsurface" - MessageBox MB_YESNO "Do you wish to store subsurface's settings?" IDYES end + MessageBox MB_YESNO "Do you wish to keep subsurface's registry settings?" IDYES end DeleteRegKey HKCU "SOFTWARE\subsurface" end: sectionEnd From d2654d4951a01efd36f4189aeb02a791f20fa94d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 25 Nov 2011 19:48:53 -0800 Subject: [PATCH 2/3] Fix the Windows preferences support Now that I can test Windows binaries again, the bugs were rather easy to spot. Because of the different flow of the opening, writing and closing of the registry key my first attempt got things wrong - we simply always create the key with all access rights; if it exists Windows will just open it for us. The second bug was a cut'n'paste error. Signed-off-by: Dirk Hohndel --- windows.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/windows.c b/windows.c index 91323ebe8..b8eafb6de 100644 --- a/windows.c +++ b/windows.c @@ -22,15 +22,11 @@ void subsurface_open_conf(void) { LONG success; - success = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), 0, - KEY_QUERY_VALUE, &hkey); - if (success != ERROR_SUCCESS) { - success = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), - 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, - NULL, &hkey, NULL); - if (success != ERROR_SUCCESS) - printf("CreateKey Software\\subsurface failed %ld\n", success); - } + success = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), + 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, + NULL, &hkey, NULL); + if (success != ERROR_SUCCESS) + printf("CreateKey Software\\subsurface failed %ld\n", success); } void subsurface_set_conf(char *name, pref_type_t type, const void *value) @@ -38,7 +34,7 @@ void subsurface_set_conf(char *name, pref_type_t type, const void *value) switch (type) { case PREF_BOOL: /* we simply store the value as DWORD */ - RegSetValueEx(hkey, TEXT(name), 0, REG_DWORD, value, 4); + RegSetValueEx(hkey, TEXT(name), 0, REG_DWORD, &value, 4); break; case PREF_STRING: RegSetValueEx(hkey, TEXT(name), 0, REG_SZ, value, strlen(value)); From 192713680eb02afe6453a0a404e0eabb59758791 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 25 Nov 2011 20:09:01 -0800 Subject: [PATCH 3/3] Add more typecasts for Windows` This is based on an older patch by Lubomir I. Ivanov which no longer applies due to the refactoring of the registry setting code. It takes care of all of the casts between actual C types and the Windows specific types that the Windows API functions expect. It also adds some comments to the overloading of "value" in our subsurface_set_conf function. Signed-off-by: Dirk Hohndel --- windows.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/windows.c b/windows.c index b8eafb6de..e4c811984 100644 --- a/windows.c +++ b/windows.c @@ -11,8 +11,8 @@ static int get_from_registry(HKEY hkey, const char *key) DWORD len = 4; LONG success; - success = RegQueryValueEx(hkey, TEXT(key), NULL, NULL, - (LPBYTE) &value, &len ); + success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(key), NULL, NULL, + (LPBYTE) &value, (LPDWORD)&len ); if (success != ERROR_SUCCESS) return FALSE; /* that's what happens the first time we start */ return value; @@ -22,7 +22,7 @@ void subsurface_open_conf(void) { LONG success; - success = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), + success = RegCreateKeyEx(HKEY_CURRENT_USER, (LPCTSTR)TEXT("Software\\subsurface"), 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL); if (success != ERROR_SUCCESS) @@ -31,13 +31,19 @@ void subsurface_open_conf(void) void subsurface_set_conf(char *name, pref_type_t type, const void *value) { + /* since we are using the pointer 'value' as both an actual + * pointer to the string setting and as a way to pass the + * numbers 0 and 1 to this function for booleans, one of the + * calls to RegSetValueEx needs to pass &value (when we want + * to pass the boolean value), the other one passes value (the + * address of the string. */ switch (type) { case PREF_BOOL: /* we simply store the value as DWORD */ - RegSetValueEx(hkey, TEXT(name), 0, REG_DWORD, &value, 4); + RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_DWORD, (const BYTE *)&value, 4); break; case PREF_STRING: - RegSetValueEx(hkey, TEXT(name), 0, REG_SZ, value, strlen(value)); + RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_SZ, (const BYTE *)value, strlen(value)); } } @@ -53,7 +59,7 @@ const void *subsurface_get_conf(char *name, pref_type_t type) case PREF_STRING: string = malloc(80); len = 80; - success = RegQueryValueEx(hkey, TEXT(name), NULL, NULL, + success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(name), NULL, NULL, (LPBYTE) string, (LPDWORD)&len ); if (success != ERROR_SUCCESS) { /* that's what happens the first time we start - just return NULL */