Bug 1022847 - toolkit/mozapps/update fails to compile with MinGW r=netzen
authorJacek Caban <jacek@codeweavers.com>
Wed, 25 Jun 2014 11:30:05 +0200
changeset 211561 7bbedf6937aa458602e804f8b3709a99599b11ce
parent 211560 b30d5443b70e0db90d2502a0c24c69049ae81ddb
child 211562 990efda774885124e47aec65ef52f3e8cb63a3e4
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnetzen
bugs1022847
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1022847 - toolkit/mozapps/update fails to compile with MinGW r=netzen
toolkit/mozapps/update/common/updatehelper.cpp
toolkit/mozapps/update/tests/Makefile.in
toolkit/mozapps/update/tests/TestAUSHelper.cpp
toolkit/mozapps/update/tests/moz.build
toolkit/mozapps/update/updater/moz.build
toolkit/mozapps/update/updater/updater.cpp
--- a/toolkit/mozapps/update/common/updatehelper.cpp
+++ b/toolkit/mozapps/update/common/updatehelper.cpp
@@ -5,17 +5,16 @@
 #ifdef MOZ_METRO
 // Needed for COM calls to launch Metro applications
 #undef WINVER
 #undef _WIN32_WINNT
 #define WINVER 0x602
 #define _WIN32_WINNT 0x602
 #include <objbase.h>
 #include <shobjidl.h>
-#pragma comment(lib, "ole32.lib")
 #endif
 
 #include <windows.h>
 
 // Needed for CreateToolhelp32Snapshot
 #include <tlhelp32.h>
 #ifndef ONLY_SERVICE_LAUNCHING
 
@@ -23,17 +22,16 @@
 #include "shlobj.h"
 #include "updatehelper.h"
 #include "uachelper.h"
 #include "pathhash.h"
 #include "mozilla/Scoped.h"
 
 // Needed for PathAppendW
 #include <shlwapi.h>
