Bug 1537641 - Make MIDL use clang-cl as a preprocessor. r=dmajor

Using clang-cl as a preprocessor fails with:
```
In file included from z:\build\build\src\accessible\ipc\win\handler\HandlerData.idl:8:
z:\build\build\src\accessible\ipc\win\handler/AccessibleHandler.h(27,8): error: pasting formed 'Accessible2_3.', an invalid preprocessing token [-Winvalid-token-paste]
import NEWEST_IA2_IDL;
       ^
z:\build\build\src\accessible\ipc\win\handler/AccessibleHandler.h(15,24): note: expanded from macro 'NEWEST_IA2_IDL'
                       ^
z:\build\build\src\accessible\ipc\win\handler/AccessibleHandler.h(14,22): note: expanded from macro 'IDLFOR'
                     ^
z:\build\build\src\accessible\ipc\win\handler/AccessibleHandler.h(13,36): note: expanded from macro '__GENIDL'
                                   ^
1 error generated.
midl : command line error MIDL1003 : error returned by the C preprocessor (1)
```

There's only one place using the NEWEST_IA2_IDL and accompanying
macros, we can just avoid the issue altogether by expanding it manually
(and it's not like the macro buys much, the other arm of the __midl ifdef
has a #include "Accessible2_3.h" that doesn't use the macro either,
presumably for the same reason).

Differential Revision: https://phabricator.services.mozilla.com/D24868

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Hommey 2019-03-26 16:29:17 +00:00
parent 745c949fa8
commit b5706992db
2 changed files with 7 additions and 8 deletions

View File

@ -9,11 +9,6 @@
#define NEWEST_IA2_BASENAME Accessible2_3
#define __QUOTE(idl) #idl
#define __GENIDL(base) __QUOTE(base##.idl)
#define IDLFOR(base) __GENIDL(base)
#define NEWEST_IA2_IDL IDLFOR(NEWEST_IA2_BASENAME)
#define __GENIFACE(base) I##base
#define INTERFACEFOR(base) __GENIFACE(base)
#define NEWEST_IA2_INTERFACE INTERFACEFOR(NEWEST_IA2_BASENAME)
@ -24,7 +19,7 @@
#if defined(__midl) || defined(__WIDL__)
import NEWEST_IA2_IDL;
import "Accessible2_3.idl";
#else

View File

@ -1163,8 +1163,12 @@ def midl_flags(c_compiler, target, toolchain_search_path):
'aarch64': 'arm64',
}[target.cpu]
flags = ['-env', env]
# Ideally, we'd use ['-cpp_cmd', c_compiler.compiler], but clang-cl
# currently doesn't work as a preprocessor for midl, so we need to
if c_compiler.version >= '8':
return flags + ['-cpp_cmd', c_compiler.compiler]
# clang-cl didn't work as a preprocessor for midl before version 8
# so we need to find cl if we use an older version.
# find cl. https://bugs.llvm.org/show_bug.cgi?id=40140
cl = find_program('cl', paths=toolchain_search_path)
if not cl: