Commit 5d0edd94 authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

bindings: Generate entries for .cpp/.h files from IDL dictionaries in GN

By auto-generating those entries, we can stop requiring people to manually
update lists such as |generated_core_dictionary_files| every time Blink's
lists of IDL dictionary files change.

Since the names of the generated .cpp/.h follow a fixed, specific format
that only depends on their respective IDL file's path and file name, we can
use GN itself to do some path introspection and generate the file names we
want in idl_impl().

While here, change the names of idl_impl()'s required arguments to make
their purpose more explicit: it is not immediately obvious that we
differentiate unions and callback functions from dictionary files in terms
of where the latter are generated and their file names, as well as why
idl_impl() only expects non-dictionary files in its outputs list. A good
next step would be generating dictionary impl files separately from unions
and callbacks to avoid the confusion altogether.

Bug: 725996
Change-Id: I41b06e8d71f33b21d77944216fcb07d0557ac47b
Reviewed-on: https://chromium-review.googlesource.com/517795
Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#476262}
parent 0f1cadbc
...@@ -27,11 +27,10 @@ idl_compiler("generate_bindings_modules_v8_interfaces") { ...@@ -27,11 +27,10 @@ idl_compiler("generate_bindings_modules_v8_interfaces") {
} }
idl_impl("bindings_modules_impl_generated") { idl_impl("bindings_modules_impl_generated") {
sources = modules_dictionary_idl_files dict_idls = modules_dictionary_idl_files
outputs = bindings_modules_generated_union_type_files + non_dict_outputs = bindings_modules_generated_union_type_files +
generated_modules_dictionary_files + generated_modules_callback_function_files
generated_modules_callback_function_files non_dict_output_dir = bindings_modules_v8_output_dir
output_dir = bindings_modules_v8_output_dir
target_component = "modules" target_component = "modules"
} }
......
...@@ -245,12 +245,17 @@ template("idl_compiler") { ...@@ -245,12 +245,17 @@ template("idl_compiler") {
} }
} }
# Runs the idl_compiler to generate IDL dictionary and union impl files. # Runs idl_compiler.py to generate IDL dictionary impl files, unions and
# callback functions.
# #
# Parameters: # Parameters:
# sources = a list of IDL files to process # dict_idls = a list of dictionary IDL files to process. the callback and
# outputs = a list of files to write to # union IDL file names are already known and do not need to be
# output_dir = the directory to put the output files # specified.
# non_dict_outputs = a list of files generated from callback functions and
# unions. the list of files generated from |dict_idls| is
# added automatically and does not need to be specified.
# non_dict_output_dir = the directory to put the non-dict output files.
# target_component = component to generate code for # target_component = component to generate code for
template("idl_impl") { template("idl_impl") {
dictionary_impl_output_dir = "$root_gen_dir/blink/" dictionary_impl_output_dir = "$root_gen_dir/blink/"
...@@ -258,7 +263,7 @@ template("idl_impl") { ...@@ -258,7 +263,7 @@ template("idl_impl") {
action(target_name) { action(target_name) {
script = "//third_party/WebKit/Source/bindings/scripts/idl_compiler.py" script = "//third_party/WebKit/Source/bindings/scripts/idl_compiler.py"
idl_files_list = "$target_gen_dir/${target_name}_file_list.tmp" idl_files_list = "$target_gen_dir/${target_name}_file_list.tmp"
write_file(idl_files_list, rebase_path(invoker.sources, root_build_dir)) write_file(idl_files_list, rebase_path(invoker.dict_idls, root_build_dir))
inputs = idl_lexer_parser_files + idl_compiler_files # to be explicit (covered by parsetab) inputs = idl_lexer_parser_files + idl_compiler_files # to be explicit (covered by parsetab)
inputs += [ inputs += [
...@@ -267,14 +272,27 @@ template("idl_impl") { ...@@ -267,14 +272,27 @@ template("idl_impl") {
"$bindings_scripts_output_dir/cached_jinja_templates.stamp", "$bindings_scripts_output_dir/cached_jinja_templates.stamp",
"$bindings_dir/IDLExtendedAttributes.txt", "$bindings_dir/IDLExtendedAttributes.txt",
] ]
inputs += [ idl_files_list ] + invoker.sources inputs += [ idl_files_list ] + invoker.dict_idls
outputs = invoker.outputs outputs = invoker.non_dict_outputs
# Derive the names of the generated dictionary impl files. Contrary to
# generated interfaces, callbacks and unions, these files go to
# $root_gen_dir/blink/{core,modules}/<module name>/<IDLName>.{cpp,h}.
foreach(dict_idl, invoker.dict_idls) {
rel_path = rebase_path(dict_idl, "//third_party/WebKit/Source")
impl_dir = get_path_info(rel_path, "dir")
idl_name = get_path_info(rel_path, "name")
outputs += [
"${dictionary_impl_output_dir}$impl_dir/$idl_name.cpp",
"${dictionary_impl_output_dir}$impl_dir/$idl_name.h",
]
}
args = [ args = [
"--cache-dir", "--cache-dir",
rebase_path(bindings_scripts_output_dir, root_build_dir), rebase_path(bindings_scripts_output_dir, root_build_dir),
"--output-dir", "--output-dir",
rebase_path(invoker.output_dir, root_build_dir), rebase_path(invoker.non_dict_output_dir, root_build_dir),
"--impl-output-dir", "--impl-output-dir",
rebase_path(dictionary_impl_output_dir, root_build_dir), rebase_path(dictionary_impl_output_dir, root_build_dir),
"--info-dir", "--info-dir",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment