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 import("//build/config/win/visual_studio_version.gni")
9 # This template defines a rule to invoke the MS IDL compiler.
14 # List of .idl file to process.
17 # Directory to write the generated files to. Defaults to target_gen_dir.
19 # visibility (optional)
22 action_name = "${target_name}_idl_action"
23 source_set_name = target_name
25 assert(defined(invoker.sources), "Source must be defined for $target_name")
27 if (defined(invoker.out_dir)) {
28 out_dir = invoker.out_dir
30 out_dir = target_gen_dir
33 header_file = "{{source_name_part}}.h"
34 dlldata_file = "{{source_name_part}}.dlldata.c"
35 interface_identifier_file = "{{source_name_part}}_i.c"
36 proxy_file = "{{source_name_part}}_p.c"
37 type_library_file = "{{source_name_part}}.tlb"
39 action_foreach(action_name) {
40 visibility = ":$source_set_name"
42 # This functionality is handled by the win-tool because the GYP build has
43 # MIDL support built-in.
44 # TODO(brettw) move this to a separate MIDL wrapper script for better
45 # clarity once GYP support is not needed.
46 script = "$root_build_dir/gyp-win-tool"
48 sources = invoker.sources
50 # Note that .tlb is not included in the outputs as it is not always
51 # generated depending on the content of the input idl file.
53 "$out_dir/$header_file",
54 "$out_dir/$dlldata_file",
55 "$out_dir/$interface_identifier_file",
56 "$out_dir/$proxy_file",
59 if (cpu_arch == "x86") {
60 win_tool_arch = "environment.x86"
61 idl_target_platform = "win32"
62 } else if (cpu_arch == "x64") {
63 win_tool_arch = "environment.x64"
64 idl_target_platform = "x64"
66 assert(false, "Need environment for this arch")
70 "midl-wrapper", win_tool_arch,
71 rebase_path(out_dir, root_build_dir),
75 interface_identifier_file,
79 "/env", idl_target_platform,
83 foreach(include, system_include_dirs) {
84 args += [ "/I", include ]
88 source_set(target_name) {
89 if (defined(invoker.visibility)) {
90 visibility = invoker.visibility
93 # We only compile the IID files from the IDL tool rather than all outputs.
94 sources = process_file_template(
96 [ "$out_dir/$interface_identifier_file" ])
98 deps = [ ":$action_name" ]