summaryrefslogtreecommitdiff
path: root/utils/ipc/mojo/public/tools/bindings/mojom.gni
diff options
context:
space:
mode:
Diffstat (limited to 'utils/ipc/mojo/public/tools/bindings/mojom.gni')
-rw-r--r--utils/ipc/mojo/public/tools/bindings/mojom.gni845
1 files changed, 449 insertions, 396 deletions
diff --git a/utils/ipc/mojo/public/tools/bindings/mojom.gni b/utils/ipc/mojo/public/tools/bindings/mojom.gni
index fe2a1da3..3f6e54e0 100644
--- a/utils/ipc/mojo/public/tools/bindings/mojom.gni
+++ b/utils/ipc/mojo/public/tools/bindings/mojom.gni
@@ -1,25 +1,28 @@
-# Copyright 2014 The Chromium Authors. All rights reserved.
+# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import("//build/config/python.gni")
import("//third_party/closure_compiler/closure_args.gni")
import("//third_party/closure_compiler/compile_js.gni")
import("//third_party/protobuf/proto_library.gni")
+import("//ui/webui/resources/tools/generate_grd.gni")
import("//ui/webui/webui_features.gni")
+import("//build/config/cast.gni")
+
# TODO(rockot): Maybe we can factor these dependencies out of //mojo. They're
# used to conditionally enable message ID scrambling in a way which is
# consistent across toolchains and which is affected by branded vs non-branded
# Chrome builds. Ideally we could create some generic knobs here that could be
# flipped elsewhere though.
import("//build/config/chrome_build.gni")
-import("//build/config/chromecast_build.gni")
import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/features.gni")
import("//build/config/nacl/config.gni")
import("//build/toolchain/kythe.gni")
import("//components/nacl/features.gni")
import("//third_party/jinja2/jinja2.gni")
+import("//third_party/ply/ply.gni")
import("//tools/ipc_fuzzer/ipc_fuzzer.gni")
declare_args() {
# Indicates whether typemapping should be supported in this build
@@ -34,21 +37,30 @@ declare_args() {
# Controls message ID scrambling behavior. If |true|, message IDs are
# scrambled (i.e. randomized based on the contents of //chrome/VERSION) on
- # non-Chrome OS desktop platforms. Set to |false| to disable message ID
- # scrambling on all platforms.
- enable_mojom_message_id_scrambling = true
+ # non-Chrome OS desktop platforms. Enabled on official builds by default.
+ # Set to |true| to enable message ID scrambling on a specific build.
+ # See also `enable_scrambled_message_ids` below for more details.
+ enable_mojom_message_id_scrambling = is_official_build
+
+ # Enables generating javascript fuzzing-related code and the bindings for the
+ # MojoLPM fuzzer targets. Off by default.
+ enable_mojom_fuzzer = false
# Enables Closure compilation of generated JS lite bindings. In environments
# where compilation is supported, any mojom target "foo" will also have a
# corresponding "foo_js_library_for_compile" target generated.
- enable_mojom_closure_compile = enable_js_type_check && optimize_webui
-
- # Enables generating Typescript bindings and compiling them to JS bindings.
- enable_typescript_bindings = false
+ if (is_chromeos_ash) {
+ enable_mojom_closure_compile = enable_js_type_check && optimize_webui
+ }
+}
- # Enables generating javascript fuzzing-related code and the bindings for the
- # MojoLPM fuzzer targets. Off by default.
- enable_mojom_fuzzer = false
+# Closure libraries are needed for mojom_closure_compile, and when
+# js_type_check is enabled on Ash.
+if (is_chromeos_ash) {
+ generate_mojom_closure_libraries =
+ enable_mojom_closure_compile || enable_js_type_check
+} else {
+ generate_mojom_closure_libraries = false
}
# NOTE: We would like to avoid scrambling message IDs where it doesn't add
@@ -69,9 +81,8 @@ declare_args() {
# lacros-chrome switches to target_os="chromeos"
enable_scrambled_message_ids =
enable_mojom_message_id_scrambling &&
- (is_mac || is_win ||
- (is_linux && !is_chromeos_ash && !is_chromecast && !is_chromeos_lacros) ||
- ((enable_nacl || is_nacl || is_nacl_nonsfi) &&
+ (is_mac || is_win || (is_linux && !is_castos) ||
+ ((enable_nacl || is_nacl) &&
(target_os != "chromeos" && !chromeos_is_browser_only)))
_mojom_tools_root = "//mojo/public/tools"
@@ -80,7 +91,9 @@ mojom_parser_script = "$_mojom_tools_root/mojom/mojom_parser.py"
mojom_parser_sources = [
"$_mojom_library_root/__init__.py",
"$_mojom_library_root/error.py",
+ "$_mojom_library_root/fileutil.py",
"$_mojom_library_root/generate/__init__.py",
+ "$_mojom_library_root/generate/check.py",
"$_mojom_library_root/generate/generator.py",
"$_mojom_library_root/generate/module.py",
"$_mojom_library_root/generate/pack.py",
@@ -88,21 +101,32 @@ mojom_parser_sources = [
"$_mojom_library_root/generate/translate.py",
"$_mojom_library_root/parse/__init__.py",
"$_mojom_library_root/parse/ast.py",
+ "$_mojom_library_root/parse/conditional_features.py",
"$_mojom_library_root/parse/lexer.py",
"$_mojom_library_root/parse/parser.py",
+ "//tools/diagnosis/crbug_1001171.py",
]
mojom_generator_root = "$_mojom_tools_root/bindings"
mojom_generator_script = "$mojom_generator_root/mojom_bindings_generator.py"
mojom_generator_sources =
mojom_parser_sources + [
+ "$mojom_generator_root/checks/__init__.py",
+ "$mojom_generator_root/checks/mojom_attributes_check.py",
+ "$mojom_generator_root/checks/mojom_definitions_check.py",
+ "$mojom_generator_root/checks/mojom_interface_feature_check.py",
+ "$mojom_generator_root/checks/mojom_restrictions_check.py",
+ "$mojom_generator_root/generators/__init__.py",
"$mojom_generator_root/generators/cpp_util.py",
"$mojom_generator_root/generators/mojom_cpp_generator.py",
"$mojom_generator_root/generators/mojom_java_generator.py",
- "$mojom_generator_root/generators/mojom_mojolpm_generator.py",
"$mojom_generator_root/generators/mojom_js_generator.py",
+ "$mojom_generator_root/generators/mojom_mojolpm_generator.py",
"$mojom_generator_root/generators/mojom_ts_generator.py",
"$mojom_generator_script",
+ "//build/action_helpers.py",
+ "//build/gn_helpers.py",
+ "//build/zip_helpers.py",
]
if (enable_scrambled_message_ids) {
@@ -243,12 +267,16 @@ if (enable_scrambled_message_ids) {
# |cpp_only| is set to true, it overrides this to prevent generation of
# Java bindings.
#
-# enable_fuzzing (optional)
+# enable_js_fuzzing (optional)
+# Enables generation of javascript fuzzing sources for the target if the
+# global build arg |enable_mojom_fuzzer| is also set to |true|.
+# Defaults to |true|. If JS fuzzing generation is enabled for a target,
+# the target will always generate JS bindings even if |cpp_only| is set to
+# |true|. See note above.
+#
+# enable_mojolpm_fuzzing (optional)
# Enables generation of fuzzing sources for the target if the global build
-# arg |enable_mojom_fuzzer| is also set to |true|. Defaults to |true|. If
-# fuzzing generation is enabled for a target, the target will always
-# generate JS bindings even if |cpp_only| is set to |true|. See note
-# above.
+# arg |enable_mojom_fuzzer| is also set to |true|. Defaults to |true|.
#
# support_lazy_serialization (optional)
# If set to |true|, generated C++ bindings will effectively prefer to
@@ -310,8 +338,15 @@ if (enable_scrambled_message_ids) {
# correct dependency order. Note that this only has an effect if
# the |enable_mojom_closure_compile| global arg is set to |true| as well.
#
-# use_typescript_sources (optional)
-# Uses the Typescript generator to generate JavaScript bindings.
+# generate_webui_js_bindings (optional)
+# Generate WebUI bindings in JavaScript rather than TypeScript. Defaults
+# to false. ChromeOS only parameter.
+#
+# generate_legacy_js_bindings (optional)
+# Generate js_data_deps target containing legacy JavaScript bindings files
+# for Blink tests and other non-WebUI users when generating TypeScript
+# bindings for WebUI. Ignored if generate_webui_js_bindings is set to
+# true.
#
# js_generate_struct_deserializers (optional)
# Generates JS deerialize methods for structs.
@@ -323,17 +358,23 @@ if (enable_scrambled_message_ids) {
# webui_module_path (optional)
# The path or URL at which modules generated by this target will be
# accessible to WebUI pages. This may either be an absolute path or
-# a full URL path starting with "chrome://resources/mojo".
+# a full URL path starting with "chrome://resources/mojo". If this path
+# is not specified, WebUI bindings will not be generated.
#
# If an absolute path, a WebUI page may only import these modules if
-# they are manually packaged and mapped independently by that page's
-# WebUIDataSource. The mapped path must match the path given here.
+# they are added to that page's data source (usually by adding the
+# modules to the mojo_files list for build_webui(), or by listing the
+# files as inputs to the page's ts_library() and/or generate_grd() build
+# steps.
#
# If this is is instead a URL string starting with
-# "chrome://resources/mojo", the generated resources must be added to
-# content_resources.grd and registered with
-# content::SharedResourcesDataSource with a corresponding path, at which
-# point they will be made available to all WebUI pages at the given URL.
+# "chrome://resources/mojo", the resulting bindings files should
+# be added to one of the lists in ui/webui/resources/mojo/BUILD.gn,
+# at which point they will be made available to all WebUI pages at the
+# given URL.
+#
+# Note: WebUI module bindings are generated in TypeScript by default,
+# unless |generate_webui_js_bindings| is specified as true.
#
# The following parameters are used to support the component build. They are
# needed so that bindings which are linked with a component can use the same
@@ -402,16 +443,41 @@ if (enable_scrambled_message_ids) {
# should be mapped in generated bindings. This is a string like
# "::base::Value" or "std::vector<::base::Value>".
#
-# move_only (optional)
-# A boolean value (default false) which indicates whether the C++
-# type is move-only. If true, generated bindings will pass the type
-# by value and use std::move() at call sites.
-#
# copyable_pass_by_value (optional)
# A boolean value (default false) which effectively indicates
# whether the C++ type is very cheap to copy. If so, generated
# bindings will pass by value but not use std::move() at call sites.
#
+# default_constructible (optional)
+# A boolean value (default true) which indicates whether the C++
+# type is default constructible. If a C++ type is not default
+# constructible (e.g. the implementor of the type prefers not to
+# publicly expose a default constructor that creates an object in an
+# invalid state), Mojo will instead construct C++ type with an
+# argument of the type `mojo::DefaultConstruct::Tag` (essentially a
+# passkey-like type specifically for this use case).
+#
+# force_serialize (optional)
+# A boolean value (default false) which disables lazy serialization
+# of the typemapped type if lazy serialization is enabled for the
+# mojom target applying this typemap.
+#
+# forward_declaration (optional)
+# A forward declaration of the C++ type, which bindings that don't
+# need the full type definition can use to reduce the size of
+# the generated code. This is a string like
+# "namespace base { class Value; }".
+#
+# hashable (optional)
+# A boolean value (default false) indicating whether the C++ type is
+# hashable. Set to true if true AND needed (i.e. you need to use the
+# type as the key of a mojom map).
+#
+# move_only (optional)
+# A boolean value (default false) which indicates whether the C++
+# type is move-only. If true, generated bindings will pass the type
+# by value and use std::move() at call sites.
+#
# nullable_is_same_type (optional)
# A boolean value (default false) which indicates that the C++ type
# has some baked-in semantic notion of a "null" state. If true, the
@@ -421,16 +487,6 @@ if (enable_scrambled_message_ids) {
# type with absl::optional, and null values are simply
# absl::nullopt.
#
-# hashable (optional)
-# A boolean value (default false) indicating whether the C++ type is
-# hashable. Set to true if true AND needed (i.e. you need to use the
-# type as the key of a mojom map).
-#
-# force_serialize (optional)
-# A boolean value (default false) which disables lazy serialization
-# of the typemapped type if lazy serialization is enabled for the
-# mojom target applying this typemap.
-#
# Additional typemap scope parameters:
#
# traits_headers (optional)
@@ -621,20 +677,26 @@ template("mojom") {
build_metadata_filename = "$target_gen_dir/$target_name.build_metadata"
build_metadata = {
}
- build_metadata.sources = rebase_path(sources_list)
+ build_metadata.sources = rebase_path(sources_list, target_gen_dir)
build_metadata.deps = []
foreach(dep, all_deps) {
dep_target_gen_dir = get_label_info(dep, "target_gen_dir")
dep_name = get_label_info(dep, "name")
build_metadata.deps +=
- [ rebase_path("$dep_target_gen_dir/$dep_name.build_metadata") ]
+ [ rebase_path("$dep_target_gen_dir/$dep_name.build_metadata",
+ target_gen_dir) ]
}
write_file(build_metadata_filename, build_metadata, "json")
- generate_fuzzing =
- (!defined(invoker.enable_fuzzing) || invoker.enable_fuzzing) &&
+ generate_js_fuzzing =
+ (!defined(invoker.enable_js_fuzzing) || invoker.enable_js_fuzzing) &&
enable_mojom_fuzzer && (!defined(invoker.testonly) || !invoker.testonly)
+ generate_mojolpm_fuzzing =
+ (!defined(invoker.enable_mojolpm_fuzzing) ||
+ invoker.enable_mojolpm_fuzzing) && enable_mojom_fuzzer &&
+ (!defined(invoker.testonly) || !invoker.testonly)
+
parser_target_name = "${target_name}__parser"
parser_deps = []
foreach(dep, all_deps) {
@@ -665,30 +727,34 @@ template("mojom") {
"is_chromeos",
"is_chromeos_ash",
]
+ } else if (is_chromeos_lacros) {
+ enabled_features += [
+ "is_chromeos",
+ "is_chromeos_lacros",
+ ]
} else if (is_fuchsia) {
enabled_features += [ "is_fuchsia" ]
} else if (is_ios) {
enabled_features += [ "is_ios" ]
- } else if (is_linux || is_chromeos_lacros) {
+ } else if (is_linux) {
enabled_features += [ "is_linux" ]
- if (is_chromeos_lacros) {
- enabled_features += [
- "is_chromeos",
- "is_chromeos_lacros",
- ]
- }
} else if (is_mac) {
enabled_features += [ "is_mac" ]
} else if (is_win) {
enabled_features += [ "is_win" ]
}
- # TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(parser_target_name) {
+ if (is_apple) {
+ enabled_features += [ "is_apple" ]
+ }
+
+ action(parser_target_name) {
+ allow_remote = true
+ custom_processor = "mojom_parser"
script = mojom_parser_script
- inputs = mojom_parser_sources + [ build_metadata_filename ]
+ inputs = mojom_parser_sources + ply_sources + [ build_metadata_filename ]
sources = sources_list
- deps = parser_deps
+ public_deps = parser_deps
outputs = []
foreach(base_path, output_file_base_paths) {
filename = get_path_info(base_path, "file")
@@ -698,31 +764,35 @@ template("mojom") {
filelist = []
foreach(source, sources_list) {
- filelist += [ rebase_path(source) ]
+ filelist += [ rebase_path(source, root_build_dir) ]
}
- response_file_contents = filelist
+
+ # Workaround for https://github.com/ninja-build/ninja/issues/1966.
+ rsp_file = "$target_gen_dir/${target_name}.rsp"
+ write_file(rsp_file, filelist)
+ inputs += [ rsp_file ]
args = [
# Resolve relative input mojom paths against both the root src dir and
# the root gen dir.
"--input-root",
- rebase_path("//."),
+ rebase_path("//.", root_build_dir),
"--input-root",
- rebase_path(root_gen_dir),
+ rebase_path(root_gen_dir, root_build_dir),
"--output-root",
- rebase_path(root_gen_dir),
+ rebase_path(root_gen_dir, root_build_dir),
- "--mojom-file-list={{response_file_name}}",
+ "--mojom-file-list=" + rebase_path(rsp_file, root_build_dir),
"--check-imports",
- rebase_path(build_metadata_filename),
+ rebase_path(build_metadata_filename, root_build_dir),
]
if (defined(invoker.input_root_override)) {
args += [
"--input-root",
- rebase_path(invoker.input_root_override),
+ rebase_path(invoker.input_root_override, root_build_dir),
]
}
@@ -738,6 +808,13 @@ template("mojom") {
"--add-module-metadata",
"webui_module_path=${invoker.webui_module_path}",
]
+ if (defined(invoker.generate_webui_js_bindings) &&
+ invoker.generate_webui_js_bindings) {
+ args += [
+ "--add-module-metadata",
+ "generate_webui_js=True",
+ ]
+ }
}
}
}
@@ -819,11 +896,12 @@ template("mojom") {
}
}
- # TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(generator_cpp_message_ids_target_name) {
+ action(generator_cpp_message_ids_target_name) {
+ allow_remote = true
script = mojom_generator_script
inputs = mojom_generator_sources + jinja2_sources
- sources = sources_list
+ sources = sources_list +
+ [ "$root_gen_dir/mojo/public/tools/bindings/cpp_templates.zip" ]
deps = [
":$parser_target_name",
"//mojo/public/tools/bindings:precompile_templates",
@@ -835,16 +913,22 @@ template("mojom") {
args = common_generator_args
filelist = []
foreach(source, sources_list) {
- filelist += [ rebase_path("$source", root_build_dir) ]
+ filelist += [ rebase_path(source, root_build_dir) ]
}
foreach(base_path, output_file_base_paths) {
+ filename = get_path_info(base_path, "file")
+ dirname = get_path_info(base_path, "dir")
+ inputs += [ "$root_gen_dir/$dirname/${filename}-module" ]
outputs += [ "$root_gen_dir/$base_path-shared-message-ids.h" ]
}
- response_file_contents = filelist
+ # Workaround for https://github.com/ninja-build/ninja/issues/1966.
+ rsp_file = "$target_gen_dir/${target_name}.rsp"
+ write_file(rsp_file, filelist)
+ inputs += [ rsp_file ]
args += [
- "--filelist={{response_file_name}}",
+ "--filelist=" + rebase_path(rsp_file, root_build_dir),
"--generate_non_variant_code",
"--generate_message_ids",
"-g",
@@ -860,12 +944,13 @@ template("mojom") {
generator_shared_target_name = "${target_name}_shared__generator"
- # TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(generator_shared_target_name) {
+ action(generator_shared_target_name) {
+ allow_remote = true
visibility = [ ":*" ]
script = mojom_generator_script
inputs = mojom_generator_sources + jinja2_sources
- sources = sources_list
+ sources = sources_list +
+ [ "$root_gen_dir/mojo/public/tools/bindings/cpp_templates.zip" ]
deps = [
":$parser_target_name",
"//mojo/public/tools/bindings:precompile_templates",
@@ -878,10 +963,16 @@ template("mojom") {
args = common_generator_args
filelist = []
foreach(source, sources_list) {
- filelist += [ rebase_path("$source", root_build_dir) ]
+ filelist += [ rebase_path(source, root_build_dir) ]
}
foreach(base_path, output_file_base_paths) {
+ # Need the mojom-module as an input to this action.
+ filename = get_path_info(base_path, "file")
+ dirname = get_path_info(base_path, "dir")
+ inputs += [ "$root_gen_dir/$dirname/${filename}-module" ]
+
outputs += [
+ "$root_gen_dir/$base_path-features.h",
"$root_gen_dir/$base_path-params-data.h",
"$root_gen_dir/$base_path-shared-internal.h",
"$root_gen_dir/$base_path-shared.cc",
@@ -889,10 +980,13 @@ template("mojom") {
]
}
- response_file_contents = filelist
+ # Workaround for https://github.com/ninja-build/ninja/issues/1966.
+ rsp_file = "$target_gen_dir/${target_name}.rsp"
+ write_file(rsp_file, filelist)
+ inputs += [ rsp_file ]
args += [
- "--filelist={{response_file_name}}",
+ "--filelist=" + rebase_path(rsp_file, root_build_dir),
"--generate_non_variant_code",
"-g",
"c++",
@@ -923,12 +1017,14 @@ template("mojom") {
if (defined(invoker.testonly)) {
testonly = invoker.testonly
}
+ configs += [ "//build/config/compiler:wexit_time_destructors" ]
deps = []
public_deps = []
if (output_file_base_paths != []) {
sources = []
foreach(base_path, output_file_base_paths) {
sources += [
+ "$root_gen_dir/$base_path-features.h",
"$root_gen_dir/$base_path-params-data.h",
"$root_gen_dir/$base_path-shared-internal.h",
"$root_gen_dir/$base_path-shared.cc",
@@ -972,7 +1068,7 @@ template("mojom") {
}
}
- if (generate_fuzzing) {
+ if (generate_mojolpm_fuzzing) {
# This block generates the proto files used for the MojoLPM fuzzer,
# and the corresponding proto targets that will be linked in the fuzzer
# targets. These are independent of the typemappings, and can be done
@@ -981,11 +1077,15 @@ template("mojom") {
generator_mojolpm_proto_target_name =
"${target_name}_mojolpm_proto_generator"
- # TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(generator_mojolpm_proto_target_name) {
+ action(generator_mojolpm_proto_target_name) {
+ allow_remote = true
script = mojom_generator_script
inputs = mojom_generator_sources + jinja2_sources
- sources = invoker.sources
+ sources =
+ invoker.sources + [
+ "$root_gen_dir/mojo/public/tools/bindings/cpp_templates.zip",
+ "$root_gen_dir/mojo/public/tools/bindings/mojolpm_templates.zip",
+ ]
deps = [
":$parser_target_name",
"//mojo/public/tools/bindings:precompile_templates",
@@ -994,15 +1094,37 @@ template("mojom") {
outputs = []
args = common_generator_args
filelist = []
- foreach(source, invoker.sources) {
- filelist += [ rebase_path("$source", root_build_dir) ]
+
+ # Split the input into generated and non-generated source files. They
+ # need to be processed separately.
+ gen_dir_path_wildcard = get_path_info("//", "gen_dir") + "/*"
+ non_gen_sources =
+ filter_exclude(invoker.sources, [ gen_dir_path_wildcard ])
+ gen_sources = filter_include(invoker.sources, [ gen_dir_path_wildcard ])
+
+ foreach(source, non_gen_sources) {
+ filelist += [ rebase_path(source, root_build_dir) ]
+ inputs += [ "$target_gen_dir/$source-module" ]
outputs += [ "$target_gen_dir/$source.mojolpm.proto" ]
}
- response_file_contents = filelist
+ foreach(source, gen_sources) {
+ filelist += [ rebase_path(source, root_build_dir) ]
+
+ # For generated files, we assume they're in the target_gen_dir or a
+ # sub-folder of it. Rebase the path so we can get the relative location.
+ source_file = rebase_path(source, target_gen_dir)
+ inputs += [ "$target_gen_dir/$source_file-module" ]
+ outputs += [ "$target_gen_dir/$source_file.mojolpm.proto" ]
+ }
+
+ # Workaround for https://github.com/ninja-build/ninja/issues/1966.
+ rsp_file = "$target_gen_dir/${target_name}.rsp"
+ write_file(rsp_file, filelist)
+ inputs += [ rsp_file ]
args += [
- "--filelist={{response_file_name}}",
+ "--filelist=" + rebase_path(rsp_file, root_build_dir),
"--generate_non_variant_code",
"-g",
"mojolpm",
@@ -1014,9 +1136,20 @@ template("mojom") {
proto_library(mojolpm_proto_target_name) {
testonly = true
generate_python = false
+
+ # Split the input into generated and non-generated source files. They
+ # need to be processed separately.
+ gen_dir_path_wildcard = get_path_info("//", "gen_dir") + "/*"
+ non_gen_sources =
+ filter_exclude(invoker.sources, [ gen_dir_path_wildcard ])
+ gen_sources = filter_include(invoker.sources, [ gen_dir_path_wildcard ])
sources = process_file_template(
- invoker.sources,
+ non_gen_sources,
[ "{{source_gen_dir}}/{{source_file_part}}.mojolpm.proto" ])
+ sources += process_file_template(
+ gen_sources,
+ [ "{{source_dir}}/{{source_file_part}}.mojolpm.proto" ])
+
import_dirs = [ "//" ]
proto_in_dir = "${root_gen_dir}"
proto_out_dir = "."
@@ -1055,7 +1188,7 @@ template("mojom") {
component_macro_suffix = ""
}
if ((!defined(invoker.disable_variants) || !invoker.disable_variants) &&
- !is_ios) {
+ use_blink) {
blink_variant = {
variant = "blink"
component_macro_suffix = "_BLINK"
@@ -1149,39 +1282,6 @@ template("mojom") {
"${bindings_configuration.component_macro_suffix}_IMPL" ]
}
- export_args = []
- export_args_overridden = false
- if (defined(bindings_configuration.for_blink) &&
- bindings_configuration.for_blink) {
- if (defined(invoker.export_class_attribute_blink)) {
- export_args_overridden = true
- export_args += [
- "--export_attribute",
- invoker.export_class_attribute_blink,
- "--export_header",
- invoker.export_header_blink,
- ]
- }
- } else if (defined(invoker.export_class_attribute)) {
- export_args_overridden = true
- export_args += [
- "--export_attribute",
- invoker.export_class_attribute,
- "--export_header",
- invoker.export_header,
- ]
- }
-
- if (!export_args_overridden && defined(invoker.component_macro_prefix)) {
- export_args += [
- "--export_attribute",
- "COMPONENT_EXPORT(${invoker.component_macro_prefix}" +
- "${bindings_configuration.component_macro_suffix})",
- "--export_header",
- "base/component_export.h",
- ]
- }
-
generate_java = false
if (!cpp_only && defined(invoker.generate_java)) {
generate_java = invoker.generate_java
@@ -1190,6 +1290,38 @@ template("mojom") {
type_mappings_path =
"$target_gen_dir/${target_name}${variant_suffix}__type_mappings"
if (sources_list != []) {
+ export_args = []
+ export_args_overridden = false
+ if (defined(bindings_configuration.for_blink) &&
+ bindings_configuration.for_blink) {
+ if (defined(invoker.export_class_attribute_blink)) {
+ export_args_overridden = true
+ export_args += [
+ "--export_attribute",
+ invoker.export_class_attribute_blink,
+ "--export_header",
+ invoker.export_header_blink,
+ ]
+ }
+ } else if (defined(invoker.export_class_attribute)) {
+ export_args_overridden = true
+ export_args += [
+ "--export_attribute",
+ invoker.export_class_attribute,
+ "--export_header",
+ invoker.export_header,
+ ]
+ }
+ if (!export_args_overridden && defined(invoker.component_macro_prefix)) {
+ export_args += [
+ "--export_attribute",
+ "COMPONENT_EXPORT(${invoker.component_macro_prefix}" +
+ "${bindings_configuration.component_macro_suffix})",
+ "--export_header",
+ "base/component_export.h",
+ ]
+ }
+
generator_cpp_output_suffixes = []
variant_dash_suffix = ""
if (defined(variant)) {
@@ -1198,7 +1330,6 @@ template("mojom") {
generator_cpp_output_suffixes += [
"${variant_dash_suffix}-forward.h",
"${variant_dash_suffix}-import-headers.h",
- "${variant_dash_suffix}-test-utils.cc",
"${variant_dash_suffix}-test-utils.h",
"${variant_dash_suffix}.cc",
"${variant_dash_suffix}.h",
@@ -1207,16 +1338,28 @@ template("mojom") {
generator_target_name = "${target_name}${variant_suffix}__generator"
# TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(generator_target_name) {
+ action(generator_target_name) {
+ allow_remote = true
visibility = [ ":*" ]
script = mojom_generator_script
inputs = mojom_generator_sources + jinja2_sources
- sources = sources_list
+ sources =
+ sources_list + [
+ "$root_gen_dir/mojo/public/tools/bindings/cpp_templates.zip",
+ type_mappings_path,
+ ]
+ if (generate_mojolpm_fuzzing &&
+ !defined(bindings_configuration.variant)) {
+ sources += [
+ "$root_gen_dir/mojo/public/tools/bindings/mojolpm_templates.zip",
+ ]
+ }
deps = [
":$parser_target_name",
":$type_mappings_target_name",
"//mojo/public/tools/bindings:precompile_templates",
]
+
if (defined(invoker.parser_deps)) {
deps += invoker.parser_deps
}
@@ -1224,18 +1367,22 @@ template("mojom") {
args = common_generator_args + export_args
filelist = []
foreach(source, sources_list) {
- filelist += [ rebase_path("$source", root_build_dir) ]
+ filelist += [ rebase_path(source, root_build_dir) ]
}
foreach(base_path, output_file_base_paths) {
+ filename = get_path_info(base_path, "file")
+ dirname = get_path_info(base_path, "dir")
+ inputs += [ "$root_gen_dir/$dirname/${filename}-module" ]
+
outputs += [
"$root_gen_dir/${base_path}${variant_dash_suffix}-forward.h",
"$root_gen_dir/${base_path}${variant_dash_suffix}-import-headers.h",
- "$root_gen_dir/${base_path}${variant_dash_suffix}-test-utils.cc",
"$root_gen_dir/${base_path}${variant_dash_suffix}-test-utils.h",
"$root_gen_dir/${base_path}${variant_dash_suffix}.cc",
"$root_gen_dir/${base_path}${variant_dash_suffix}.h",
]
- if (generate_fuzzing && !defined(bindings_configuration.variant)) {
+ if (generate_mojolpm_fuzzing &&
+ !defined(bindings_configuration.variant)) {
outputs += [
"$root_gen_dir/${base_path}${variant_dash_suffix}-mojolpm.cc",
"$root_gen_dir/${base_path}${variant_dash_suffix}-mojolpm.h",
@@ -1243,14 +1390,17 @@ template("mojom") {
}
}
- response_file_contents = filelist
-
+ # Workaround for https://github.com/ninja-build/ninja/issues/1966.
+ rsp_file = "$target_gen_dir/${target_name}.rsp"
+ write_file(rsp_file, filelist)
+ inputs += [ rsp_file ]
args += [
- "--filelist={{response_file_name}}",
+ "--filelist=" + rebase_path("$rsp_file", root_build_dir),
"-g",
]
- if (generate_fuzzing && !defined(bindings_configuration.variant)) {
+ if (generate_mojolpm_fuzzing &&
+ !defined(bindings_configuration.variant)) {
args += [ "c++,mojolpm" ]
} else {
args += [ "c++" ]
@@ -1294,6 +1444,8 @@ template("mojom") {
"--extra_cpp_template_paths",
rebase_path(extra_cpp_template, root_build_dir),
]
+ inputs += [ extra_cpp_template ]
+
assert(
get_path_info(extra_cpp_template, "extension") == "tmpl",
"--extra_cpp_template_paths only accepts template files ending in extension .tmpl")
@@ -1306,62 +1458,6 @@ template("mojom") {
}
}
- if (generate_fuzzing && !defined(variant)) {
- # This block contains the C++ targets for the MojoLPM fuzzer, we need to
- # do this here so that we can use the typemap configuration for the
- # empty-variant Mojo target.
-
- mojolpm_target_name = "${target_name}_mojolpm"
- mojolpm_generator_target_name = "${target_name}__generator"
- source_set(mojolpm_target_name) {
- # There are still a few missing header dependencies between mojo targets
- # with typemaps and the dependencies of their typemap headers. It would
- # be good to enable include checking for these in the future though.
- check_includes = false
- testonly = true
- if (defined(invoker.sources)) {
- sources = process_file_template(
- invoker.sources,
- [
- "{{source_gen_dir}}/{{source_file_part}}-mojolpm.cc",
- "{{source_gen_dir}}/{{source_file_part}}-mojolpm.h",
- ])
- deps = []
- } else {
- sources = []
- deps = []
- }
-
- public_deps = [
- ":$generator_shared_target_name",
-
- # NB: hardcoded dependency on the no-variant variant generator, since
- # mojolpm only uses the no-variant type.
- ":$mojolpm_generator_target_name",
- ":$mojolpm_proto_target_name",
- "//base",
- "//mojo/public/tools/fuzzers:mojolpm",
- ]
-
- foreach(d, all_deps) {
- # Resolve the name, so that a target //mojo/something becomes
- # //mojo/something:something and we can append variant_suffix to
- # get the cpp dependency name.
- full_name = get_label_info("$d", "label_no_toolchain")
- public_deps += [ "${full_name}_mojolpm" ]
- }
-
- foreach(config, cpp_typemap_configs) {
- if (defined(config.traits_deps)) {
- deps += config.traits_deps
- }
- if (defined(config.traits_public_deps)) {
- public_deps += config.traits_public_deps
- }
- }
- }
- }
-
# Write the typemapping configuration for this target out to a file to be
# validated by a Python script. This helps catch mistakes that can't
# be caught by logic in GN.
@@ -1389,20 +1485,20 @@ template("mojom") {
write_file(_typemap_config_filename, _rebased_typemap_configs, "json")
_mojom_target_name = target_name
- # TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(_typemap_validator_target_name) {
+ action(_typemap_validator_target_name) {
+ allow_remote = true
script = "$mojom_generator_root/validate_typemap_config.py"
inputs = [ _typemap_config_filename ]
outputs = [ _typemap_stamp_filename ]
args = [
get_label_info(_mojom_target_name, "label_no_toolchain"),
- rebase_path(_typemap_config_filename),
- rebase_path(_typemap_stamp_filename),
+ rebase_path(_typemap_config_filename, root_build_dir),
+ rebase_path(_typemap_stamp_filename, root_build_dir),
]
}
- # TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(type_mappings_target_name) {
+ action(type_mappings_target_name) {
+ allow_remote = true
inputs =
mojom_generator_sources + jinja2_sources + [ _typemap_stamp_filename ]
outputs = [ type_mappings_path ]
@@ -1413,6 +1509,7 @@ template("mojom") {
rebase_path(type_mappings_path, root_build_dir),
]
+ sources = []
foreach(d, all_deps) {
name = get_label_info(d, "label_no_toolchain")
toolchain = get_label_info(d, "toolchain")
@@ -1422,12 +1519,11 @@ template("mojom") {
dependency_output_dir =
get_label_info(dependency_output, "target_gen_dir")
dependency_name = get_label_info(dependency_output, "name")
- dependency_path =
- rebase_path("$dependency_output_dir/${dependency_name}",
- root_build_dir)
+ dependency_path = "$dependency_output_dir/${dependency_name}"
+ sources += [ dependency_path ]
args += [
"--dependency",
- dependency_path,
+ rebase_path(dependency_path, root_build_dir),
]
}
@@ -1485,11 +1581,15 @@ template("mojom") {
if (defined(output_name_override)) {
output_name = output_name_override
}
- visibility = output_visibility + [ ":$output_target_name" ]
+ visibility = output_visibility + [
+ ":$output_target_name",
+ ":${target_name}_mojolpm",
+ ]
if (defined(invoker.testonly)) {
testonly = invoker.testonly
}
defines = export_defines
+ configs += [ "//build/config/compiler:wexit_time_destructors" ]
configs += extra_configs
if (output_file_base_paths != []) {
sources = []
@@ -1578,13 +1678,81 @@ template("mojom") {
}
}
+ if (generate_mojolpm_fuzzing && !defined(variant)) {
+ # This block contains the C++ targets for the MojoLPM fuzzer, we need to
+ # do this here so that we can use the typemap configuration for the
+ # empty-variant Mojo target.
+
+ mojolpm_target_name = "${target_name}_mojolpm"
+ mojolpm_generator_target_name = "${target_name}__generator"
+ source_set(mojolpm_target_name) {
+ # There are still a few missing header dependencies between mojo targets
+ # with typemaps and the dependencies of their typemap headers. It would
+ # be good to enable include checking for these in the future though.
+ check_includes = false
+ testonly = true
+ if (defined(invoker.sources)) {
+ # Split the input into generated and non-generated source files. They
+ # need to be processed separately.
+ gen_dir_path_wildcard = get_path_info("//", "gen_dir") + "/*"
+ non_gen_sources =
+ filter_exclude(invoker.sources, [ gen_dir_path_wildcard ])
+ gen_sources =
+ filter_include(invoker.sources, [ gen_dir_path_wildcard ])
+ sources = process_file_template(
+ non_gen_sources,
+ [
+ "{{source_gen_dir}}/{{source_file_part}}-mojolpm.cc",
+ "{{source_gen_dir}}/{{source_file_part}}-mojolpm.h",
+ ])
+ sources += process_file_template(
+ gen_sources,
+ [
+ "{{source_dir}}/{{source_file_part}}-mojolpm.cc",
+ "{{source_dir}}/{{source_file_part}}-mojolpm.h",
+ ])
+ deps = [ ":$output_target_name" ]
+ } else {
+ sources = []
+ deps = []
+ }
+
+ public_deps = [
+ ":$generator_shared_target_name",
+
+ # NB: hardcoded dependency on the no-variant variant generator, since
+ # mojolpm only uses the no-variant type.
+ ":$mojolpm_generator_target_name",
+ ":$mojolpm_proto_target_name",
+ "//base",
+ "//mojo/public/tools/fuzzers:mojolpm",
+ ]
+
+ foreach(d, all_deps) {
+ # Resolve the name, so that a target //mojo/something becomes
+ # //mojo/something:something and we can append variant_suffix to
+ # get the cpp dependency name.
+ full_name = get_label_info("$d", "label_no_toolchain")
+ public_deps += [ "${full_name}_mojolpm" ]
+ }
+
+ foreach(config, cpp_typemap_configs) {
+ if (defined(config.traits_deps)) {
+ deps += config.traits_deps
+ }
+ if (defined(config.traits_public_deps)) {
+ public_deps += config.traits_public_deps
+ }
+ }
+ }
+ }
+
if (generate_java && is_android) {
import("//build/config/android/rules.gni")
java_generator_target_name = target_name + "_java__generator"
if (sources_list != []) {
- # TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(java_generator_target_name) {
+ action(java_generator_target_name) {
script = mojom_generator_script
inputs = mojom_generator_sources + jinja2_sources
sources = sources_list
@@ -1597,7 +1765,7 @@ template("mojom") {
args = common_generator_args
filelist = []
foreach(source, sources_list) {
- filelist += [ rebase_path("$source", root_build_dir) ]
+ filelist += [ rebase_path(source, root_build_dir) ]
}
foreach(base_path, output_file_base_paths) {
outputs += [ "$root_gen_dir/$base_path.srcjar" ]
@@ -1624,8 +1792,7 @@ template("mojom") {
java_srcjar_target_name = target_name + "_java_sources"
- # TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(java_srcjar_target_name) {
+ action(java_srcjar_target_name) {
script = "//build/android/gyp/zip.py"
inputs = []
if (output_file_base_paths != []) {
@@ -1651,7 +1818,6 @@ template("mojom") {
android_library(java_target_name) {
forward_variables_from(invoker, [ "enable_bytecode_checks" ])
deps = [
- "//base:base_java",
"//mojo/public/java:bindings_java",
"//mojo/public/java:system_java",
"//third_party/androidx:androidx_annotation_annotation_java",
@@ -1673,21 +1839,36 @@ template("mojom") {
}
}
- use_typescript_for_target =
- enable_typescript_bindings && defined(invoker.use_typescript_sources) &&
- invoker.use_typescript_sources
+ if (defined(invoker.generate_webui_js_bindings)) {
+ assert(is_chromeos_ash,
+ "generate_webui_js_bindings can only be used on ChromeOS Ash")
+ assert(invoker.generate_webui_js_bindings,
+ "generate_webui_js_bindings should be set to true or removed")
+ }
+
+ use_typescript_for_target = defined(invoker.webui_module_path) &&
+ !defined(invoker.generate_webui_js_bindings)
- if (!use_typescript_for_target && defined(invoker.use_typescript_sources)) {
- not_needed(invoker, [ "use_typescript_sources" ])
+ generate_legacy_js = !use_typescript_for_target ||
+ (defined(invoker.generate_legacy_js_bindings) &&
+ invoker.generate_legacy_js_bindings)
+
+ if (!use_typescript_for_target &&
+ defined(invoker.generate_legacy_js_bindings)) {
+ not_needed(invoker, [ "generate_legacy_js_bindings" ])
}
- if ((generate_fuzzing || !defined(invoker.cpp_only) || !invoker.cpp_only) &&
- !use_typescript_for_target) {
+ # Targets needed by both TS and JS bindings targets. These are needed
+ # unconditionally for JS bindings targets, and are needed for TS bindings
+ # targets when generate_legacy_js_bindings is true. This option is provided
+ # since the legacy bindings are needed by Blink tests and non-Chromium users,
+ # which are not expected to migrate to modules or TypeScript.
+ if (generate_legacy_js && (generate_js_fuzzing ||
+ !defined(invoker.cpp_only) || !invoker.cpp_only)) {
if (sources_list != []) {
generator_js_target_name = "${target_name}_js__generator"
- # TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(generator_js_target_name) {
+ action(generator_js_target_name) {
script = mojom_generator_script
inputs = mojom_generator_sources + jinja2_sources
sources = sources_list
@@ -1702,19 +1883,18 @@ template("mojom") {
args = common_generator_args
filelist = []
foreach(source, sources_list) {
- filelist += [ rebase_path("$source", root_build_dir) ]
+ filelist += [ rebase_path(source, root_build_dir) ]
}
foreach(base_path, output_file_base_paths) {
outputs += [
"$root_gen_dir/$base_path.js",
- "$root_gen_dir/$base_path.externs.js",
"$root_gen_dir/$base_path.m.js",
"$root_gen_dir/$base_path-lite.js",
- "$root_gen_dir/$base_path.html",
"$root_gen_dir/$base_path-lite-for-compile.js",
]
- if (defined(invoker.webui_module_path)) {
+ if (defined(invoker.webui_module_path) &&
+ !use_typescript_for_target) {
outputs += [ "$root_gen_dir/mojom-webui/$base_path-webui.js" ]
}
}
@@ -1725,7 +1905,6 @@ template("mojom") {
"--filelist={{response_file_name}}",
"-g",
"javascript",
- "--js_bindings_mode=new",
]
if (defined(invoker.js_generate_struct_deserializers) &&
@@ -1739,7 +1918,7 @@ template("mojom") {
args += message_scrambling_args
}
- if (generate_fuzzing) {
+ if (generate_js_fuzzing) {
args += [ "--generate_fuzzing" ]
}
}
@@ -1783,31 +1962,13 @@ template("mojom") {
data_deps += [ "${full_name}_js_data_deps" ]
}
}
+ }
- js_library_target_name = "${target_name}_js_library"
- if (sources_list != []) {
- js_library(js_library_target_name) {
- extra_public_deps = [ ":$generator_js_target_name" ]
- sources = []
- foreach(base_path, output_file_base_paths) {
- sources += [ "$root_gen_dir/${base_path}-lite.js" ]
- }
- externs_list = [
- "${externs_path}/mojo_core.js",
- "${externs_path}/pending.js",
- ]
-
- deps = []
- foreach(d, all_deps) {
- full_name = get_label_info(d, "label_no_toolchain")
- deps += [ "${full_name}_js_library" ]
- }
- }
- } else {
- group(js_library_target_name) {
- }
- }
-
+ # js_library() closure compiler targets, primarily used on ChromeOS. Only
+ # generate these targets if the mojom target is not C++ only and is not using
+ # TypeScript.
+ if (generate_mojom_closure_libraries &&
+ (!defined(invoker.cpp_only) || !invoker.cpp_only) && generate_legacy_js) {
js_library_for_compile_target_name = "${target_name}_js_library_for_compile"
if (sources_list != []) {
js_library(js_library_for_compile_target_name) {
@@ -1834,35 +1995,9 @@ template("mojom") {
}
}
- js_modules_target_name = "${target_name}_js_modules"
- if (sources_list != []) {
- js_library(js_modules_target_name) {
- extra_public_deps = [ ":$generator_js_target_name" ]
- sources = []
- foreach(base_path, output_file_base_paths) {
- sources += [ "$root_gen_dir/${base_path}.m.js" ]
- }
- externs_list = [
- "${externs_path}/mojo_core.js",
- "${externs_path}/pending.js",
- ]
- if (defined(invoker.disallow_native_types) &&
- invoker.disallow_native_types) {
- deps = []
- } else {
- deps = [ "//mojo/public/js:bindings_uncompiled" ]
- }
- foreach(d, all_deps) {
- full_name = get_label_info(d, "label_no_toolchain")
- deps += [ "${full_name}_js_modules" ]
- }
- }
- } else {
- group(js_modules_target_name) {
- }
- }
-
- if (defined(invoker.webui_module_path)) {
+ # WebUI specific closure targets, not needed by targets that are generating
+ # TypeScript WebUI bindings or by legacy-only targets.
+ if (defined(invoker.webui_module_path) && !use_typescript_for_target) {
webui_js_target_name = "${target_name}_webui_js"
if (sources_list != []) {
js_library(webui_js_target_name) {
@@ -1890,46 +2025,38 @@ template("mojom") {
group(webui_js_target_name) {
}
}
- }
- }
- if ((generate_fuzzing || !defined(invoker.cpp_only) || !invoker.cpp_only) &&
- use_typescript_for_target) {
- generator_js_target_names = []
- source_filelist = []
- foreach(source, sources_list) {
- source_filelist += [ rebase_path("$source", root_build_dir) ]
- }
- dependency_types = [
- {
- name = "regular"
- ts_extension = ".ts"
- js_extension = ".js"
- },
- {
- name = "es_modules"
- ts_extension = ".m.ts"
- js_extension = ".m.js"
- },
- ]
+ webui_grdp_target_name = "${target_name}_webui_grdp"
+ out_grd = "$target_gen_dir/${target_name}_webui_resources.grdp"
+ grd_prefix = "${target_name}_webui"
+ generate_grd(webui_grdp_target_name) {
+ grd_prefix = grd_prefix
+ out_grd = out_grd
- foreach(dependency_type, dependency_types) {
- ts_outputs = []
- js_outputs = []
+ deps = [ ":$webui_js_target_name" ]
- foreach(base_path, output_file_base_paths) {
- ts_outputs +=
- [ "$root_gen_dir/$base_path-lite${dependency_type.ts_extension}" ]
- js_outputs +=
- [ "$root_gen_dir/$base_path-lite${dependency_type.js_extension}" ]
+ input_files = []
+ foreach(base_path, output_file_base_paths) {
+ input_files += [ "${base_path}-webui.js" ]
+ }
+
+ input_files_base_dir =
+ rebase_path("$root_gen_dir/mojom-webui", "$root_build_dir")
+ }
+ }
+ }
+ if ((generate_js_fuzzing || !defined(invoker.cpp_only) ||
+ !invoker.cpp_only) && use_typescript_for_target) {
+ if (sources_list != []) {
+ source_filelist = []
+ foreach(source, sources_list) {
+ source_filelist += [ rebase_path(source, root_build_dir) ]
}
# Generate Typescript bindings.
- generator_ts_target_name =
- "${target_name}_${dependency_type.name}__ts__generator"
+ generator_ts_target_name = "${target_name}_ts__generator"
- # TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(generator_ts_target_name) {
+ action(generator_ts_target_name) {
script = mojom_generator_script
inputs = mojom_generator_sources + jinja2_sources
sources = sources_list
@@ -1938,7 +2065,10 @@ template("mojom") {
"//mojo/public/tools/bindings:precompile_templates",
]
- outputs = ts_outputs
+ outputs = []
+ foreach(base_path, output_file_base_paths) {
+ outputs += [ "$root_gen_dir/$base_path-webui.ts" ]
+ }
args = common_generator_args
response_file_contents = source_filelist
@@ -1948,97 +2078,20 @@ template("mojom") {
"typescript",
]
- if (dependency_type.name == "es_modules") {
- args += [ "--ts_use_es_modules" ]
- }
-
- # TODO(crbug.com/1007587): Support scramble_message_ids.
- # TODO(crbug.com/1007591): Support generate_fuzzing.
- }
-
- # Create tsconfig.json for the generated Typescript.
- tsconfig_filename =
- "$target_gen_dir/$target_name-${dependency_type.name}-tsconfig.json"
- tsconfig = {
- }
- tsconfig.compilerOptions = {
- composite = true
- target = "es6"
- module = "es6"
- lib = [
- "es6",
- "esnext.bigint",
- ]
- strict = true
- }
- tsconfig.files = []
- foreach(base_path, output_file_base_paths) {
- tsconfig.files += [ rebase_path(
- "$root_gen_dir/$base_path-lite${dependency_type.ts_extension}",
- target_gen_dir,
- root_gen_dir) ]
- }
- tsconfig.references = []
-
- # Get tsconfigs for deps.
- foreach(d, all_deps) {
- dep_target_gen_dir = rebase_path(get_label_info(d, "target_gen_dir"))
- dep_name = get_label_info(d, "name")
- reference = {
- }
- reference.path = "$dep_target_gen_dir/$dep_name-${dependency_type.name}-tsconfig.json"
- tsconfig.references += [ reference ]
- }
- write_file(tsconfig_filename, tsconfig, "json")
-
- # Compile previously generated Typescript to Javascript.
- generator_js_target_name =
- "${target_name}_${dependency_type.name}__js__generator"
- generator_js_target_names += [ generator_js_target_name ]
-
- # TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds.
- python2_action(generator_js_target_name) {
- script = "$mojom_generator_root/compile_typescript.py"
- sources = ts_outputs
- outputs = js_outputs
- public_deps = [ ":$generator_ts_target_name" ]
- foreach(d, all_deps) {
- full_name = get_label_info(d, "label_no_toolchain")
- public_deps +=
- [ "${full_name}_${dependency_type.name}__js__generator" ]
+ if (!defined(invoker.scramble_message_ids) ||
+ invoker.scramble_message_ids) {
+ inputs += message_scrambling_inputs
+ args += message_scrambling_args
}
- absolute_tsconfig_path =
- rebase_path(tsconfig_filename, "", target_gen_dir)
- args = [ "--tsconfig_path=$absolute_tsconfig_path" ]
- }
- }
-
- js_target_name = target_name + "_js"
- group(js_target_name) {
- public_deps = []
- if (sources_list != []) {
- foreach(generator_js_target_name, generator_js_target_names) {
- public_deps += [ ":$generator_js_target_name" ]
+ if (defined(invoker.js_generate_struct_deserializers) &&
+ invoker.js_generate_struct_deserializers) {
+ args += [ "--js_generate_struct_deserializers" ]
}
- }
- foreach(d, all_deps) {
- full_name = get_label_info(d, "label_no_toolchain")
- public_deps += [ "${full_name}_js" ]
- }
- }
-
- group(js_data_deps_target_name) {
- data = js_outputs
- deps = []
- foreach(generator_js_target_name, generator_js_target_names) {
- deps += [ ":$generator_js_target_name" ]
- }
- data_deps = []
- foreach(d, all_deps) {
- full_name = get_label_info(d, "label_no_toolchain")
- data_deps += [ "${full_name}_js_data_deps" ]
+ # TODO(crbug.com/1007587): Support scramble_message_ids if above is
+ # insufficient.
+ # TODO(crbug.com/1007591): Support generate_fuzzing.
}
}
}