1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
7 # This template defines a rule to invoke the MS IDL compiler.
12 # List of .idl file to process.
15 # Directory to write the generated files to. Defaults to target_gen_dir.
17 # visibility (optional)
20 action_name = "${target_name}_idl_action"
21 source_set_name = target_name
23 assert(defined(invoker.sources), "Source must be defined for $target_name")
25 if (defined(invoker.out_dir)) {
26 out_dir = invoker.out_dir
28 out_dir = target_gen_dir
31 header_file = "{{source_name_part}}.h"
32 dlldata_file = "{{source_name_part}}.dlldata.c"
33 interface_identifier_file = "{{source_name_part}}_i.c"
34 proxy_file = "{{source_name_part}}_p.c"
35 type_library_file = "{{source_name_part}}.tlb"
37 action_foreach(action_name) {
38 visibility = ":$source_set_name"
40 # This functionality is handled by the win-tool because the GYP build has
41 # MIDL support built-in.
42 # TODO(brettw) move this to a separate MIDL wrapper script for better
43 # clarity once GYP support is not needed.
44 script = "$root_build_dir/gyp-win-tool"
46 sources = invoker.sources
48 # Note that .tlb is not included in the outputs as it is not always
49 # generated depending on the content of the input idl file.
51 "$out_dir/$header_file",
52 "$out_dir/$dlldata_file",
53 "$out_dir/$interface_identifier_file",
54 "$out_dir/$proxy_file",
57 if (cpu_arch == "x86") {
58 win_tool_arch = "environment.x86"
59 idl_target_platform = "win32"
60 } else if (cpu_arch == "x64") {
61 win_tool_arch = "environment.x64"
62 idl_target_platform = "x64"
64 assert(false, "Need environment for this arch")
68 "midl-wrapper", win_tool_arch,
69 rebase_path(out_dir, root_build_dir),
73 interface_identifier_file,
77 "/env", idl_target_platform,
82 source_set(target_name) {
83 if (defined(invoker.visibility)) {
84 visibility = invoker.visibility
87 # We only compile the IID files from the IDL tool rather than all outputs.
88 sources = process_file_template(
90 [ "$out_dir/$interface_identifier_file" ])
92 deps = [ ":$action_name" ]