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 # output_file = pickle file to write
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
35 template("compute_interfaces_info_individual") {
37 script = "$bindings_scripts_dir/compute_interfaces_info_individual.py"
38 if (defined(invoker.visibility)) {
39 visibility = invoker.visibility
42 # Save static list to temp file to avoid blowing out command-line length
44 file_list = "$target_gen_dir/${target_name}_file_list.txt"
45 write_file(file_list, rebase_path(invoker.sources_static, root_build_dir))
48 "$bindings_scripts_dir/utilities.py",
50 ] + invoker.sources_static + invoker.sources_generated
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",
62 ] + rebase_path(invoker.sources_generated, root_build_dir)
65 # FIXME: should be {modules|core}_generated_idls
66 # http://crbug.com/358074
67 "//third_party/WebKit/Source/bindings:generated_idls",
72 # Calls generate_event_interfaces
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") {
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))
87 "//third_party/WebKit/Source/bindings/scripts/utilities.py",
91 output_file = "$root_gen_dir/blink/" + invoker.output_file
92 outputs = [ output_file ]
94 script = "//third_party/WebKit/Source/bindings/scripts/generate_event_interfaces.py"
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.
103 if (defined(invoker.suffix)) {
104 args += [ "--suffix", invoker.suffix ]
109 # Runs the idl_compiler script over a list of sources.
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
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"
124 idl_lexer_parser_files + # to be explicit (covered by parsetab)
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",
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
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
146 sources = invoker.sources
148 "$output_dir/V8{{source_name_part}}.cpp",
149 "$output_dir/V8{{source_name_part}}.h",
154 rebase_path(bindings_scripts_output_dir, root_build_dir),
156 rebase_path(output_dir, root_build_dir),
158 rebase_path("$bindings_modules_output_dir/InterfacesInfoModules.pickle",
160 "--write-file-only-if-changed=1", # Always true for Ninja.
165 # FIXME: should be interfaces_info_core (w/o modules)
166 # http://crbug.com/358074
167 "//third_party/WebKit/Source/bindings/modules:interfaces_info",
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",
176 # Runs the idl_compiler to generate IDL dictionary impl files.
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/"
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))
189 inputs = [ idl_files_list ] + invoker.sources
190 outputs = invoker.outputs
194 rebase_path(bindings_scripts_output_dir, root_build_dir),
196 rebase_path(output_dir, root_build_dir),
198 rebase_path("$bindings_modules_output_dir/InterfacesInfoModules.pickle",
200 "--write-file-only-if-changed=1",
201 "--generate-dictionary-impl",
202 rebase_path(idl_files_list, root_build_dir),
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",
215 # Calls the aggregate_generated_bindings script.
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"
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))
230 inputs = [ idl_files_list ] + invoker.sources
231 outputs = invoker.outputs
234 invoker.component_dir,
235 rebase_path(idl_files_list, root_build_dir),
238 args += rebase_path(invoker.outputs, root_build_dir)