| # Copyright 2014 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//mojo/public/tools/bindings/mojom.gni") |
| import("//third_party/closure_compiler/closure_args.gni") |
| import("//third_party/closure_compiler/compile_js.gni") |
| import("//tools/grit/grit_rule.gni") |
| |
| interfaces_bindings_gen_dir = "$root_gen_dir/mojo/public/interfaces/bindings" |
| |
| action("bindings") { |
| bindings_js_files = [ |
| # This must be the first file in the list, because it initializes global |
| # variable |mojo| that the others need to refer to. |
| "base.js", |
| |
| "bindings.js", |
| "interface_types.js", |
| "lib/buffer.js", |
| "lib/codec.js", |
| "lib/connector.js", |
| "lib/control_message_handler.js", |
| "lib/control_message_proxy.js", |
| "lib/interface_endpoint_client.js", |
| "lib/interface_endpoint_handle.js", |
| "lib/pipe_control_message_handler.js", |
| "lib/pipe_control_message_proxy.js", |
| "lib/router.js", |
| "lib/unicode.js", |
| "lib/validator.js", |
| |
| # These two needs to refer to codec.js. |
| "$interfaces_bindings_gen_dir/interface_control_messages.mojom.js", |
| "$interfaces_bindings_gen_dir/pipe_control_messages.mojom.js", |
| ] |
| compiled_file = "$target_gen_dir/mojo_bindings.js" |
| |
| # TODO(yzshen): Eventually we would like to use Closure Compiler to minify the |
| # bindings instead of simply concatenating the files. |
| script = "//v8/tools/concatenate-files.py" |
| |
| sources = bindings_js_files |
| outputs = [ |
| compiled_file, |
| ] |
| |
| args = rebase_path(bindings_js_files, root_build_dir) |
| args += [ rebase_path(compiled_file, root_build_dir) ] |
| |
| deps = [ |
| "//mojo/public/interfaces/bindings:bindings_js__generator", |
| ] |
| } |
| |
| bindings_lite_sources = [ |
| "bindings_lite.js", |
| "interface_support.js", |
| ] |
| |
| bindings_lite_compiled_file = "$target_gen_dir/mojo_bindings_lite.js" |
| |
| js_library("bindings_lite_sources") { |
| sources = [ "compile_preamble.js" ] + bindings_lite_sources |
| deps = [ |
| "//mojo/public/interfaces/bindings:bindings_js_library_for_compile", |
| ] |
| } |
| |
| if (enable_mojom_closure_compile || closure_compile) { |
| js_binary("bindings_lite") { |
| outputs = [ |
| bindings_lite_compiled_file, |
| ] |
| deps = [ |
| ":bindings_lite_sources", |
| ] |
| externs_list = [ |
| "$externs_path/mojo_core.js", |
| "$externs_path/pending.js", |
| ] |
| closure_flags = strict_error_checking_closure_args + [ |
| "compilation_level=ADVANCED_OPTIMIZATIONS", |
| "language_in=ECMASCRIPT_2017", |
| "language_out=ECMASCRIPT5_STRICT", |
| "generate_exports", |
| ] |
| } |
| } else { |
| action("bindings_lite") { |
| all_sources = bindings_lite_sources + [ "$root_gen_dir/mojo/public/interfaces/bindings/interface_control_messages.mojom-lite.js" ] |
| script = "//mojo/public/tools/bindings/concatenate_and_replace_closure_exports.py" |
| sources = all_sources |
| outputs = [ |
| bindings_lite_compiled_file, |
| ] |
| args = rebase_path(all_sources, root_build_dir) + |
| [ rebase_path(bindings_lite_compiled_file, root_build_dir) ] |
| deps = [ |
| "//mojo/public/interfaces/bindings:bindings_js__generator", |
| ] |
| } |
| } |
| |
| grit("resources") { |
| source = "mojo_bindings_resources.grd" |
| |
| # The .grd contains references to generated files. |
| source_is_generated = true |
| |
| outputs = [ |
| "grit/mojo_bindings_resources.h", |
| "grit/mojo_bindings_resources_map.cc", |
| "grit/mojo_bindings_resources_map.h", |
| "mojo_bindings_resources.pak", |
| ] |
| |
| grit_flags = [ |
| "-E", |
| "root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir), |
| ] |
| |
| deps = [ |
| ":bindings", |
| ":bindings_lite", |
| "//mojo/public/mojom/base:base_js", |
| ] |
| } |
| |
| group("tests") { |
| deps = [ |
| "//mojo/public/js/test:compile_test", |
| ] |
| } |