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 import("//third_party/WebKit/Source/bindings/core/v8/generated.gni") |
| 6 import("//third_party/WebKit/Source/bindings/modules/idl.gni") |
| 7 import("//third_party/WebKit/Source/bindings/modules/modules.gni") |
| 8 |
| 9 bindings_scripts_dir = get_path_info(".", "abspath") |
| 10 bindings_scripts_output_dir = "$root_gen_dir/blink/bindings/scripts" |
| 11 |
| 12 # Replacing <(DEPTH) with "/" makes paths like "<(DEPTH)/foo" absolute. |
| 13 _gypi = exec_script( |
| 14 "//build/gypi_to_gn.py", |
| 15 [ rebase_path("scripts.gypi"), |
| 16 "--replace=<(DEPTH)=/" ], |
| 17 "scope", |
| 18 [ "scripts.gypi" ]) |
| 19 |
| 20 jinja_module_files = get_path_info(_gypi.jinja_module_files, "abspath") |
| 21 idl_lexer_parser_files = get_path_info(_gypi.idl_lexer_parser_files, "abspath") |
| 22 idl_compiler_files = get_path_info(_gypi.idl_compiler_files, "abspath") |
| 23 |
| 24 # Calls the compute_interfaces_info_individual script. |
| 25 # |
| 26 # Parameters: |
| 27 # sources_static = list of IDL files to pass as inputs |
| 28 # sources_generated = list of generated IDL files to pass as inputs |
| 29 # component_dir = name if subdirectory (one word, no slashes) of component. |
| 30 # output_file = pickle file to write |
| 31 # |
| 32 # FIXME: Note the static/generated split is for consistency with GYP. This |
| 33 # split is not necessary in the GN build and could be combined into a single |
| 34 # "sources". |
| 35 template("compute_interfaces_info_individual") { |
| 36 action(target_name) { |
| 37 script = "$bindings_scripts_dir/compute_interfaces_info_individual.py" |
| 38 |
| 39 # Save static list to temp file to avoid blowing out command-line length |
| 40 # limit. |
| 41 file_list = "$target_gen_dir/${target_name}_file_list.txt" |
| 42 write_file(file_list, rebase_path(invoker.sources_static, root_build_dir)) |
| 43 |
| 44 source_prereqs = [ |
| 45 "$bindings_scripts_dir/utilities.py", |
| 46 file_list, |
| 47 ] + invoker.sources_static + invoker.sources_generated |
| 48 |
| 49 outputs = [ |
| 50 invoker.output_file |
| 51 ] |
| 52 |
| 53 args = [ |
| 54 "--component-dir", invoker.component_dir, |
| 55 "--idl-files-list", rebase_path(file_list, root_build_dir), |
| 56 "--interfaces-info-file", |
| 57 rebase_path(invoker.output_file, root_build_dir), |
| 58 "--write-file-only-if-changed=1", |
| 59 "--", |
| 60 ] + rebase_path(invoker.sources_generated, root_build_dir) |
| 61 |
| 62 deps = [ |
| 63 # FIXME: should be {modules|core}_generated_idls |
| 64 # http://crbug.com/358074 |
| 65 "//third_party/WebKit/Source/bindings:generated_idls", |
| 66 ] |
| 67 } |
| 68 } |
| 69 |
| 70 # Calls generate_event_interfaces |
| 71 # |
| 72 # Parameters: |
| 73 # sources = A list of IDL files to process. |
| 74 # output_file = The .in file to write, relative to the blink_gen_dir. |
| 75 # suffix = (Optional) String to be passed to script via --suffix |
| 76 template("generate_event_interfaces") { |
| 77 action(target_name) { |
| 78 # Write the file list to a unique temp file to avoid blowing out the |
| 79 # command line length limit. |
| 80 idl_files_list = "$target_gen_dir/${target_name}_file_list.tmp" |
| 81 write_file(idl_files_list, |
| 82 rebase_path(invoker.sources, root_build_dir)) |
| 83 |
| 84 source_prereqs = [ |
| 85 "//third_party/WebKit/Source/bindings/scripts/utilities.py", |
| 86 idl_files_list, |
| 87 ] + invoker.sources |
| 88 |
| 89 output_file = "$root_gen_dir/blink/" + invoker.output_file |
| 90 outputs = [ output_file ] |
| 91 |
| 92 script = "//third_party/WebKit/Source/bindings/scripts/generate_event_interf
aces.py" |
| 93 args = [ |
| 94 "--event-idl-files-list", |
| 95 rebase_path(idl_files_list, root_build_dir), |
| 96 "--event-interfaces-file", |
| 97 rebase_path(output_file, root_build_dir), |
| 98 "--write-file-only-if-changed=1", # Always true for Ninja. |
| 99 ] |
| 100 |
| 101 if (defined(invoker.suffix)) { |
| 102 args += [ "--suffix", invoker.suffix ] |
| 103 } |
| 104 } |
| 105 } |
| 106 |
| 107 # Runs the idl_compiler script over a list of sources. |
| 108 # |
| 109 # Parameters: |
| 110 # sources = list of IDL files to compile |
| 111 # output_dir = string containing the directory to put the output files. |
| 112 template("idl_compiler") { |
| 113 output_dir = invoker.output_dir |
| 114 |
| 115 action_foreach(target_name) { |
| 116 # TODO(brettw) GYP adds a "-S before the script name to skip "import site" t
o |
| 117 # speed up startup. Figure out if we need this and do something similar (not |
| 118 # really expressible in GN now). |
| 119 script = "//third_party/WebKit/Source/bindings/scripts/idl_compiler.py" |
| 120 |
| 121 source_prereqs = |
| 122 idl_lexer_parser_files + # to be explicit (covered by parsetab) |
| 123 idl_compiler_files |
| 124 source_prereqs += [ |
| 125 "$bindings_scripts_output_dir/lextab.py", |
| 126 "$bindings_scripts_output_dir/parsetab.pickle", |
| 127 "$bindings_scripts_output_dir/cached_jinja_templates.stamp", |
| 128 "$bindings_dir/IDLExtendedAttributes.txt", |
| 129 # If the dependency structure or public interface info (e.g., |
| 130 # [ImplementedAs]) changes, we rebuild all files, since we're not |
| 131 # computing dependencies file-by-file in the build. |
| 132 # This data is generally stable. |
| 133 "$bindings_modules_output_dir/InterfacesInfoModules.pickle", |
| 134 ] |
| 135 # Further, if any dependency (partial interface or implemented |
| 136 # interface) changes, rebuild everything, since every IDL potentially |
| 137 # depends on them, because we're not computing dependencies |
| 138 # file-by-file. |
| 139 # FIXME: This is too conservative, and causes excess rebuilds: |
| 140 # compute this file-by-file. http://crbug.com/341748 |
| 141 # This should theoretically just be the IDL files passed in. |
| 142 source_prereqs += all_dependency_idl_files |
| 143 |
| 144 sources = invoker.sources |
| 145 outputs = [ |
| 146 "$output_dir/V8{{source_name_part}}.cpp", |
| 147 "$output_dir/V8{{source_name_part}}.h", |
| 148 ] |
| 149 |
| 150 args = [ |
| 151 "--cache-dir", |
| 152 rebase_path(bindings_scripts_output_dir, root_build_dir), |
| 153 "--output-dir", |
| 154 rebase_path(output_dir, root_build_dir), |
| 155 "--interfaces-info", |
| 156 rebase_path("$bindings_modules_output_dir/InterfacesInfoModules.pickle", |
| 157 root_build_dir), |
| 158 "--write-file-only-if-changed=1", # Always true for Ninja. |
| 159 "{{source}}", |
| 160 ] |
| 161 |
| 162 deps = [ |
| 163 # FIXME: should be interfaces_info_core (w/o modules) |
| 164 # http://crbug.com/358074 |
| 165 "//third_party/WebKit/Source/bindings/modules:interfaces_info", |
| 166 |
| 167 "//third_party/WebKit/Source/bindings/scripts:cached_lex_yacc_tables", |
| 168 "//third_party/WebKit/Source/bindings/scripts:cached_jinja_templates", |
| 169 "//third_party/WebKit/Source/core:generated_testing_idls", |
| 170 ] |
| 171 } |
| 172 } |
| 173 |
| 174 # Calls the aggregate_generated_bindings script. |
| 175 # |
| 176 # Parameters: |
| 177 # sources = a list of source IDL files. |
| 178 # component_dir = Name of directory for these files (one word, no slashes). |
| 179 # outputs = a list of files to write to. |
| 180 template("aggregate_generated_bindings") { |
| 181 action(target_name) { |
| 182 script = "//third_party/WebKit/Source/bindings/scripts/aggregate_generated_b
indings.py" |
| 183 |
| 184 # Write lists of main IDL files to a file, so that the command lines don't |
| 185 # exceed OS length limits. |
| 186 idl_files_list = "$target_gen_dir/${target_name}_file_list.tmp" |
| 187 write_file(idl_files_list, rebase_path(invoker.sources, root_build_dir)) |
| 188 |
| 189 source_prereqs = [ idl_files_list ] + invoker.sources |
| 190 outputs = invoker.outputs |
| 191 |
| 192 args = [ |
| 193 invoker.component_dir, |
| 194 rebase_path(idl_files_list, root_build_dir), |
| 195 "--", |
| 196 ] |
| 197 args += rebase_path(invoker.outputs, root_build_dir) |
| 198 } |
| 199 } |
OLD | NEW |