Commit 9a10fc2d authored by Jacques Newman's avatar Jacques Newman Committed by Chromium LUCI CQ

Update midl.py to be able to skip dlldata and proxy files.

Some IDLs do not generate a dlldata or proxy stub file. In these cases,
midl.py should not expect midl to generate these, similar to how .tlb
files are handled today. Currently, midl.py will assert as the
output comparison will always try to find the dlldata and proxy files.

This issue was found in a project downstream, currently there are no
such IDLs being build in chromium.

Bug: 1157129
Change-Id: Id6069eb7879ce917ab683c7ac00543f36d0dee4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2582261Reviewed-by: default avatarS. Ganesh <ganesh@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Jacques Newman <janewman@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#835740}
parent 4e6ead69
......@@ -39,6 +39,12 @@ import("//build/config/win/visual_studio_version.gni")
# writes_tlb (optional)
# Whether a .tlb file should be added to outputs. Defaults to false.
#
# writes_proxy(optional)
# Whether a _p.c file should be added to outputs. Defaults to true.
#
# writes_dlldata(optional)
# Whether a .dlldata.c file should be added to outputs. Defaults to true.
#
# deps (optional)
#
# defines (optional)
......@@ -84,15 +90,38 @@ template("midl") {
writes_tlb = false
}
dlldata_file = "{{source_name_part}}.dlldata.c"
interface_identifier_file = "{{source_name_part}}_i.c"
proxy_file = "{{source_name_part}}_p.c"
if (defined(invoker.writes_proxy)) {
writes_proxy = invoker.writes_proxy
} else {
writes_proxy = true
}
if (defined(invoker.writes_dlldata)) {
writes_dlldata = invoker.writes_dlldata
} else {
writes_dlldata = true
}
if (writes_tlb) {
type_library_file = "{{source_name_part}}.tlb"
} else {
type_library_file = "none"
}
if (writes_dlldata) {
dlldata_file = "{{source_name_part}}.dlldata.c"
} else {
dlldata_file = "none"
}
if (writes_proxy) {
proxy_file = "{{source_name_part}}_p.c"
} else {
proxy_file = "none"
}
interface_identifier_file = "{{source_name_part}}_i.c"
# TODO(crbug.com/1112471): Get this to run cleanly under Python 3.
python2_action_foreach(action_name) {
visibility = [ ":$source_set_name" ]
......@@ -102,16 +131,21 @@ template("midl") {
outputs = [
"$out_dir/$header_file",
"$out_dir/$dlldata_file",
"$out_dir/$interface_identifier_file",
"$out_dir/$proxy_file",
]
# The .tlb is only added to outputs if the invoker so desires, as it is not
# always generated depending on the content of the input idl file.
# These files are only added to outputs if the invoker so desires, as it
# they are not always generated depending on the content of the input idl
# file.
if (writes_tlb) {
outputs += [ "$out_dir/$type_library_file" ]
}
if (writes_dlldata) {
outputs += [ "$out_dir/$dlldata_file" ]
}
if (writes_proxy) {
outputs += [ "$out_dir/$proxy_file" ]
}
if (current_cpu == "x86") {
win_tool_arch = "environment.x86"
......
......@@ -336,13 +336,26 @@ def main(arch, gendir, outdir, dynamic_guids, tlb, h, dlldata, iid, proxy,
# third_party\win_build_output\midl. We create an empty directory for now.
os.makedirs(source)
common_files = [h, dlldata, iid, proxy]
common_files = [h, iid]
if tlb != 'none':
# Not all projects use tlb files.
common_files += [tlb]
else:
tlb = None
if dlldata != 'none':
# Not all projects use dlldta files.
common_files += [dlldata]
else:
dlldata = None
# Not all projects use proxy files
if proxy != 'none':
# Not all projects use proxy files.
common_files += [proxy]
else:
proxy = None
for source_file in common_files:
file_path = os.path.join(source, source_file)
if not os.path.isfile(file_path):
......@@ -418,9 +431,10 @@ def main(arch, gendir, outdir, dynamic_guids, tlb, h, dlldata, iid, proxy,
preprocessor_options += ''.join(
[' ' + flag for flag in flags if flag.startswith('/D')])
args = ['midl', '/nologo'] + list(flags) + (['/tlb', tlb] if tlb else []) + [
'/h', h, '/dlldata', dlldata, '/iid', iid, '/proxy', proxy, '/cpp_cmd',
clang, '/cpp_opt', preprocessor_options, idl
]
'/h', h
] + (['/dlldata', dlldata] if dlldata else []) + ['/iid', iid] + (
['/proxy', proxy] if proxy else
[]) + ['/cpp_cmd', clang, '/cpp_opt', preprocessor_options, idl]
returncode, midl_output_dir = run_midl(args, env_dict)
if returncode != 0:
......
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