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