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.
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")
9 bindings_scripts_dir = get_path_info(".", "abspath")
10 bindings_scripts_output_dir = "$root_gen_dir/blink/bindings/scripts"
12 # Replacing <(DEPTH) with "/" makes paths like "<(DEPTH)/foo" absolute.
14 "//build/gypi_to_gn.py",
15 [ rebase_path("scripts.gypi"),
16 "--replace=<(DEPTH)=/" ],
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")
24 # Calls the compute_interfaces_info_individual script.
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 # interfaces_info_file = output pickle file for interfaces info.
31 # component_wide_info_file = output pickle file for component wide info.
34 # FIXME: Note the static/generated split is for consistency with GYP. This
35 # split is not necessary in the GN build and could be combined into a single
37 template("compute_interfaces_info_individual") {
39 script = "$bindings_scripts_dir/compute_interfaces_info_individual.py"
40 if (defined(invoker.visibility)) {
41 visibility = invoker.visibility
44 # Save static list to temp file to avoid blowing out command-line length
46 file_list = "$target_gen_dir/${target_name}_file_list.txt"
47 write_file(file_list, rebase_path(invoker.sources_static, root_build_dir))
50 "$bindings_scripts_dir/utilities.py",
52 ] + invoker.sources_static + invoker.sources_generated
55 invoker.interfaces_info_file,
56 invoker.component_wide_info_file,
61 rebase_path(bindings_scripts_output_dir, root_build_dir),
62 "--idl-files-list", rebase_path(file_list, root_build_dir),
63 "--interfaces-info-file",
64 rebase_path(invoker.interfaces_info_file, root_build_dir),
65 "--component-info-file",
66 rebase_path(invoker.component_wide_info_file, root_build_dir),
67 "--write-file-only-if-changed=1",
69 ] + rebase_path(invoker.sources_generated, root_build_dir)
72 "//third_party/WebKit/Source/bindings/scripts:cached_lex_yacc_tables",
77 # Calls generate_event_interfaces
80 # sources = A list of IDL files to process.
81 # output_file = The .in file to write, relative to the blink_gen_dir.
82 # suffix = (Optional) String to be passed to script via --suffix
83 template("generate_event_interfaces") {
85 # Write the file list to a unique temp file to avoid blowing out the
86 # command line length limit.
87 idl_files_list = "$target_gen_dir/${target_name}_file_list.tmp"
88 write_file(idl_files_list,
89 rebase_path(invoker.sources, root_build_dir))
92 "//third_party/WebKit/Source/bindings/scripts/utilities.py",
96 output_file = "$root_gen_dir/blink/" + invoker.output_file
97 outputs = [ output_file ]
99 script = "//third_party/WebKit/Source/bindings/scripts/generate_event_interfaces.py"
101 "--event-idl-files-list",
102 rebase_path(idl_files_list, root_build_dir),
103 "--event-interfaces-file",
104 rebase_path(output_file, root_build_dir),
105 "--write-file-only-if-changed=1", # Always true for Ninja.
108 if (defined(invoker.suffix)) {
109 args += [ "--suffix", invoker.suffix ]
114 # Runs the idl_compiler script over a list of sources.
117 # sources = list of IDL files to compile
118 # output_dir = string containing the directory to put the output files.
119 # output_name_suffix = a suffix after the basename of the output file names.
120 # target_component = component to generate code for.
121 template("idl_compiler") {
122 output_dir = invoker.output_dir
123 output_name_suffix = invoker.output_name_suffix
125 action_foreach(target_name) {
126 # TODO(brettw) GYP adds a "-S before the script name to skip "import site" to
127 # speed up startup. Figure out if we need this and do something similar (not
128 # really expressible in GN now).
129 script = "//third_party/WebKit/Source/bindings/scripts/idl_compiler.py"
132 idl_lexer_parser_files + # to be explicit (covered by parsetab)
135 "$bindings_scripts_output_dir/lextab.py",
136 "$bindings_scripts_output_dir/parsetab.pickle",
137 "$bindings_scripts_output_dir/cached_jinja_templates.stamp",
138 "$bindings_dir/IDLExtendedAttributes.txt",
139 # If the dependency structure or public interface info (e.g.,
140 # [ImplementedAs]) changes, we rebuild all files, since we're not
141 # computing dependencies file-by-file in the build.
142 # This data is generally stable.
143 "$bindings_modules_output_dir/InterfacesInfoOverall.pickle",
145 # Further, if any dependency (partial interface or implemented
146 # interface) changes, rebuild everything, since every IDL potentially
147 # depends on them, because we're not computing dependencies
149 # FIXME: This is too conservative, and causes excess rebuilds:
150 # compute this file-by-file. http://crbug.com/341748
151 # This should theoretically just be the IDL files passed in.
152 inputs += all_dependency_idl_files
154 sources = invoker.sources
156 "$output_dir/V8{{source_name_part}}${output_name_suffix}.cpp",
157 "$output_dir/V8{{source_name_part}}${output_name_suffix}.h",
162 rebase_path(bindings_scripts_output_dir, root_build_dir),
164 rebase_path(output_dir, root_build_dir),
166 rebase_path("$bindings_modules_output_dir/InterfacesInfoOverall.pickle",
168 "--write-file-only-if-changed=1", # Always true for Ninja.
169 "--target-component",
170 invoker.target_component,
175 # FIXME: should be interfaces_info_core (w/o modules)
176 # http://crbug.com/358074
177 "//third_party/WebKit/Source/bindings/modules:interfaces_info",
179 "//third_party/WebKit/Source/bindings/scripts:cached_lex_yacc_tables",
180 "//third_party/WebKit/Source/bindings/scripts:cached_jinja_templates",
181 "//third_party/WebKit/Source/core:generated_testing_idls",
186 # Runs the idl_compiler to generate IDL dictionary and union impl files.
189 # sources = a list of IDL files to process
190 # outputs = a list of files to write to
191 # output_dir = the directory to put the output files
192 # component_wide_info = a filename of pickle file which contains component
194 # target_component = component to generate code for
195 template("idl_impl") {
196 dictionary_impl_output_dir = "$root_gen_dir/blink/"
198 action(target_name) {
199 script = "//third_party/WebKit/Source/bindings/scripts/idl_compiler.py"
200 idl_files_list = "$target_gen_dir/${target_name}_file_list.tmp"
201 write_file(idl_files_list, rebase_path(invoker.sources, root_build_dir))
203 inputs = [ idl_files_list ] + invoker.sources
204 outputs = invoker.outputs
208 rebase_path(bindings_scripts_output_dir, root_build_dir),
210 rebase_path(invoker.output_dir, root_build_dir),
212 rebase_path(dictionary_impl_output_dir, root_build_dir),
214 rebase_path("$bindings_modules_output_dir/InterfacesInfoOverall.pickle",
217 rebase_path(invoker.component_wide_info, root_build_dir),
218 "--target-component",
219 invoker.target_component,
220 "--write-file-only-if-changed=1",
222 rebase_path(idl_files_list, root_build_dir),
226 # FIXME: should be interfaces_info_core (w/o modules)
227 # http://crbug.com/358074
228 "//third_party/WebKit/Source/bindings/core:interfaces_info_individual_core",
229 "//third_party/WebKit/Source/bindings/modules:interfaces_info",
230 "//third_party/WebKit/Source/bindings/modules:interfaces_info_individual_modules",
231 "//third_party/WebKit/Source/bindings/scripts:cached_lex_yacc_tables",
232 "//third_party/WebKit/Source/bindings/scripts:cached_jinja_templates",
237 # Calls the aggregate_generated_bindings script.
240 # sources = a list of source IDL files.
241 # component_dir = Name of directory for these files (one word, no slashes).
242 # outputs = a list of files to write to.
243 template("aggregate_generated_bindings") {
244 action(target_name) {
245 script = "//third_party/WebKit/Source/bindings/scripts/aggregate_generated_bindings.py"
247 # Write lists of main IDL files to a file, so that the command lines don't
248 # exceed OS length limits.
249 idl_files_list = "$target_gen_dir/${target_name}_file_list.tmp"
250 write_file(idl_files_list, rebase_path(invoker.sources, root_build_dir))
252 inputs = [ idl_files_list ] + invoker.sources
253 outputs = invoker.outputs
256 invoker.component_dir,
257 rebase_path(idl_files_list, root_build_dir),
260 args += rebase_path(invoker.outputs, root_build_dir)
264 # Calls the compute_global_objects script.
267 # sources = a list of source IDL files.
268 # sources_generated = a list of generated pickle sources.
269 # output_file = a pickle file to write to (need to specify directory)
271 template("compute_global_objects") {
272 action(target_name) {
273 script = "//third_party/WebKit/Source/bindings/scripts/compute_global_objects.py"
275 # Write the file list to a unique temp file to avoid blowing out the
276 # command line length limit.
277 idl_files_list = "$target_gen_dir/${target_name}_file_list.tmp"
278 write_file(idl_files_list,
279 rebase_path(invoker.sources, root_build_dir))
282 "//third_party/WebKit/Source/bindings/scripts/utilities.py",
284 ] + invoker.sources_generated + invoker.sources
286 outputs = [ invoker.output_file ]
290 rebase_path(idl_files_list, root_build_dir),
291 "--write-file-only-if-changed=1", # Always true for Ninja.
294 args += rebase_path(invoker.sources_generated, root_build_dir)
295 args += [ rebase_path(invoker.output_file, root_build_dir) ]
301 # Calls the generate_global_constructors script.
304 # sources = a list of source IDL files.
305 # global_objects_file = a global objects file generated by compute_global_objects
306 # interfaces = interfaces to generate global constructors for.
307 # component = component to generate global constructors for.
308 # output_dir = output directory to generate idl files and header files.
309 # deps = dependencies
311 template("generate_global_constructors") {
312 action(target_name) {
313 script = "//third_party/WebKit/Source/bindings/scripts/generate_global_constructors.py"
315 # Write the file list to a unique temp file to avoid blowing out the
316 # command line length limit.
317 idl_files_list = "$target_gen_dir/${target_name}_file_list.tmp"
318 write_file(idl_files_list,
319 rebase_path(invoker.sources, root_build_dir))
322 "//third_party/WebKit/Source/bindings/scripts/utilities.py",
324 invoker.global_objects_file,
329 rebase_path(idl_files_list, root_build_dir),
330 "--global-objects-file",
331 rebase_path(invoker.global_objects_file, root_build_dir),
332 "--write-file-only-if-changed=1", # Always true for Ninja.
336 output_dir = invoker.output_dir
337 component = invoker.component
339 # generate outputs from invoker.interfaces.
340 output_idl_files = []
341 output_header_files = []
342 foreach(interface, invoker.interfaces) {
343 args += [ interface ]
344 output_idl_file = "$output_dir/${interface}${component}Constructors.idl"
345 args += [ rebase_path(output_idl_file, root_build_dir) ]
346 output_idl_files += [ output_idl_file ]
347 output_header_files += [
348 "$output_dir/${interface}${component}Constructors.h"
352 outputs = output_idl_files + output_header_files