-#pragma comment(lib, "shlwapi.lib")
 
 WCHAR* MakeCommandLine(int argc, WCHAR **argv);
 BOOL PathAppendSafe(LPWSTR base, LPCWSTR extra);
 
 /**
  * Obtains the path of a file in the same directory as the specified file.
  *
  * @param  destinationBuffer A buffer of size MAX_PATH + 1 to store the result.
--- a/toolkit/mozapps/update/tests/Makefile.in
+++ b/toolkit/mozapps/update/tests/Makefile.in
@@ -64,16 +64,17 @@ INI_TEST_FILES = \
   TestAUSReadStrings3.ini \
   $(NULL)
 
 MOZ_GLUE_LDFLAGS =
 MOZ_WINCONSOLE = 1
 
 ifeq ($(OS_ARCH),WINNT)
 LIBS += $(call EXPAND_LIBNAME_PATH,updatecommon-standalone,../common-standalone)
+OS_LIBS += $(call EXPAND_LIBNAME,wintrust shlwapi)
 else
 LIBS += $(call EXPAND_LIBNAME_PATH,updatecommon,../common)
 endif
 
 endif # Not Android
 
 include $(topsrcdir)/config/rules.mk
 
--- a/toolkit/mozapps/update/tests/TestAUSHelper.cpp
+++ b/toolkit/mozapps/update/tests/TestAUSHelper.cpp
@@ -1,15 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 #ifdef XP_WIN
-#pragma comment(lib, "wintrust.lib")
-#pragma comment(lib, "crypt32.lib")
 # include <windows.h>
 # include <wintrust.h>
 # include <tlhelp32.h>
 # include <softpub.h>
 # include <direct.h>
 # include <io.h>
   typedef WCHAR NS_tchar;
 # define NS_main wmain
--- a/toolkit/mozapps/update/tests/moz.build
+++ b/toolkit/mozapps/update/tests/moz.build
@@ -38,8 +38,10 @@ if CONFIG['MOZ_MAINTENANCE_SERVICE']:
 
 # For debugging purposes only
 #DEFINES['DISABLE_UPDATER_AUTHENTICODE_CHECK'] = True
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     DEFINES['UNICODE'] = True
     DEFINES['_UNICODE'] = True
     USE_STATIC_LIBS = True
+    if CONFIG['GNU_CC']:
+        WIN32_EXE_LDFLAGS += ['-municode']
--- a/toolkit/mozapps/update/updater/moz.build
+++ b/toolkit/mozapps/update/updater/moz.build
@@ -18,16 +18,17 @@ if CONFIG['OS_ARCH'] == 'WINNT':
     SOURCES += [
         'loaddlls.cpp',
         'progressui_win.cpp',
         'win_dirent.cpp',
     ]
     RCINCLUDE = 'updater.rc'
     DEFINES['UNICODE'] = True
     DEFINES['_UNICODE'] = True
+    DEFINES['NOMINMAX'] = True
     USE_STATIC_LIBS = True
 
     # Pick up nsWindowsRestart.cpp
     LOCAL_INCLUDES += [
         '/toolkit/xre',
     ]
 
 if CONFIG['MOZ_ENABLE_GTK']:
@@ -52,29 +53,32 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'go
     DISABLE_STL_WRAPPING = True
 
 if have_progressui == 0:
     SOURCES += [
         'progressui_null.cpp',
     ]
 
 DEFINES['NS_NO_XPCOM'] = True
+DISABLE_STL_WRAPPING = True
 for var in ('MAR_CHANNEL_ID', 'MOZ_APP_VERSION'):
     DEFINES[var] = '"%s"' % CONFIG[var]
 
 LOCAL_INCLUDES += [
     '../common',
     '/xpcom/glue',
 ]
 
 DELAYLOAD_DLLS += [
     'crypt32.dll',
     'userenv.dll',
     'wsock32.dll',
 ]
 
 if CONFIG['_MSC_VER']:
     WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
+elif CONFIG['OS_ARCH'] == 'WINNT':
+    WIN32_EXE_LDFLAGS += ['-municode']
 
 if CONFIG['MOZ_UPDATE_CHANNEL'] in ('beta', 'release', 'esr'):
     DEFINES['MAR_SIGNING_RELEASE_BETA'] = '1'
 elif CONFIG['MOZ_UPDATE_CHANNEL'] in ('nightly', 'aurora', 'nightly-elm', 'nightly-profiling', 'nightly-oak', 'nightly-ux'):
     DEFINES['MAR_SIGNING_AURORA_NIGHTLY'] = '1'
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -45,16 +45,17 @@
 #include <stdlib.h>
 #include <stdarg.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <limits.h>
 #include <errno.h>
+#include <algorithm>
 
 #include "updatelogging.h"
 
 #include "mozilla/Compiler.h"
 #include "mozilla/Types.h"
 
 // Amount of the progress bar to use in each of the 3 update stages,
 // should total 100.0.
@@ -2663,17 +2664,17 @@ int NS_main(int argc, NS_tchar **argv)
                                        FILE_FLAG_DELETE_ON_CLOSE,
                                        nullptr);
 
       if (elevatedFileHandle == INVALID_HANDLE_VALUE) {
         LOG(("Unable to create elevated lock file! Exiting"));
         return 1;
       }
 
-      char16_t *cmdLine = MakeCommandLine(argc - 1, argv + 1);
+      wchar_t *cmdLine = MakeCommandLine(argc - 1, argv + 1);
       if (!cmdLine) {
         CloseHandle(elevatedFileHandle);
         return 1;
       }
 
       NS_tchar installDir[MAXPATHLEN];
       if (!GetInstallationDir(installDir)) {
         return 1;
@@ -2980,17 +2981,17 @@ int NS_main(int argc, NS_tchar **argv)
       bufferLeft--;
       *p = NS_T('\0');
       NS_tchar installDir[MAXPATHLEN];
       if (!GetInstallationDir(installDir))
         return 1;
       size_t callbackPrefixLength = PathCommonPrefixW(argv[callbackIndex],
                                                       installDir,
                                                       nullptr);
-      NS_tstrncpy(p, argv[callbackIndex] + max(callbackPrefixLength, commonPrefixLength), bufferLeft);
+      NS_tstrncpy(p, argv[callbackIndex] + std::max(callbackPrefixLength, commonPrefixLength), bufferLeft);
       targetPath = buffer;
     }
     if (!GetLongPathNameW(targetPath, callbackLongPath,
                           sizeof(callbackLongPath)/sizeof(callbackLongPath[0]))) {
       LOG(("NS_main: unable to find callback file: " LOG_S, targetPath));
       LogFinish();
       WriteStatusFile(WRITE_ERROR);
       EXIT_WHEN_ELEVATED(elevatedLockFilePath, updateLockFileHandle, 1);