bug 1223530 - Move MOZ_WINCONSOLE to configure. r?gps draft
authorTed Mielczarek <ted@mielczarek.org>
Wed, 11 Nov 2015 06:24:39 -0500
changeset 308990 89ce9655e1fac472b698257a0491fc6a7320ca0f
parent 308257 887c67fc1fc8129ac62fcddca6e6bb7664d3162d
child 511235 4f27fc7e797a31078812893b347304fdbcb5329c
push id7549
push usertmielczarek@mozilla.com
push dateMon, 16 Nov 2015 13:39:06 +0000
reviewersgps
bugs1223530
milestone45.0a1
bug 1223530 - Move MOZ_WINCONSOLE to configure. r?gps This patch moves the logic for selecting MOZ_WINCONSOLE out of individual Makefile.in files and into configure. It also changes config.mk to only pass -SUBSYSTEM:CONSOLE if MOZ_WINCONSOLE=1. The MSDN docs state that in the absence of -SUBSYSTEM, the linker will select the proper subsystem based on whether the program contains [w]main or [w]WinMain, so let it do that. One program (windbgdlg) needed a tweak to add a wmain for when MOZ_WINCONSOLE is defined. This patch leaves one instance in security/sandbox/win/wow_helper/Makefile.in, that Makefile has its own separate bug.
browser/app/Makefile.in
config/config.mk
configure.in
ipc/app/Makefile.in
toolkit/components/maintenanceservice/Makefile.in
toolkit/crashreporter/client/Makefile.in
toolkit/mozapps/update/tests/Makefile.in
toolkit/mozapps/update/updater/Makefile.in
toolkit/mozapps/update/updater/updater-xpcshell/Makefile.in
toolkit/xre/test/win/Makefile.in
webapprt/win/Makefile.in
xpcom/windbgdlg/Makefile.in
xpcom/windbgdlg/windbgdlg.cpp
xulrunner/app/Makefile.in
xulrunner/stub/Makefile.in
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -10,26 +10,16 @@ AB_CD = en-US
 DEFINES += \
   -DFIREFOX_ICO='"$(DIST)/branding/firefox.ico"' \
   -DDOCUMENT_ICO='"$(DIST)/branding/document.ico"' \
   -DNEWWINDOW_ICO='"$(DIST)/branding/newwindow.ico"' \
   -DNEWTAB_ICO='"$(DIST)/branding/newtab.ico"' \
   -DPBMODE_ICO='"$(DIST)/branding/pbmode.ico"' \
   $(NULL)
 
-# Build a binary bootstrapping with XRE_main
-
-ifndef MOZ_WINCONSOLE
-ifneq (,$(MOZ_DEBUG)$(MOZ_ASAN))
-MOZ_WINCONSOLE = 1
-else
-MOZ_WINCONSOLE = 0
-endif
-endif
-
 # This switches $(INSTALL) to copy mode, like $(SYSINSTALL), so things that
 # shouldn't get 755 perms need $(IFLAGS1) for either way of calling nsinstall.
 NSDISTMODE = copy
 
 include $(topsrcdir)/config/config.mk
 
 ifeq ($(OS_ARCH),WINNT)
 # Rebuild firefox.exe if the manifest changes - it's included by splash.rc.
--- a/config/config.mk
+++ b/config/config.mk
@@ -446,24 +446,18 @@ endif # MACOSX_DEPLOYMENT_TARGET
 ifdef MOZ_USING_CCACHE
 ifdef CLANG_CXX
 export CCACHE_CPP2=1
 endif
 endif
 
 # Set link flags according to whether we want a console.
 ifeq ($(OS_ARCH),WINNT)
-ifdef MOZ_WINCONSOLE
 ifeq ($(MOZ_WINCONSOLE),1)
-WIN32_EXE_LDFLAGS	+= $(WIN32_CONSOLE_EXE_LDFLAGS)
-else # MOZ_WINCONSOLE
-WIN32_EXE_LDFLAGS	+= $(WIN32_GUI_EXE_LDFLAGS)
-endif
-else
-# For setting subsystem version
+# If not specified, let the linker choose the right subsystem.
 WIN32_EXE_LDFLAGS	+= $(WIN32_CONSOLE_EXE_LDFLAGS)
 endif
 endif # WINNT
 
 ifdef _MSC_VER
 ifeq ($(CPU_ARCH),x86_64)
 # set stack to 2MB on x64 build.  See bug 582910
 WIN32_EXE_LDFLAGS	+= -STACK:2097152
--- a/configure.in
+++ b/configure.in
@@ -407,20 +407,16 @@ else
     if test -z "$HOST_AR"; then
         HOST_AR="$AR"
     fi
     if test -z "$HOST_AR_FLAGS"; then
         HOST_AR_FLAGS="$AR_FLAGS"
     fi
 fi
 
-if test -n "$MOZ_WINCONSOLE"; then
-    AC_DEFINE(MOZ_WINCONSOLE)
-fi
-
 MOZ_TOOL_VARIABLES
 
 MOZ_CHECK_COMPILER_WRAPPER
 
 MOZ_RUST_SUPPORT
 
 dnl ========================================================
 dnl Check for MacOS deployment target version
