Commit c65456bf authored by Sami Kyostila's avatar Sami Kyostila Committed by Commit Bot

tracing: Initialize track events conditionally

If V8 is running in a context where Perfetto hasn't been initialized
(e.g., as part of mksnapshot), don't try to initialize track events
either.

Since perfetto::Tracing::IsInitialized() was only added recently, we
also roll Perfetto to the latest revision. This also requires updating
the proto_library GN template together with the underlying libprotobuf
dependency.

Bug: chromium:1006541
Change-Id: Icec626b7ed78264a81f1a80d73d60be3bde0d908
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2632590
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Auto-Submit: Sami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72130}
parent a75b129a
......@@ -5473,28 +5473,77 @@ if (!build_with_chromium && v8_use_perfetto) {
sources = [
"third_party/protobuf/src/google/protobuf/any_lite.cc",
"third_party/protobuf/src/google/protobuf/arena.cc",
"third_party/protobuf/src/google/protobuf/arena.h",
"third_party/protobuf/src/google/protobuf/arena_impl.h",
"third_party/protobuf/src/google/protobuf/arenastring.h",
"third_party/protobuf/src/google/protobuf/extension_set.cc",
"third_party/protobuf/src/google/protobuf/extension_set.h",
"third_party/protobuf/src/google/protobuf/generated_enum_util.cc",
"third_party/protobuf/src/google/protobuf/generated_enum_util.h",
"third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.cc",
"third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.h",
"third_party/protobuf/src/google/protobuf/generated_message_util.cc",
"third_party/protobuf/src/google/protobuf/generated_message_util.h",
"third_party/protobuf/src/google/protobuf/has_bits.h",
"third_party/protobuf/src/google/protobuf/implicit_weak_message.cc",
"third_party/protobuf/src/google/protobuf/implicit_weak_message.h",
"third_party/protobuf/src/google/protobuf/inlined_string_field.h",
"third_party/protobuf/src/google/protobuf/io/coded_stream.cc",
"third_party/protobuf/src/google/protobuf/io/coded_stream.h",
"third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h",
"third_party/protobuf/src/google/protobuf/io/io_win32.cc",
"third_party/protobuf/src/google/protobuf/io/io_win32.h",
"third_party/protobuf/src/google/protobuf/io/strtod.cc",
"third_party/protobuf/src/google/protobuf/io/strtod.h",
"third_party/protobuf/src/google/protobuf/io/zero_copy_stream.cc",
"third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h",
"third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc",
"third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h",
"third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
"third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h",
"third_party/protobuf/src/google/protobuf/map.h",
"third_party/protobuf/src/google/protobuf/map_entry_lite.h",
"third_party/protobuf/src/google/protobuf/map_field_lite.h",
"third_party/protobuf/src/google/protobuf/map_type_handler.h",
"third_party/protobuf/src/google/protobuf/message_lite.cc",
"third_party/protobuf/src/google/protobuf/message_lite.h",
"third_party/protobuf/src/google/protobuf/repeated_field.cc",
"third_party/protobuf/src/google/protobuf/repeated_field.h",
"third_party/protobuf/src/google/protobuf/stubs/bytestream.cc",
"third_party/protobuf/src/google/protobuf/stubs/bytestream.h",
"third_party/protobuf/src/google/protobuf/stubs/callback.h",
"third_party/protobuf/src/google/protobuf/stubs/casts.h",
"third_party/protobuf/src/google/protobuf/stubs/common.cc",
"third_party/protobuf/src/google/protobuf/stubs/common.h",
"third_party/protobuf/src/google/protobuf/stubs/fastmem.h",
"third_party/protobuf/src/google/protobuf/stubs/hash.h",
"third_party/protobuf/src/google/protobuf/stubs/int128.cc",
"third_party/protobuf/src/google/protobuf/stubs/io_win32.cc",
"third_party/protobuf/src/google/protobuf/stubs/int128.h",
"third_party/protobuf/src/google/protobuf/stubs/logging.h",
"third_party/protobuf/src/google/protobuf/stubs/macros.h",
"third_party/protobuf/src/google/protobuf/stubs/map_util.h",
"third_party/protobuf/src/google/protobuf/stubs/mutex.h",
"third_party/protobuf/src/google/protobuf/stubs/once.h",
"third_party/protobuf/src/google/protobuf/stubs/platform_macros.h",
"third_party/protobuf/src/google/protobuf/stubs/port.h",
"third_party/protobuf/src/google/protobuf/stubs/status.cc",
"third_party/protobuf/src/google/protobuf/stubs/status.h",
"third_party/protobuf/src/google/protobuf/stubs/status_macros.h",
"third_party/protobuf/src/google/protobuf/stubs/statusor.cc",
"third_party/protobuf/src/google/protobuf/stubs/statusor.h",
"third_party/protobuf/src/google/protobuf/stubs/stl_util.h",
"third_party/protobuf/src/google/protobuf/stubs/stringpiece.cc",
"third_party/protobuf/src/google/protobuf/stubs/stringpiece.h",
"third_party/protobuf/src/google/protobuf/stubs/stringprintf.cc",
"third_party/protobuf/src/google/protobuf/stubs/stringprintf.h",
"third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc",
"third_party/protobuf/src/google/protobuf/stubs/strutil.cc",
"third_party/protobuf/src/google/protobuf/stubs/strutil.h",
"third_party/protobuf/src/google/protobuf/stubs/template_util.h",
"third_party/protobuf/src/google/protobuf/stubs/time.cc",
"third_party/protobuf/src/google/protobuf/stubs/time.h",
"third_party/protobuf/src/google/protobuf/wire_format_lite.cc",
"third_party/protobuf/src/google/protobuf/wire_format_lite.h",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
......@@ -5512,59 +5561,119 @@ if (!build_with_chromium && v8_use_perfetto) {
deps = [ ":protobuf_lite" ]
sources = [
"third_party/protobuf/src/google/protobuf/any.cc",
"third_party/protobuf/src/google/protobuf/any.h",
"third_party/protobuf/src/google/protobuf/any.pb.cc",
"third_party/protobuf/src/google/protobuf/any.pb.h",
"third_party/protobuf/src/google/protobuf/api.pb.cc",
"third_party/protobuf/src/google/protobuf/api.pb.h",
"third_party/protobuf/src/google/protobuf/compiler/importer.cc",
"third_party/protobuf/src/google/protobuf/compiler/importer.h",
"third_party/protobuf/src/google/protobuf/compiler/parser.cc",
"third_party/protobuf/src/google/protobuf/compiler/parser.h",
"third_party/protobuf/src/google/protobuf/descriptor.cc",
"third_party/protobuf/src/google/protobuf/descriptor.h",
"third_party/protobuf/src/google/protobuf/descriptor.pb.cc",
"third_party/protobuf/src/google/protobuf/descriptor.pb.h",
"third_party/protobuf/src/google/protobuf/descriptor_database.cc",
"third_party/protobuf/src/google/protobuf/descriptor_database.h",
"third_party/protobuf/src/google/protobuf/duration.pb.cc",
"third_party/protobuf/src/google/protobuf/duration.pb.h",
"third_party/protobuf/src/google/protobuf/dynamic_message.cc",
"third_party/protobuf/src/google/protobuf/dynamic_message.h",
"third_party/protobuf/src/google/protobuf/empty.pb.cc",
"third_party/protobuf/src/google/protobuf/empty.pb.h",
"third_party/protobuf/src/google/protobuf/extension_set_heavy.cc",
"third_party/protobuf/src/google/protobuf/field_mask.pb.cc",
"third_party/protobuf/src/google/protobuf/field_mask.pb.h",
"third_party/protobuf/src/google/protobuf/generated_enum_reflection.h",
"third_party/protobuf/src/google/protobuf/generated_message_reflection.cc",
"third_party/protobuf/src/google/protobuf/generated_message_table_driven.cc",
"third_party/protobuf/src/google/protobuf/generated_message_reflection.h",
"third_party/protobuf/src/google/protobuf/io/gzip_stream.cc",
"third_party/protobuf/src/google/protobuf/io/gzip_stream.h",
"third_party/protobuf/src/google/protobuf/io/printer.cc",
"third_party/protobuf/src/google/protobuf/io/printer.h",
"third_party/protobuf/src/google/protobuf/io/tokenizer.cc",
"third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc",
"third_party/protobuf/src/google/protobuf/io/tokenizer.h",
"third_party/protobuf/src/google/protobuf/map_entry.h",
"third_party/protobuf/src/google/protobuf/map_field.cc",
"third_party/protobuf/src/google/protobuf/map_field.h",
"third_party/protobuf/src/google/protobuf/map_field_inl.h",
"third_party/protobuf/src/google/protobuf/message.cc",
"third_party/protobuf/src/google/protobuf/message.h",
"third_party/protobuf/src/google/protobuf/metadata.h",
"third_party/protobuf/src/google/protobuf/reflection.h",
"third_party/protobuf/src/google/protobuf/reflection_internal.h",
"third_party/protobuf/src/google/protobuf/reflection_ops.cc",
"third_party/protobuf/src/google/protobuf/reflection_ops.h",
"third_party/protobuf/src/google/protobuf/service.cc",
"third_party/protobuf/src/google/protobuf/service.h",
"third_party/protobuf/src/google/protobuf/source_context.pb.cc",
"third_party/protobuf/src/google/protobuf/source_context.pb.h",
"third_party/protobuf/src/google/protobuf/struct.pb.cc",
"third_party/protobuf/src/google/protobuf/struct.pb.h",
"third_party/protobuf/src/google/protobuf/stubs/mathlimits.cc",
"third_party/protobuf/src/google/protobuf/stubs/mathlimits.h",
"third_party/protobuf/src/google/protobuf/stubs/mathutil.h",
"third_party/protobuf/src/google/protobuf/stubs/substitute.cc",
"third_party/protobuf/src/google/protobuf/stubs/substitute.h",
"third_party/protobuf/src/google/protobuf/text_format.cc",
"third_party/protobuf/src/google/protobuf/text_format.h",
"third_party/protobuf/src/google/protobuf/timestamp.pb.cc",
"third_party/protobuf/src/google/protobuf/timestamp.pb.h",
"third_party/protobuf/src/google/protobuf/type.pb.cc",
"third_party/protobuf/src/google/protobuf/type.pb.h",
"third_party/protobuf/src/google/protobuf/unknown_field_set.cc",
"third_party/protobuf/src/google/protobuf/util/delimited_message_util.cc",
"third_party/protobuf/src/google/protobuf/unknown_field_set.h",
"third_party/protobuf/src/google/protobuf/util/field_comparator.cc",
"third_party/protobuf/src/google/protobuf/util/field_comparator.h",
"third_party/protobuf/src/google/protobuf/util/field_mask_util.cc",
"third_party/protobuf/src/google/protobuf/util/field_mask_util.h",
"third_party/protobuf/src/google/protobuf/util/internal/constants.h",
"third_party/protobuf/src/google/protobuf/util/internal/datapiece.cc",
"third_party/protobuf/src/google/protobuf/util/internal/datapiece.h",
"third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc",
"third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h",
"third_party/protobuf/src/google/protobuf/util/internal/error_listener.cc",
"third_party/protobuf/src/google/protobuf/util/internal/error_listener.h",
"third_party/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc",
"third_party/protobuf/src/google/protobuf/util/internal/field_mask_utility.h",
"third_party/protobuf/src/google/protobuf/util/internal/json_escaping.cc",
"third_party/protobuf/src/google/protobuf/util/internal/json_escaping.h",
"third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc",
"third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.h",
"third_party/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc",
"third_party/protobuf/src/google/protobuf/util/internal/json_stream_parser.h",
"third_party/protobuf/src/google/protobuf/util/internal/location_tracker.h",
"third_party/protobuf/src/google/protobuf/util/internal/object_location_tracker.h",
"third_party/protobuf/src/google/protobuf/util/internal/object_source.h",
"third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc",
"third_party/protobuf/src/google/protobuf/util/internal/object_writer.h",
"third_party/protobuf/src/google/protobuf/util/internal/proto_writer.cc",
"third_party/protobuf/src/google/protobuf/util/internal/proto_writer.h",
"third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc",
"third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h",
"third_party/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc",
"third_party/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h",
"third_party/protobuf/src/google/protobuf/util/internal/structured_objectwriter.h",
"third_party/protobuf/src/google/protobuf/util/internal/type_info.cc",
"third_party/protobuf/src/google/protobuf/util/internal/type_info.h",
"third_party/protobuf/src/google/protobuf/util/internal/type_info_test_helper.cc",
"third_party/protobuf/src/google/protobuf/util/internal/type_info_test_helper.h",
"third_party/protobuf/src/google/protobuf/util/internal/utility.cc",
"third_party/protobuf/src/google/protobuf/util/internal/utility.h",
"third_party/protobuf/src/google/protobuf/util/json_util.cc",
"third_party/protobuf/src/google/protobuf/util/json_util.h",
"third_party/protobuf/src/google/protobuf/util/message_differencer.cc",
"third_party/protobuf/src/google/protobuf/util/message_differencer.h",
"third_party/protobuf/src/google/protobuf/util/time_util.cc",
"third_party/protobuf/src/google/protobuf/util/time_util.h",
"third_party/protobuf/src/google/protobuf/util/type_resolver.h",
"third_party/protobuf/src/google/protobuf/util/type_resolver_util.cc",
"third_party/protobuf/src/google/protobuf/util/type_resolver_util.h",
"third_party/protobuf/src/google/protobuf/wire_format.cc",
"third_party/protobuf/src/google/protobuf/wire_format.h",
"third_party/protobuf/src/google/protobuf/wrappers.pb.cc",
"third_party/protobuf/src/google/protobuf/wrappers.pb.h",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
......@@ -5582,25 +5691,47 @@ if (!build_with_chromium && v8_use_perfetto) {
deps = [ ":protobuf_full" ]
sources = [
"third_party/protobuf/src/google/protobuf/compiler/code_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/code_generator.h",
"third_party/protobuf/src/google/protobuf/compiler/command_line_interface.cc",
"third_party/protobuf/src/google/protobuf/compiler/command_line_interface.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h",
"third_party/protobuf/src/google/protobuf/compiler/plugin.cc",
"third_party/protobuf/src/google/protobuf/compiler/plugin.h",
"third_party/protobuf/src/google/protobuf/compiler/plugin.pb.cc",
"third_party/protobuf/src/google/protobuf/compiler/plugin.pb.h",
"third_party/protobuf/src/google/protobuf/compiler/subprocess.cc",
"third_party/protobuf/src/google/protobuf/compiler/subprocess.h",
"third_party/protobuf/src/google/protobuf/compiler/zip_writer.cc",
"third_party/protobuf/src/google/protobuf/compiler/zip_writer.h",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
......@@ -5637,7 +5768,7 @@ if (!build_with_chromium && v8_use_perfetto) {
"//third_party/perfetto/protos/perfetto/config:cpp",
"//third_party/perfetto/protos/perfetto/trace/track_event:zero",
"//third_party/perfetto/src/tracing:in_process_backend",
"//third_party/perfetto/src/tracing:platform_posix",
"//third_party/perfetto/src/tracing:platform_impl",
]
}
} # if (!build_with_chromium && v8_use_perfetto)
......@@ -286,9 +286,9 @@ deps = {
'dep_type': 'cipd',
},
'third_party/perfetto':
Var('android_url') + '/platform/external/perfetto.git' + '@' + '7cdc44f903d3bcfd1d0f67188bfa797a24756868',
Var('android_url') + '/platform/external/perfetto.git' + '@' + 'aa4385bc5997ecad4c633885e1b331b1115012fb',
'third_party/protobuf':
Var('chromium_url') + '/external/github.com/google/protobuf'+ '@' + 'b68a347f56137b4b1a746e8c7438495a6ac1bd91',
Var('chromium_url') + '/external/github.com/google/protobuf'+ '@' + '6a59a2ad1f61d9696092f79b6d74368b4d7970a3',
'third_party/zlib':
Var('chromium_url') + '/chromium/src/third_party/zlib.git'+ '@' + '2c183c9f93a328bfb3121284da13cf89a0f7e64a',
'third_party/jsoncpp/source':
......
......@@ -7,16 +7,16 @@ import("//build_overrides/build.gni")
# This file should not be pulled in chromium builds.
assert(!build_with_chromium)
if (host_os == "win") {
_host_executable_suffix = ".exe"
} else {
_host_executable_suffix = ""
}
template("proto_library") {
assert(defined(invoker.sources))
proto_sources = invoker.sources
if (host_os == "win") {
host_executable_suffix = ".exe"
} else {
host_executable_suffix = ""
}
# All the proto imports should be relative to the project root.
proto_in_dir = "//"
if (defined(invoker.proto_in_dir)) {
......@@ -32,6 +32,11 @@ template("proto_library") {
# generate_python = true.
assert(defined(invoker.generate_python) && !invoker.generate_python)
import_dirs = []
if (defined(invoker.import_dirs)) {
import_dirs = invoker.import_dirs
}
# If false will not generate the default .pb.{cc,h} files. Used for custom
# codegen plugins.
generate_cc = true
......@@ -48,7 +53,7 @@ template("proto_library") {
plugin_host_label = invoker.generator_plugin_label + "($host_toolchain)"
plugin_path =
get_label_info(plugin_host_label, "root_out_dir") + "/" +
get_label_info(plugin_host_label, "name") + host_executable_suffix
get_label_info(plugin_host_label, "name") + _host_executable_suffix
generate_with_plugin = true
} else if (defined(invoker.generator_plugin_script)) {
plugin_path = invoker.generator_plugin_script
......@@ -68,14 +73,19 @@ template("proto_library") {
}
}
cc_out_dir = "$root_gen_dir/" + proto_out_dir
rel_cc_out_dir = rebase_path(cc_out_dir, root_build_dir)
out_dir = "$root_gen_dir/" + proto_out_dir
rel_out_dir = rebase_path(out_dir, root_build_dir)
# Prevent unused errors when generating descriptor only.
if (generate_descriptor != "") {
not_needed([ "rel_out_dir" ])
}
protos = rebase_path(proto_sources, proto_in_dir)
protogens = []
if (generate_descriptor != "") {
protogens += [ "$root_gen_dir/" + generate_descriptor ]
protogens += [ "$out_dir/${generate_descriptor}" ]
}
foreach(proto, protos) {
......@@ -83,44 +93,64 @@ template("proto_library") {
proto_name = get_path_info(proto, "name")
proto_path = proto_dir + "/" + proto_name
# Prevent unused errors when generating descriptor only.
if (generate_descriptor != "") {
not_needed([ "proto_path" ])
}
if (generate_cc) {
protogens += [
"$cc_out_dir/$proto_path.pb.h",
"$cc_out_dir/$proto_path.pb.cc",
"$out_dir/$proto_path.pb.h",
"$out_dir/$proto_path.pb.cc",
]
}
if (generate_with_plugin) {
foreach(suffix, generator_plugin_suffixes) {
protogens += [ "$cc_out_dir/${proto_path}${suffix}" ]
protogens += [ "$out_dir/${proto_path}${suffix}" ]
}
}
}
config_name = "${target_name}_config"
action_name = "${target_name}_gen"
source_set_name = target_name
if (generate_descriptor == "") {
action_name = "${target_name}_gen"
source_set_name = target_name
} else {
action_name = target_name
}
config(config_name) {
include_dirs = [ cc_out_dir ]
include_dirs = [ out_dir ]
}
# The XXX_gen action that generates the .pb.{cc,h} files.
action(action_name) {
visibility = [ ":$source_set_name" ]
script = "//build/gn_run_binary.py"
if (generate_descriptor == "") {
visibility = [ ":$source_set_name" ]
}
sources = proto_sources
outputs = get_path_info(protogens, "abspath")
protoc_label = "//:protoc($host_toolchain)"
protoc_path = get_label_info(protoc_label, "root_out_dir") + "/protoc" +
host_executable_suffix
_host_executable_suffix
protoc_rebased_path = "./" + rebase_path(protoc_path, root_build_dir)
script = "//gni/protoc.py"
args = [
# Path should be rebased because |root_build_dir| for current toolchain
# may be different from |root_out_dir| of protoc built on host toolchain.
"./" + rebase_path(protoc_path, root_build_dir),
protoc_rebased_path,
"--proto_path",
rebase_path(proto_in_dir, root_build_dir),
]
foreach(path, import_dirs) {
args += [
"--proto_path",
rebase_path(path, root_build_dir),
]
}
if (generate_cc) {
cc_generator_options_ = ""
if (defined(invoker.cc_generator_options)) {
......@@ -128,30 +158,27 @@ template("proto_library") {
}
args += [
"--cpp_out",
cc_generator_options_ + rel_cc_out_dir,
cc_generator_options_ + rel_out_dir,
]
}
if (generate_descriptor != "") {
depfile = "$out_dir/$generate_descriptor.d"
args += [
"--include_imports",
"--descriptor_set_out",
rebase_path("$root_gen_dir/" + generate_descriptor, root_build_dir),
rebase_path("$out_dir/$generate_descriptor", root_build_dir),
"--dependency_out",
rebase_path(depfile, root_build_dir),
]
}
if (defined(invoker.import_dirs)) {
foreach(path, invoker.import_dirs) {
args += [ "--import-dir=" + rebase_path(path, root_build_dir) ]
}
}
if (generate_with_plugin) {
plugin_path_rebased = rebase_path(plugin_path, root_build_dir)
plugin_out_args = ""
if (defined(invoker.generator_plugin_options)) {
plugin_out_args += invoker.generator_plugin_options
}
plugin_out_args += ":$rel_cc_out_dir"
plugin_out_args += ":$rel_out_dir"
args += [
"--plugin=protoc-gen-plugin=$plugin_path_rebased",
......@@ -162,8 +189,15 @@ template("proto_library") {
args += rebase_path(proto_sources, root_build_dir)
inputs = [ protoc_path ]
deps = [ protoc_label ]
# TODO(hjd): Avoid adding to deps here this.
# When we generate BUILD files we need find the transitive proto,
# dependencies, so also add link_deps to actual deps so they show up
# in gn desc.
if (defined(invoker.link_deps)) {
deps += invoker.link_deps
}
if (generate_with_plugin) {
inputs += [ plugin_path ]
if (defined(plugin_host_label)) {
......@@ -172,61 +206,64 @@ template("proto_library") {
}
}
if (defined(invoker.proto_deps)) {
deps += invoker.proto_deps
}
if (defined(invoker.deps)) {
deps += invoker.deps
}
} # action "${target_name}_gen"
} # action(action_name)
# The source_set that builds the generated .pb.cc files.
source_set(target_name) {
forward_variables_from(invoker,
[
"defines",
"include_dirs",
"public_configs",
"testonly",
"visibility",
])
sources = get_target_outputs(":$action_name")
# configs -= [ "//gn/standalone:extra_warnings" ]
if (defined(invoker.extra_configs)) {
configs += invoker.extra_configs
}
if (generate_descriptor == "") {
source_set(source_set_name) {
forward_variables_from(invoker,
[
"defines",
"include_dirs",
"public_configs",
"testonly",
"visibility",
])
sources = get_target_outputs(":$action_name")
if (defined(invoker.extra_configs)) {
configs += invoker.extra_configs
}
if (!defined(invoker.public_configs)) {
public_configs = []
}
if (!defined(invoker.public_configs)) {
public_configs = []
}
public_configs += [ "//:protobuf_gen_config" ]
public_configs += [
"//:protobuf_gen_config",
":$config_name",
]
propagate_imports_configs = !defined(invoker.propagate_imports_configs) ||
invoker.propagate_imports_configs
if (propagate_imports_configs) {
public_configs += [ ":$config_name" ]
} else {
# Embedder handles include directory propagation to dependents.
configs += [ ":$config_name" ]
}
# By default, propagate the config for |include_dirs| to dependent
# targets, so that public imports can be resolved to corresponding header
# files. In some cases, the embedder target handles include directory
# propagation itself, e.g. via a common config.
propagate_imports_configs = !defined(invoker.propagate_imports_configs) ||
invoker.propagate_imports_configs
if (propagate_imports_configs) {
public_configs += [ ":$config_name" ]
} else {
configs += [ ":$config_name" ]
}
# Use protobuf_full only for tests.
if (defined(invoker.use_protobuf_full) &&
invoker.use_protobuf_full == true) {
deps = [ "//:protobuf_full" ]
} else {
deps = [ "//:protobuf_lite" ]
}
# Use protobuf_full only for tests.
if (defined(invoker.use_protobuf_full) &&
invoker.use_protobuf_full == true) {
deps = [ "//:protobuf_full" ]
} else if (generate_cc) {
deps = [ "//:protobuf_lite" ]
} else {
deps = []
}
deps += [ ":$action_name" ]
if (defined(invoker.deps)) {
deps += invoker.deps
}
if (defined(invoker.link_deps)) {
deps += invoker.link_deps
}
} # source_set(target_name)
deps += [ ":$action_name" ]
if (defined(invoker.deps)) {
deps += invoker.deps
}
} # source_set(source_set_name)
}
} # template
#!/usr/bin/env python
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Script to wrap protoc execution.
This script exists to work-around the bad depfile generation by protoc when
generating descriptors."""
from __future__ import print_function
import argparse
import os
import sys
import subprocess
import tempfile
import uuid
from codecs import open
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--descriptor_set_out', default=None)
parser.add_argument('--dependency_out', default=None)
parser.add_argument('protoc')
args, remaining = parser.parse_known_args()
if args.dependency_out and args.descriptor_set_out:
tmp_path = os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))
custom = [
'--descriptor_set_out', args.descriptor_set_out, '--dependency_out',
tmp_path
]
try:
cmd = [args.protoc] + custom + remaining
subprocess.check_call(cmd)
with open(tmp_path, 'rb') as tmp_rd:
dependency_data = tmp_rd.read().decode('utf-8')
finally:
if os.path.exists(tmp_path):
os.unlink(tmp_path)
with open(args.dependency_out, 'w', encoding='utf-8') as f:
f.write(args.descriptor_set_out + ":")
f.write(dependency_data)
else:
subprocess.check_call(sys.argv[1:])
if __name__ == '__main__':
sys.exit(main())
......@@ -106,7 +106,7 @@ void V8::InitializeOncePerProcessImpl() {
if (FLAG_random_seed) SetRandomMmapSeed(FLAG_random_seed);
#if defined(V8_USE_PERFETTO)
TrackEvent::Register();
if (perfetto::Tracing::IsInitialized()) TrackEvent::Register();
#endif
Isolate::InitializeOncePerProcess();
......
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