[tbb-commits] [tor-browser/tor-browser-24.7.0esr-4.x-2] MinGW-w64 fixes for updater. See Moz bug 1022847.
mikeperry at torproject.org
mikeperry at torproject.org
Thu Aug 28 06:45:30 UTC 2014
commit 616b4446a586de5d5ba487ed813f78dc54ca1af7
Author: Kathy Brade <brade at pearlcrescent.com>
Date: Wed Aug 13 21:38:11 2014 -0400
MinGW-w64 fixes for updater. See Moz bug 1022847.
---
toolkit/mozapps/update/common/updatedefines.h | 1 +
toolkit/mozapps/update/common/updatehelper.cpp | 2 --
toolkit/mozapps/update/test/Makefile.in | 6 ++++++
toolkit/mozapps/update/test/TestAUSHelper.cpp | 2 --
toolkit/mozapps/update/updater/Makefile.in | 7 +++++++
toolkit/mozapps/update/updater/updater.cpp | 17 +++++++++++++++--
6 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/toolkit/mozapps/update/common/updatedefines.h b/toolkit/mozapps/update/common/updatedefines.h
index 6a35129..09a2231 100644
--- a/toolkit/mozapps/update/common/updatedefines.h
+++ b/toolkit/mozapps/update/common/updatedefines.h
@@ -39,6 +39,7 @@
# define putenv _putenv
# define stat _stat
+# define fstat _fstat // This Tor Project change may not be needed with ESR 31.
# define DELETE_DIR L"tobedeleted"
# define CALLBACK_BACKUP_EXT L".moz-callback"
diff --git a/toolkit/mozapps/update/common/updatehelper.cpp b/toolkit/mozapps/update/common/updatehelper.cpp
index ab64c2d..b14b0f6 100644
--- a/toolkit/mozapps/update/common/updatehelper.cpp
+++ b/toolkit/mozapps/update/common/updatehelper.cpp
@@ -10,7 +10,6 @@
#define _WIN32_WINNT 0x602
#include <objbase.h>
#include <shobjidl.h>
-#pragma comment(lib, "ole32.lib")
#endif
#include <windows.h>
@@ -27,7 +26,6 @@
// Needed for PathAppendW
#include <shlwapi.h>
-#pragma comment(lib, "shlwapi.lib")
WCHAR* MakeCommandLine(int argc, WCHAR **argv);
BOOL PathAppendSafe(LPWSTR base, LPCWSTR extra);
diff --git a/toolkit/mozapps/update/test/Makefile.in b/toolkit/mozapps/update/test/Makefile.in
index b01aac7..a12d2fe 100644
--- a/toolkit/mozapps/update/test/Makefile.in
+++ b/toolkit/mozapps/update/test/Makefile.in
@@ -56,6 +56,12 @@ LIBS += \
ifeq ($(OS_ARCH),WINNT)
USE_STATIC_LIBS = 1
DEFINES += -DUNICODE -D_UNICODE
+OS_LIBS += $(call EXPAND_LIBNAME,wintrust shlwapi)
+ifdef GNU_CC
+# MinGW requires -municode to define the wWinMain() entry point.
+# With ESR 31, this Tor Project change will need to be moved to moz.build.
+WIN32_EXE_LDFLAGS += -municode
+endif
endif
endif # Not Android
diff --git a/toolkit/mozapps/update/test/TestAUSHelper.cpp b/toolkit/mozapps/update/test/TestAUSHelper.cpp
index 854293b..542c0ed 100644
--- a/toolkit/mozapps/update/test/TestAUSHelper.cpp
+++ b/toolkit/mozapps/update/test/TestAUSHelper.cpp
@@ -3,8 +3,6 @@
*/
#ifdef XP_WIN
-#pragma comment(lib, "wintrust.lib")
-#pragma comment(lib, "crypt32.lib")
# include <windows.h>
# include <wintrust.h>
# include <tlhelp32.h>
diff --git a/toolkit/mozapps/update/updater/Makefile.in b/toolkit/mozapps/update/updater/Makefile.in
index 4c0edc6..ba28b0b 100644
--- a/toolkit/mozapps/update/updater/Makefile.in
+++ b/toolkit/mozapps/update/updater/Makefile.in
@@ -75,6 +75,13 @@ WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
WIN32_EXE_LDFLAGS += -DELAYLOAD:wsock32.dll -DELAYLOAD:crypt32.dll -DELAYLOAD:userenv.dll
endif
+ifeq ($(OS_ARCH),WINNT)
+ifdef GNU_CC
+# With ESR 31, this Tor Project change will need to be moved to moz.build.
+WIN32_EXE_LDFLAGS += -municode
+endif
+endif
+
ifdef MOZ_WIDGET_GTK
libs:: updater.png
$(NSINSTALL) -D $(DIST)/bin/icons
diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp
index 927f77e..4012f00 100644
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -30,6 +30,12 @@
* -----------
* method = "remove" | "rmdir"
*/
+
+// To avoid conflicts within MinGW headers, sys/stat.h must be included
+// before ../common/updatedefines.h which is included by progressui.h
+// This Tor Project change may not be needed with ESR 31.
+#include <sys/stat.h>
+
#include "bspatch.h"
#include "progressui.h"
#include "archivereader.h"
@@ -41,9 +47,12 @@
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
+#ifdef XP_WIN
+// This Tor Project change may not be needed with ESR 31.
+#include <algorithm> // for std::max
+#endif
#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
#include <errno.h>
@@ -2301,6 +2310,10 @@ UpdateThreadFunc(void *param)
QuitProgressUI();
}
+#ifdef __MINGW32__
+// This Tor Project change may not be needed with gcc 4.9 or newer.
+extern "C"
+#endif
int NS_main(int argc, NS_tchar **argv)
{
#if defined(MOZ_WIDGET_GONK)
@@ -2947,7 +2960,7 @@ int NS_main(int argc, NS_tchar **argv)
if (!GetInstallationDir(installDir))
return 1;
size_t callbackPrefixLength = PathCommonPrefixW(argv[callbackIndex], installDir, NULL);
- 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,
More information about the tbb-commits
mailing list