Commit 9716b532 authored by Scott Sheehan's avatar Scott Sheehan Committed by Commit Bot

Remove midl.py dependency on output location

midl.py currently does some path munging that is better handled by midl.gni.
It has knowledge of 'third_party' and 'win_build_output' and these should be
an argument to the script provided by the build system instead of knowledge
intrinsic to midl.py.

This changes moves that logic to midl.gni. midl.gni produces the same default
path that midl.py previously generated (so net result is a no-op).
browser_switcher/bho is the only consumer that had custom logic that needed
to explicitly specify the output location. Additionally, this enables
other IDL producers to specify a non-standard place to persist the IDLs if
they so desire.

Details:
midl.py/gni facilitate IDL compilation. Nominally, one would run midl as part
of the build process and be done with it. However, to support cross-platform
compilation, IDL generation is done on Windows clients and persisted in the
source tree. This way platforms that can't run midl directly can still
produce a Windows build.

For a given IDL, in the source tree |somewhere|, the standard location for
the checked in midl outputs is third_party\win_build_output\midl\|somewhere|.
midl.py knew how to get from the IDL built outputs (in |gen|) to the standard
location. Now midl.gni has that knowledge, additionally some other location,
other than the standard location may be used, if necessary.

Bug: 976936
Change-Id: Ibd448c8d59cc59e19c26beb8235c6f581182061e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1666483Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Reviewed-by: default avatarNicolas Ouellet-Payeur <nicolaso@chromium.org>
Commit-Queue: Scott Sheehan <ssheehan@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#672109}
parent 1c3b2409
...@@ -21,6 +21,10 @@ import("//build/config/win/visual_studio_version.gni") ...@@ -21,6 +21,10 @@ import("//build/config/win/visual_studio_version.gni")
# out_dir (optional) # out_dir (optional)
# Directory to write the generated files to. Defaults to target_gen_dir. # Directory to write the generated files to. Defaults to target_gen_dir.
# #
# generated_dir (optional)
# Directory where generated files were previously persisted.
# Defaults to third_party\win_build_output\midl\|out_dir|.
#
# dynamic_guid (optional) # dynamic_guid (optional)
# If the GUID is not constant across builds, the current GUID. # If the GUID is not constant across builds, the current GUID.
# #
...@@ -42,6 +46,14 @@ template("midl") { ...@@ -42,6 +46,14 @@ template("midl") {
out_dir = target_gen_dir out_dir = target_gen_dir
} }
if (defined(invoker.generated_dir)) {
generated_dir = rebase_path(invoker.generated_dir)
} else {
# midl.py expects 'gen' to be replaced with 'midl'.
generated_dir = rebase_path("//third_party/win_build_output") + "/midl/" +
rebase_path(rebase_path(out_dir, root_build_dir), "gen")
}
if (defined(invoker.dynamic_guid)) { if (defined(invoker.dynamic_guid)) {
dynamic_guid = invoker.dynamic_guid dynamic_guid = invoker.dynamic_guid
} else { } else {
...@@ -99,6 +111,7 @@ template("midl") { ...@@ -99,6 +111,7 @@ template("midl") {
args = [ args = [
win_tool_arch, win_tool_arch,
generated_dir,
rebase_path(out_dir, root_build_dir), rebase_path(out_dir, root_build_dir),
dynamic_guid, dynamic_guid,
type_library_file, type_library_file,
......
...@@ -153,12 +153,10 @@ def overwrite_cls_guid(h_file, iid_file, tlb_file, dynamic_guid): ...@@ -153,12 +153,10 @@ def overwrite_cls_guid(h_file, iid_file, tlb_file, dynamic_guid):
overwrite_cls_guid_tlb(tlb_file, dynamic_guid) overwrite_cls_guid_tlb(tlb_file, dynamic_guid)
def main(arch, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, idl, *flags): def main(arch, gendir, outdir, dynamic_guid, tlb, h, dlldata, iid, proxy, idl,
*flags):
# Copy checked-in outputs to final location. # Copy checked-in outputs to final location.
THIS_DIR = os.path.abspath(os.path.dirname(__file__)) source = gendir
source = os.path.join(THIS_DIR, '..', '..', '..',
'third_party', 'win_build_output',
re.sub(r'(^[^/]+/)?gen/', 'midl/', outdir))
if os.path.isdir(os.path.join(source, os.path.basename(idl))): if os.path.isdir(os.path.join(source, os.path.basename(idl))):
source = os.path.join(source, os.path.basename(idl)) source = os.path.join(source, os.path.basename(idl))
source = os.path.join(source, arch.split('.')[1]) # Append 'x86' or 'x64'. source = os.path.join(source, arch.split('.')[1]) # Append 'x86' or 'x64'.
......
...@@ -103,4 +103,8 @@ midl("ie_bho_idl") { ...@@ -103,4 +103,8 @@ midl("ie_bho_idl") {
sources = [ sources = [
"ie_bho_idl.idl", "ie_bho_idl.idl",
] ]
# We have a custom output directory (that excludes the toolchain details).
generated_dir =
"//third_party/win_build_output/midl/chrome/browser/browser_switcher/bho"
} }
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