@@ -2546,16 +2542,25 @@ esac
 if test -z "$COMPILE_ENVIRONMENT"; then
     SKIP_COMPILER_CHECKS=1
     SKIP_LIBRARY_CHECKS=1
     PKG_SKIP_STRIP=1
 else
     MOZ_COMPILER_OPTS
 fi # COMPILE_ENVIRONMENT
 
+if test -n "$MOZ_DEBUG" -o -n "$MOZ_ASAN"; then
+  MOZ_WINCONSOLE=1
+fi
+
+if test -n "$MOZ_WINCONSOLE"; then
+    AC_DEFINE(MOZ_WINCONSOLE)
+fi
+AC_SUBST(MOZ_WINCONSOLE)
+
 if test -z "$SKIP_COMPILER_CHECKS"; then
 dnl Checks for typedefs, structures, and compiler characteristics.
 dnl ========================================================
 AC_HEADER_STDC
 AC_C_CONST
 AC_TYPE_MODE_T
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
--- a/ipc/app/Makefile.in
+++ b/ipc/app/Makefile.in
@@ -1,20 +1,12 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-ifndef MOZ_WINCONSOLE
-ifdef MOZ_DEBUG
-MOZ_WINCONSOLE = 1
-else
-MOZ_WINCONSOLE = 0
-endif
-endif
-
 # This switches $(INSTALL) to copy mode, like $(SYSINSTALL), so things that
 # shouldn't get 755 perms need $(IFLAGS1) for either way of calling nsinstall.
 NSDISTMODE = copy
 
 include $(topsrcdir)/config/config.mk
 
 include $(topsrcdir)/config/rules.mk
 
--- a/toolkit/components/maintenanceservice/Makefile.in
+++ b/toolkit/components/maintenanceservice/Makefile.in
@@ -1,15 +1,7 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DIST_PROGRAM = maintenanceservice$(BIN_SUFFIX)
 
-ifndef MOZ_WINCONSOLE
-ifdef MOZ_DEBUG
-MOZ_WINCONSOLE = 1
-else
-MOZ_WINCONSOLE = 0
-endif
-endif
-
 include $(topsrcdir)/config/rules.mk
--- a/toolkit/crashreporter/client/Makefile.in
+++ b/toolkit/crashreporter/client/Makefile.in
@@ -2,20 +2,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 ifneq ($(OS_TARGET),Android)
 DIST_PROGRAM = crashreporter$(BIN_SUFFIX)
 endif
 
-ifeq ($(OS_ARCH),WINNT)
-MOZ_WINCONSOLE = 0
-endif
-
 ifdef MOZ_WIDGET_GTK
 OS_CXXFLAGS += $(TK_CFLAGS) $(MOZ_GTHREAD_CFLAGS)
 endif
 
 ifeq ($(OS_ARCH),SunOS)
 OS_CXXFLAGS += $(MOZ_GTK2_CFLAGS) $(MOZ_GTHREAD_CFLAGS)
 endif
 
--- a/toolkit/mozapps/update/tests/Makefile.in
+++ b/toolkit/mozapps/update/tests/Makefile.in
@@ -38,18 +38,16 @@ chrome-data_DEST   := $(CHROMETESTROOT)/
 chrome-data_TARGET := misc
 
 INI_TEST_FILES = \
   TestAUSReadStrings1.ini \
   TestAUSReadStrings2.ini \
   TestAUSReadStrings3.ini \
   $(NULL)
 
-MOZ_WINCONSOLE = 1
-
 include $(topsrcdir)/config/rules.mk
 
 # TestAUSReadStrings runs during check in the following directory with a Unicode
 # char in order to test bug 473417 on Windows.
 ifeq ($(OS_ARCH),WINNT)
 bug473417dir = test_bug473417-
 else
 bug473417dir = test_bug473417
--- a/toolkit/mozapps/update/updater/Makefile.in
+++ b/toolkit/mozapps/update/updater/Makefile.in
@@ -1,23 +1,15 @@
 # vim:set ts=8 sw=8 sts=8 noet:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # For changes here, also consider ./updater-xpcshell/Makefile.in
 
-ifndef MOZ_WINCONSOLE
-ifdef MOZ_DEBUG
-MOZ_WINCONSOLE = 1
-else
-MOZ_WINCONSOLE = 0
-endif
-endif
-
 include $(topsrcdir)/config/rules.mk
 
 ifneq (,$(filter beta release esr,$(MOZ_UPDATE_CHANNEL)))
 	PRIMARY_CERT = release_primary.der
 	SECONDARY_CERT = release_secondary.der
 else ifneq (,$(filter nightly aurora nightly-elm nightly-profiling nightly-oak nightly-ux,$(MOZ_UPDATE_CHANNEL)))
 	PRIMARY_CERT = nightly_aurora_level3_primary.der
 	SECONDARY_CERT = nightly_aurora_level3_secondary.der
