Commit 7407ad20 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Get midl.exe to use clang-cl instead of cl

When midl.py is finished its work it invokes midl.exe to ensure that the
results are the same. midl.exe defaults to invoking cl.exe, and we want
to consistently use clang-cl.exe.

This change uses /cpp_cmd to specify the clang-cl compiler. It then uses
/cpp_opt to specify -Wno-nonportable-include-path because some of the
SDK .idl files include files using different case from the file on disk.
Typical warnings look like this:

  include\10.0.19041.0\um\unknwn.idl(28,10): warning:
  non-portable path to file '"Unknwnbase.Idl"'; specified path differs
  in case from file name on disk [-Wnonportable-include-path]
  #include "unknwnbase.idl"
           ^~~~~~~~~~~~~~~~
           "Unknwnbase.Idl"

When you use /cpp_opt then you are also responsible for specifying -E
and -nologo and for passing along all of the /D commands, so this change
does that as well.

Bug: 1097510
Change-Id: Iece8ae7395d9afb05652d0a40f333721b3207a9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261267
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781638}
parent f889c1ed
......@@ -123,6 +123,8 @@ template("midl") {
dlldata_file,
interface_identifier_file,
proxy_file,
rebase_path("//third_party/llvm-build/Release+Asserts/bin/clang-cl.exe",
root_build_dir),
"{{source}}",
"/char",
"signed",
......
......@@ -173,8 +173,8 @@ def overwrite_cls_guid(h_file, iid_file, tlb_file, dynamic_guid):
overwrite_cls_guid_tlb(tlb_file, dynamic_guid)
def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, idl,
*flags):
def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, clang,
idl, *flags):
# Copy checked-in outputs to final location.
source = gendir
if os.path.isdir(os.path.join(source, os.path.basename(idl))):
......@@ -192,16 +192,6 @@ def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, idl,
if sys.platform != 'win32':
return 0
# Skip the verification step on Windows 7 to avoid issues running the
# compiler.
ver = sys.getwindowsversion()
# Impossible version number, but just in case...
if ver.major < 6:
return 0
# Check for before Windows 8.
if ver.major == 6 and ver.minor < 2:
return 0;
# On Windows, run midl.exe on the input and check that its outputs are
# identical to the checked-in outputs (after possibly replacing their main
# class guid).
......@@ -214,6 +204,10 @@ def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, idl,
env_pairs = open(arch).read()[:-2].split('\0')
env_dict = dict([item.split('=', 1) for item in env_pairs])
# Extract the /D options and send them to the preprocessor.
preprocessor_options = '-E -nologo -Wno-nonportable-include-path'
preprocessor_options += ''.join(
[' ' + flag for flag in flags if flag.startswith('/D')])
args = ['midl', '/nologo'] + list(flags) + [
'/out', tmp_dir,
'/tlb', tlb,
......@@ -221,6 +215,8 @@ def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, idl,
'/dlldata', dlldata,
'/iid', iid,
'/proxy', proxy,
'/cpp_cmd', clang,
'/cpp_opt', preprocessor_options,
idl]
try:
popen = subprocess.Popen(args, shell=True, env=env_dict,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment