| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 assert(is_win) | |
| 6 | |
| 7 import("//build/config/win/visual_studio_version.gni") | |
| 8 | |
| 9 # This template defines a rule to invoke the MS IDL compiler. | |
| 10 # | |
| 11 # Parameters | |
| 12 # | |
| 13 # sources | |
| 14 # List of .idl file to process. | |
| 15 # | |
| 16 # out_dir (optional) | |
| 17 # Directory to write the generated files to. Defaults to target_gen_dir. | |
| 18 # | |
| 19 # deps (optional) | |
| 20 # visibility (optional) | |
| 21 | |
| 22 template("midl") { | |
| 23 action_name = "${target_name}_idl_action" | |
| 24 source_set_name = target_name | |
| 25 | |
| 26 assert(defined(invoker.sources), "Source must be defined for $target_name") | |
| 27 | |
| 28 if (defined(invoker.out_dir)) { | |
| 29 out_dir = invoker.out_dir | |
| 30 } else { | |
| 31 out_dir = target_gen_dir | |
| 32 } | |
| 33 | |
| 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" | |
| 39 | |
| 40 action_foreach(action_name) { | |
| 41 visibility = [ ":$source_set_name" ] | |
| 42 | |
| 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" | |
| 48 | |
| 49 sources = invoker.sources | |
| 50 | |
| 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. | |
| 53 outputs = [ | |
| 54 "$out_dir/$header_file", | |
| 55 "$out_dir/$dlldata_file", | |
| 56 "$out_dir/$interface_identifier_file", | |
| 57 "$out_dir/$proxy_file", | |
| 58 ] | |
| 59 | |
| 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" | |
| 66 } else { | |
| 67 assert(false, "Need environment for this arch") | |
| 68 } | |
| 69 | |
| 70 args = [ | |
| 71 "midl-wrapper", | |
| 72 win_tool_arch, | |
| 73 rebase_path(out_dir, root_build_dir), | |
| 74 type_library_file, | |
| 75 header_file, | |
| 76 dlldata_file, | |
| 77 interface_identifier_file, | |
| 78 proxy_file, | |
| 79 "{{source}}", | |
| 80 "/char", | |
| 81 "signed", | |
| 82 "/env", | |
| 83 idl_target_platform, | |
| 84 "/Oicf", | |
| 85 ] | |
| 86 | |
| 87 if (defined(invoker.deps)) { | |
| 88 deps = invoker.deps | |
| 89 } | |
| 90 } | |
| 91 | |
| 92 source_set(target_name) { | |
| 93 if (defined(invoker.visibility)) { | |
| 94 visibility = invoker.visibility | |
| 95 } | |
| 96 | |
| 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" ]) | |
| 100 | |
| 101 public_deps = [ | |
| 102 ":$action_name", | |
| 103 ] | |
| 104 } | |
| 105 } | |
| OLD | NEW |