--- a/toolkit/mozapps/update/updater/updater-xpcshell/Makefile.in
+++ b/toolkit/mozapps/update/updater/updater-xpcshell/Makefile.in
@@ -5,24 +5,16 @@
 
 # For changes here, also consider ../Makefile.in
 
 XPCSHELLTESTROOT = $(abspath $(DEPTH))/_tests/xpcshell/toolkit/mozapps/update/tests
 MOCHITESTROOT = $(abspath $(DEPTH))/_tests/testing/mochitest/chrome/toolkit/mozapps/update/tests
 
 include $(topsrcdir)/config/rules.mk
 
-ifndef MOZ_WINCONSOLE
-ifdef MOZ_DEBUG
-MOZ_WINCONSOLE = 1
-else
-MOZ_WINCONSOLE = 0
-endif
-endif
-
 libs::
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 	# Copy for xpcshell tests
 	$(NSINSTALL) -D $(XPCSHELLTESTROOT)/data/updater-xpcshell.app
 	rsync -a -C --exclude '*.in' $(srcdir)/../macbuild/Contents $(XPCSHELLTESTROOT)/data/updater-xpcshell.app
 	sed -e 's/%APP_NAME%/$(MOZ_APP_DISPLAYNAME)/' $(srcdir)/../macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | \
 	  iconv -f UTF-8 -t UTF-16 > $(XPCSHELLTESTROOT)/data/updater-xpcshell.app/Contents/Resources/English.lproj/InfoPlist.strings
 	$(NSINSTALL) -D $(XPCSHELLTESTROOT)/data/updater-xpcshell.app/Contents/MacOS/updater-xpcshell
--- a/toolkit/xre/test/win/Makefile.in
+++ b/toolkit/xre/test/win/Makefile.in
@@ -1,14 +1,12 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-MOZ_WINCONSOLE = 1
-
 include $(topsrcdir)/config/rules.mk
 
 libs:: TestXREMakeCommandLineWin.ini
 	$(INSTALL) $^ $(FINAL_TARGET)/
 
 check::
 	@echo 'Running TestXREMakeCommandLineWin tests'
 	@$(RUN_TEST_PROGRAM) $(FINAL_TARGET)/TestXREMakeCommandLineWin.exe
--- a/webapprt/win/Makefile.in
+++ b/webapprt/win/Makefile.in
@@ -1,20 +1,12 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
-ifndef MOZ_WINCONSOLE
-ifdef MOZ_DEBUG
-MOZ_WINCONSOLE = 1
-else
-MOZ_WINCONSOLE = 0
-endif
-endif
-
 # Installer stuff
 include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk
 
 CONFIG_DIR = instgen
 SFX_MODULE = $(topsrcdir)/other-licenses/7zstub/firefox/7zSD.sfx
 
 # Uninstaller
 ifdef LOCALE_MERGEDIR
deleted file mode 100644
--- a/xpcom/windbgdlg/Makefile.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-MOZ_WINCONSOLE = 0
--- a/xpcom/windbgdlg/windbgdlg.cpp
+++ b/xpcom/windbgdlg/windbgdlg.cpp
@@ -114,8 +114,13 @@ wWinMain(HINSTANCE  hInstance, HINSTANCE
               L"Click Retry to Debug the Application.\n"
               L"Click Ignore to continue running the Application.",
               lpszCmdLine);
     msg[size - 1] = L'\0';
     return MessageBoxW(nullptr, msg, L"NSGlue_Assertion",
                        MB_ICONSTOP | MB_SYSTEMMODAL |
                        MB_ABORTRETRYIGNORE | MB_DEFBUTTON3);
 }
+
+int wmain(int argc, wchar_t** argv) {
+    return wWinMain(nullptr, nullptr,
+                    GetCommandLineW(), 0);
+}
--- a/xulrunner/app/Makefile.in
+++ b/xulrunner/app/Makefile.in
@@ -4,24 +4,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 GARBAGE += $(addprefix $(DIST)/bin/defaults/pref/,xulrunner.js)
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 TK_LIBS := -framework Cocoa $(TK_LIBS)
 endif
 
-ifndef MOZ_WINCONSOLE
-ifdef MOZ_DEBUG
-MOZ_WINCONSOLE = 1
-else
-MOZ_WINCONSOLE = 0
-endif
-endif
-
 # This switches $(INSTALL) to copy mode, like $(SYSINSTALL), so things that
 # shouldn't get 755 perms need $(IFLAGS1) for either way of calling nsinstall.
 NSDISTMODE = copy
 
 include $(topsrcdir)/config/config.mk
 
 include $(topsrcdir)/config/rules.mk
 
deleted file mode 100644
--- a/xulrunner/stub/Makefile.in
+++ /dev/null
@@ -1,11 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-ifndef MOZ_WINCONSOLE
-ifdef MOZ_DEBUG
-MOZ_WINCONSOLE = 1
-else
-MOZ_WINCONSOLE = 0
-endif
-endif