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.
20 # visibility (optional)
23 action_name = "${target_name}_idl_action"
24 source_set_name = target_name
26 assert(defined(invoker.sources), "Source must be defined for $target_name")
28 if (defined(invoker.out_dir)) {
29 out_dir = invoker.out_dir
31 out_dir = target_gen_dir
34 header_file = "{{source_name_part}}.h"
35 dlldata_file = "{{source_name_part}}.dlldata.c"
36 interface_identifier_file = "{{source_name_part}}_i.c"
37 proxy_file = "{{source_name_part}}_p.c"
38 type_library_file = "{{source_name_part}}.tlb"
40 action_foreach(action_name) {
41 visibility = [ ":$source_set_name" ]
43 # This functionality is handled by the win-tool because the GYP build has
44 # MIDL support built-in.
45 # TODO(brettw) move this to a separate MIDL wrapper script for better
46 # clarity once GYP support is not needed.
47 script = "$root_build_dir/gyp-win-tool"
49 sources = invoker.sources
51 # Note that .tlb is not included in the outputs as it is not always
52 # generated depending on the content of the input idl file.
54 "$out_dir/$header_file",
55 "$out_dir/$dlldata_file",
56 "$out_dir/$interface_identifier_file",
57 "$out_dir/$proxy_file",
60 if (current_cpu == "x86") {
61 win_tool_arch = "environment.x86"
62 idl_target_platform = "win32"
63 } else if (current_cpu == "x64") {
64 win_tool_arch = "environment.x64"
65 idl_target_platform = "x64"
67 assert(false, "Need environment for this arch")
73 rebase_path(out_dir, root_build_dir),
77 interface_identifier_file,
87 if (defined(invoker.deps)) {
92 source_set(target_name) {
93 if (defined(invoker.visibility)) {
94 visibility = invoker.visibility
97 # We only compile the IID files from the IDL tool rather than all outputs.
98 sources = process_file_template(invoker.sources,
99 [ "$out_dir/$interface_identifier_file" ])
105 config("midl_warnings") {
107 # MIDL generates code like "#endif !_MIDL_USE_GUIDDEF_"
108 cflags = [ "-Wno-extra-tokens" ]
111 configs += [ ":midl_warnings" ]