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 if (defined(invoker.visibility)) { 39 visibility = invoker.visibility 40 } 41 42 # Save static list to temp file to avoid blowing out command-line length 43 # limit. 44 file_list = "$target_gen_dir/${target_name}_file_list.txt" 45 write_file(file_list, rebase_path(invoker.sources_static, root_build_dir)) 46 47 inputs = [ 48 "$bindings_scripts_dir/utilities.py", 49 file_list, 50 ] + invoker.sources_static + invoker.sources_generated 51 52 outputs = [ 53 invoker.output_file 54 ] 55 56 args = [ 57 "--idl-files-list", rebase_path(file_list, root_build_dir), 58 "--interfaces-info-file", 59 rebase_path(invoker.output_file, root_build_dir), 60 "--write-file-only-if-changed=1", 61 "--", 62 ] + rebase_path(invoker.sources_generated, root_build_dir) 63 64 deps = [ 65 # FIXME: should be {modules|core}_generated_idls 66 # http://crbug.com/358074 67 "//third_party/WebKit/Source/bindings:generated_idls", 68 ] 69 } 70 } 71 72 # Calls generate_event_interfaces 73 # 74 # Parameters: 75 # sources = A list of IDL files to process. 76 # output_file = The .in file to write, relative to the blink_gen_dir. 77 # suffix = (Optional) String to be passed to script via --suffix 78 template("generate_event_interfaces") { 79 action(target_name) { 80 # Write the file list to a unique temp file to avoid blowing out the 81 # command line length limit. 82 idl_files_list = "$target_gen_dir/${target_name}_file_list.tmp" 83 write_file(idl_files_list, 84 rebase_path(invoker.sources, root_build_dir)) 85 86 inputs = [ 87 "//third_party/WebKit/Source/bindings/scripts/utilities.py", 88 idl_files_list, 89 ] + invoker.sources 90 91 output_file = "$root_gen_dir/blink/" + invoker.output_file 92 outputs = [ output_file ] 93 94 script = "//third_party/WebKit/Source/bindings/scripts/generate_event_interfaces.py" 95 args = [ 96 "--event-idl-files-list", 97 rebase_path(idl_files_list, root_build_dir), 98 "--event-interfaces-file", 99 rebase_path(output_file, root_build_dir), 100 "--write-file-only-if-changed=1", # Always true for Ninja. 101 ] 102 103 if (defined(invoker.suffix)) { 104 args += [ "--suffix", invoker.suffix ] 105 } 106 } 107 } 108 109 # Runs the idl_compiler script over a list of sources. 110 # 111 # Parameters: 112 # sources = list of IDL files to compile 113 # output_dir = string containing the directory to put the output files. 114 template("idl_compiler") { 115 output_dir = invoker.output_dir 116 117 action_foreach(target_name) { 118 # TODO(brettw) GYP adds a "-S before the script name to skip "import site" to 119 # speed up startup. Figure out if we need this and do something similar (not 120 # really expressible in GN now). 121 script = "//third_party/WebKit/Source/bindings/scripts/idl_compiler.py" 122 123 inputs = 124 idl_lexer_parser_files + # to be explicit (covered by parsetab) 125 idl_compiler_files 126 inputs += [ 127 "$bindings_scripts_output_dir/lextab.py", 128 "$bindings_scripts_output_dir/parsetab.pickle", 129 "$bindings_scripts_output_dir/cached_jinja_templates.stamp", 130 "$bindings_dir/IDLExtendedAttributes.txt", 131 # If the dependency structure or public interface info (e.g., 132 # [ImplementedAs]) changes, we rebuild all files, since we're not 133 # computing dependencies file-by-file in the build. 134 # This data is generally stable. 135 "$bindings_modules_output_dir/InterfacesInfoModules.pickle", 136 ] 137 # Further, if any dependency (partial interface or implemented 138 # interface) changes, rebuild everything, since every IDL potentially 139 # depends on them, because we're not computing dependencies 140 # file-by-file. 141 # FIXME: This is too conservative, and causes excess rebuilds: 142 # compute this file-by-file. http://crbug.com/341748 143 # This should theoretically just be the IDL files passed in. 144 inputs += all_dependency_idl_files 145 146 sources = invoker.sources 147 outputs = [ 148 "$output_dir/V8{{source_name_part}}.cpp", 149 "$output_dir/V8{{source_name_part}}.h", 150 ] 151 152 args = [ 153 "--cache-dir", 154 rebase_path(bindings_scripts_output_dir, root_build_dir), 155 "--output-dir", 156 rebase_path(output_dir, root_build_dir), 157 "--interfaces-info", 158 rebase_path("$bindings_modules_output_dir/InterfacesInfoModules.pickle", 159 root_build_dir), 160 "--write-file-only-if-changed=1", # Always true for Ninja. 161 "{{source}}", 162 ] 163 164 deps = [ 165 # FIXME: should be interfaces_info_core (w/o modules) 166 # http://crbug.com/358074 167 "//third_party/WebKit/Source/bindings/modules:interfaces_info", 168 169 "//third_party/WebKit/Source/bindings/scripts:cached_lex_yacc_tables", 170 "//third_party/WebKit/Source/bindings/scripts:cached_jinja_templates", 171 "//third_party/WebKit/Source/core:generated_testing_idls", 172 ] 173 } 174 } 175 176 # Runs the idl_compiler to generate IDL dictionary impl files. 177 # 178 # Parameters: 179 # sources = a list of IDL files to process 180 # outputs = a list of files to write to 181 template("idl_dictionary") { 182 output_dir = "$root_gen_dir/blink/" 183 184 action(target_name) { 185 script = "//third_party/WebKit/Source/bindings/scripts/idl_compiler.py" 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 inputs = [ idl_files_list ] + invoker.sources 190 outputs = invoker.outputs 191 192 args = [ 193 "--cache-dir", 194 rebase_path(bindings_scripts_output_dir, root_build_dir), 195 "--output-dir", 196 rebase_path(output_dir, root_build_dir), 197 "--interfaces-info", 198 rebase_path("$bindings_modules_output_dir/InterfacesInfoModules.pickle", 199 root_build_dir), 200 "--write-file-only-if-changed=1", 201 "--generate-dictionary-impl", 202 rebase_path(idl_files_list, root_build_dir), 203 ] 204 205 deps = [ 206 # FIXME: should be interfaces_info_core (w/o modules) 207 # http://crbug.com/358074 208 "//third_party/WebKit/Source/bindings/modules:interfaces_info", 209 "//third_party/WebKit/Source/bindings/scripts:cached_lex_yacc_tables", 210 "//third_party/WebKit/Source/bindings/scripts:cached_jinja_templates", 211 ] 212 } 213 } 214 215 # Calls the aggregate_generated_bindings script. 216 # 217 # Parameters: 218 # sources = a list of source IDL files. 219 # component_dir = Name of directory for these files (one word, no slashes). 220 # outputs = a list of files to write to. 221 template("aggregate_generated_bindings") { 222 action(target_name) { 223 script = "//third_party/WebKit/Source/bindings/scripts/aggregate_generated_bindings.py" 224 225 # Write lists of main IDL files to a file, so that the command lines don't 226 # exceed OS length limits. 227 idl_files_list = "$target_gen_dir/${target_name}_file_list.tmp" 228 write_file(idl_files_list, rebase_path(invoker.sources, root_build_dir)) 229 230 inputs = [ idl_files_list ] + invoker.sources 231 outputs = invoker.outputs 232 233 args = [ 234 invoker.component_dir, 235 rebase_path(idl_files_list, root_build_dir), 236 "--", 237 ] 238 args += rebase_path(invoker.outputs, root_build_dir) 239 } 240 } 241