# HG changeset patch
# User Philipp Kewisch <mozilla@kewis.ch>
# Date 1521755029 -3600
# Node ID e58b200fabf350b10482e6b6d22b91056279118a
# Parent  d424678da2d1a82e71864b36ac9ffa41da64b5b5
Bug 1447907 - Adapt link logic for mapi component. rs=jorgk,bustage-fix

In bug 1429875 there were some changes to the link logic that made CSRCS not work well. This patch
moves CSRCS to moz.build and adds GENERATED_FILES to ensure that the build system picks up the right
files.

MozReview-Commit-ID: 9l9WL8SlRfp

diff --git a/mailnews/mapi/mapihook/build/Makefile.in b/mailnews/mapi/mapihook/build/Makefile.in
--- a/mailnews/mapi/mapihook/build/Makefile.in
+++ b/mailnews/mapi/mapihook/build/Makefile.in
@@ -1,36 +1,30 @@
-#
 # 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/.
 
-MIDL_GENERATED_FILES = msgMapi.h msgMapi_p.c msgMapi_i.c dlldata.c
-
-INSTALL_TARGETS += msgmapi
-msgmapi_FILES := msgMapi.h
-msgmapi_DEST = $(DIST)/include
-msgmapi_TARGET := export
-
-SRCDIR_CSRCS	= $(addprefix $(srcdir)/,$(CSRCS))
-
-GARBAGE	+= $(MIDL_GENERATED_FILES) done_gen $(CSRCS) $(SRCDIR_CSRCS)
+GARBAGE	+= $(MIDL_GENERATED_FILES) done_gen ;
 
-EMBED_MANIFEST_AT = 2
+MIDL_GENERATED_FILES = \
+	dlldata.c \
+	msgMapi.h \
+	msgMapi_p.c \
+	msgMapi_i.c \
+	$(NULL)
 
-CSRCS += \
-  dlldata.c \
-  msgMapi_i.c \
-  msgMapi_p.c \
-  $(NULL)
-
-include $(topsrcdir)/config/rules.mk
-
-$(MIDL_GENERATED_FILES): done_gen
+$(MIDL_GENERATED_FILES): done_gen ;
 
 done_gen: msgMapi.idl
-	$(RM) $(SRCDIR_CSRCS)
-	$(MIDL) $(MIDL_FLAGS) $(UNICODE_FLAGS) $(srcdir)/msgMapi.idl
+	$(MIDL) $(MIDL_FLAGS) -I $(srcdir) -Oicf $(srcdir)/msgMapi.idl
 	touch $@
 
 export:: done_gen
 
+midl_exports := \
+	msgMapi.h \
+	msgMapi_i.c \
+	$(NULL)
 
+INSTALL_TARGETS += midl_exports
+midl_exports_FILES := msgMapi.h
+midl_exports_DEST = $(DIST)/include
+midl_exports_TARGET := export
diff --git a/mailnews/mapi/mapihook/build/moz.build b/mailnews/mapi/mapihook/build/moz.build
--- a/mailnews/mapi/mapihook/build/moz.build
+++ b/mailnews/mapi/mapihook/build/moz.build
@@ -4,16 +4,33 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SharedLibrary('MapiProxy')
 
 OS_LIBS += [
     'rpcrt4',
 ]
 
+SOURCES += [
+    '!dlldata.c',
+    '!msgMapi_i.c',
+    '!msgMapi_p.c'
+]
+
+GENERATED_FILES += [
+    'dlldata.c',
+    'msgMapi.h',
+    'msgMapi_i.c',
+    'msgMapi_p.c'
+]
+
 for var in ('REGISTER_PROXY_DLL', 'UNICODE', '_UNICODE'):
     DEFINES[var] = True
 
-# This produces a compile warning mozilla-config.h(145): warning C4005: '_WIN32_WINNT': macro redefinition
-#DEFINES['_WIN32_WINNT'] = '0x400'
-
 DEFFILE = SRCDIR + '/MapiProxy.def'
 
+# The Windows MIDL code generator creates things like:
+#
+#   #endif !_MIDL_USE_GUIDDEF_
+#
+# which clang-cl complains about.  MSVC doesn't, so turn this warning off.
+if CONFIG['CC_TYPE'] == 'clang-cl':
+    CFLAGS += ['-Wno-extra-tokens']
diff --git a/mailnews/mapi/mapihook/src/Makefile.in b/mailnews/mapi/mapihook/src/Makefile.in
deleted file mode 100644
--- a/mailnews/mapi/mapihook/src/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/.
-
-CSRCS += ../build/msgMapi_i.c
diff --git a/mailnews/mapi/mapihook/src/moz.build b/mailnews/mapi/mapihook/src/moz.build
--- a/mailnews/mapi/mapihook/src/moz.build
+++ b/mailnews/mapi/mapihook/src/moz.build
@@ -1,14 +1,15 @@
 # vim: set filetype=python:
 # 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/.
 
 SOURCES += [
+    '!../build/msgMapi_i.c',
     'msgMapiFactory.cpp',
     'msgMapiHook.cpp',
     'msgMapiImp.cpp',
     'msgMapiMain.cpp',
     'msgMapiSupport.cpp',
     'Registry.cpp',
 ]
 

