Commit 80061615 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[tracing] Add build config for Perfetto behind a flag

This adds dependencies on Perfetto and Protobuf and the required
configs to build them.

The build configs are behind a gn flag (v8_use_perfetto) and
are disabled by default. Actual implementation of Perfetto will follow.

Based on Primiano's prototype:
https://chromium-review.googlesource.com/c/v8/v8/+/1290549

Bug: v8:8339
TBR: yangguo@chromium.org
Change-Id: I2b7462d567bfb0a5a3ffbbb8b6fcbf41c824e285
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1517876Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Auto-Submit: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60502}
parent c62a6da5
...@@ -127,6 +127,10 @@ declare_args() { ...@@ -127,6 +127,10 @@ declare_args() {
# Use Siphash as added protection against hash flooding attacks. # Use Siphash as added protection against hash flooding attacks.
v8_use_siphash = false v8_use_siphash = false
# Use Perfetto (https://perfetto.dev) as the default TracingController. Not
# currently implemented.
v8_use_perfetto = false
# Switches off inlining in V8. # Switches off inlining in V8.
v8_no_inline = false v8_no_inline = false
...@@ -416,6 +420,9 @@ config("features") { ...@@ -416,6 +420,9 @@ config("features") {
if (v8_enable_shared_ro_heap) { if (v8_enable_shared_ro_heap) {
defines += [ "V8_SHARED_RO_HEAP" ] defines += [ "V8_SHARED_RO_HEAP" ]
} }
if (v8_use_perfetto) {
defines += [ "V8_USE_PERFETTO" ]
}
} }
config("toolchain") { config("toolchain") {
...@@ -3462,6 +3469,9 @@ v8_component("v8_libplatform") { ...@@ -3462,6 +3469,9 @@ v8_component("v8_libplatform") {
":v8_headers", ":v8_headers",
":v8_libbase", ":v8_libbase",
] ]
if (v8_use_perfetto) {
deps += [ "third_party/perfetto:libperfetto" ]
}
} }
v8_source_set("v8_libsampler") { v8_source_set("v8_libsampler") {
...@@ -4137,3 +4147,255 @@ group("v8_generated_cc_files") { ...@@ -4137,3 +4147,255 @@ group("v8_generated_cc_files") {
"test/cctest:v8_generated_cc_files", "test/cctest:v8_generated_cc_files",
] ]
} }
# Protobuf targets, used only when building outside of chromium.
if (!build_with_chromium && v8_use_perfetto) {
# This config is applied to the autogenerated .pb.{cc,h} files in
# proto_library.gni. This config is propagated up to the source sets
# that depend on generated proto headers.
config("protobuf_gen_config") {
defines = [
"GOOGLE_PROTOBUF_NO_RTTI",
"GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
]
cflags = [
# Using -isystem instead of include_dirs (-I), so we don't need to suppress
# warnings coming from libprotobuf headers. Doing so would mask warnings in
# our own code.
"-isystem",
rebase_path("third_party/protobuf/src", root_build_dir),
"-Wno-unknown-warning-option",
"-Wno-deprecated",
"-Wno-undef",
"-Wno-zero-as-null-pointer-constant",
]
}
# Configuration used to build libprotobuf_* and the protoc compiler.
config("protobuf_config") {
# Apply the lighter supressions and macro definitions from above.
configs = [ ":protobuf_gen_config" ]
defines = [ "HAVE_PTHREAD=1" ]
if (is_clang) {
cflags = [
"-Wno-unknown-warning-option",
"-Wno-enum-compare-switch",
"-Wno-user-defined-warnings",
"-Wno-tautological-constant-compare",
]
}
}
source_set("protobuf_lite") {
sources = [
"third_party/protobuf/src/google/protobuf/arena.cc",
"third_party/protobuf/src/google/protobuf/arenastring.cc",
"third_party/protobuf/src/google/protobuf/extension_set.cc",
"third_party/protobuf/src/google/protobuf/generated_message_util.cc",
"third_party/protobuf/src/google/protobuf/io/coded_stream.cc",
"third_party/protobuf/src/google/protobuf/io/zero_copy_stream.cc",
"third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
"third_party/protobuf/src/google/protobuf/message_lite.cc",
"third_party/protobuf/src/google/protobuf/repeated_field.cc",
"third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
"third_party/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
"third_party/protobuf/src/google/protobuf/stubs/bytestream.cc",
"third_party/protobuf/src/google/protobuf/stubs/common.cc",
"third_party/protobuf/src/google/protobuf/stubs/int128.cc",
"third_party/protobuf/src/google/protobuf/stubs/once.cc",
"third_party/protobuf/src/google/protobuf/stubs/status.cc",
"third_party/protobuf/src/google/protobuf/stubs/statusor.cc",
"third_party/protobuf/src/google/protobuf/stubs/stringpiece.cc",
"third_party/protobuf/src/google/protobuf/stubs/stringprintf.cc",
"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/time.cc",
"third_party/protobuf/src/google/protobuf/wire_format_lite.cc",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ ":protobuf_config" ]
public_configs = [ ":protobuf_gen_config" ]
}
# This target should be used only by the protoc compiler and by test targets.
source_set("protobuf_full") {
deps = [
":protobuf_lite",
]
sources = [
"third_party/protobuf/src/google/protobuf/any.cc",
"third_party/protobuf/src/google/protobuf/any.pb.cc",
"third_party/protobuf/src/google/protobuf/api.pb.cc",
"third_party/protobuf/src/google/protobuf/compiler/importer.cc",
"third_party/protobuf/src/google/protobuf/compiler/parser.cc",
"third_party/protobuf/src/google/protobuf/descriptor.cc",
"third_party/protobuf/src/google/protobuf/descriptor.pb.cc",
"third_party/protobuf/src/google/protobuf/descriptor_database.cc",
"third_party/protobuf/src/google/protobuf/duration.pb.cc",
"third_party/protobuf/src/google/protobuf/dynamic_message.cc",
"third_party/protobuf/src/google/protobuf/empty.pb.cc",
"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/generated_message_reflection.cc",
"third_party/protobuf/src/google/protobuf/io/gzip_stream.cc",
"third_party/protobuf/src/google/protobuf/io/printer.cc",
"third_party/protobuf/src/google/protobuf/io/strtod.cc",
"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/map_field.cc",
"third_party/protobuf/src/google/protobuf/message.cc",
"third_party/protobuf/src/google/protobuf/reflection_ops.cc",
"third_party/protobuf/src/google/protobuf/service.cc",
"third_party/protobuf/src/google/protobuf/source_context.pb.cc",
"third_party/protobuf/src/google/protobuf/struct.pb.cc",
"third_party/protobuf/src/google/protobuf/stubs/mathlimits.cc",
"third_party/protobuf/src/google/protobuf/stubs/substitute.cc",
"third_party/protobuf/src/google/protobuf/text_format.cc",
"third_party/protobuf/src/google/protobuf/timestamp.pb.cc",
"third_party/protobuf/src/google/protobuf/type.pb.cc",
"third_party/protobuf/src/google/protobuf/unknown_field_set.cc",
"third_party/protobuf/src/google/protobuf/util/field_comparator.cc",
"third_party/protobuf/src/google/protobuf/util/field_mask_util.cc",
"third_party/protobuf/src/google/protobuf/util/internal/datapiece.cc",
"third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc",
"third_party/protobuf/src/google/protobuf/util/internal/error_listener.cc",
"third_party/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc",
"third_party/protobuf/src/google/protobuf/util/internal/json_escaping.cc",
"third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc",
"third_party/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc",
"third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc",
"third_party/protobuf/src/google/protobuf/util/internal/proto_writer.cc",
"third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc",
"third_party/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc",
"third_party/protobuf/src/google/protobuf/util/internal/type_info.cc",
"third_party/protobuf/src/google/protobuf/util/internal/type_info_test_helper.cc",
"third_party/protobuf/src/google/protobuf/util/internal/utility.cc",
"third_party/protobuf/src/google/protobuf/util/json_util.cc",
"third_party/protobuf/src/google/protobuf/util/message_differencer.cc",
"third_party/protobuf/src/google/protobuf/util/time_util.cc",
"third_party/protobuf/src/google/protobuf/util/type_resolver_util.cc",
"third_party/protobuf/src/google/protobuf/wire_format.cc",
"third_party/protobuf/src/google/protobuf/wrappers.pb.cc",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ ":protobuf_config" ]
public_configs = [ ":protobuf_gen_config" ]
}
if (current_toolchain == host_toolchain) {
source_set("protoc_lib") {
deps = [
":protobuf_full",
]
sources = [
"third_party/protobuf/src/google/protobuf/compiler/code_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/command_line_interface.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc",
"third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_field_base.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_helpers.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_map_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_message.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_message_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
"third_party/protobuf/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_context.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_enum.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_enum_field_lite.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_enum_lite.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_extension.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_extension_lite.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_file.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_generator_factory.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_map_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_map_field_lite.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_message.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_message_builder.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_message_builder_lite.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_message_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_message_field_lite.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_message_lite.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_name_resolver.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_service.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_string_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/java/java_string_field_lite.cc",
"third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_enum.cc",
"third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_extension.cc",
"third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_file.cc",
"third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_helpers.cc",
"third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_map_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_message.cc",
"third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_message_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/js/js_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_file.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_message.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
"third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
"third_party/protobuf/src/google/protobuf/compiler/plugin.cc",
"third_party/protobuf/src/google/protobuf/compiler/plugin.pb.cc",
"third_party/protobuf/src/google/protobuf/compiler/python/python_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generator.cc",
"third_party/protobuf/src/google/protobuf/compiler/subprocess.cc",
"third_party/protobuf/src/google/protobuf/compiler/zip_writer.cc",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ ":protobuf_config" ]
public_configs = [ ":protobuf_gen_config" ]
}
executable("protoc") {
deps = [
":protoc_lib",
"//build/win:default_exe_manifest",
]
sources = [
"third_party/protobuf/src/google/protobuf/compiler/main.cc",
]
configs -= [ "//build/config/compiler:chromium_code" ]
}
} # host_toolchain
} # if (!build_with_chromium && v8_use_perfetto)
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
vars = { vars = {
'checkout_instrumented_libraries': False, 'checkout_instrumented_libraries': False,
'chromium_url': 'https://chromium.googlesource.com', 'chromium_url': 'https://chromium.googlesource.com',
'android_url': 'https://android.googlesource.com',
'download_gcmole': False, 'download_gcmole': False,
'download_jsfunfuzz': False, 'download_jsfunfuzz': False,
'download_mips_toolchain': False, 'download_mips_toolchain': False,
...@@ -236,8 +237,11 @@ deps = { ...@@ -236,8 +237,11 @@ deps = {
}, },
'v8/test/wasm-js/data': 'v8/test/wasm-js/data':
Var('chromium_url') + '/external/github.com/WebAssembly/spec.git' + '@' + '4406612ae0f6c3c4e7791eb13704e9fb7440819a', Var('chromium_url') + '/external/github.com/WebAssembly/spec.git' + '@' + '4406612ae0f6c3c4e7791eb13704e9fb7440819a',
'v8/third_party/perfetto':
Var('android_url') + '/platform/external/perfetto.git' + '@' + 'b66b4e0b328bcb1af62701cd76b1475ebf06a438',
'v8/third_party/protobuf':
Var('chromium_url') + '/external/github.com/google/protobuf'+ '@' + 'bdeb215cab2985195325fcd5e70c3fa751f46e0f',
} }
recursedeps = [ recursedeps = [
'v8/third_party/android_tools', 'v8/third_party/android_tools',
] ]
......
...@@ -6,6 +6,16 @@ ...@@ -6,6 +6,16 @@
# Chromium specific targets in a client project's GN file etc. # Chromium specific targets in a client project's GN file etc.
build_with_chromium = false build_with_chromium = false
# Used by perfetto to distinguish from its own standalone build and the
# chromium build.
perfetto_build_with_embedder = true
# When embedding perfetto, its build files need to know in which BUILD.gn file
# the embedder (v8) declared the protobuf targets. In the v8 case they are
# declared in the root v8/BUILD.gn.
perfetto_protobuf_target_prefix = "//"
perfetto_protobuf_gni = "//gni/proto_library.gni"
# Uncomment these to specify a different NDK location and version in # Uncomment these to specify a different NDK location and version in
# non-Chromium builds. # non-Chromium builds.
# default_android_ndk_root = "//third_party/android_ndk" # default_android_ndk_root = "//third_party/android_ndk"
......
# Copyright 2019 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.
import("//build_overrides/build.gni")
# This file should not be pulled in chromium builds.
assert(!build_with_chromium)
template("proto_library") {
assert(defined(invoker.sources))
proto_sources = invoker.sources
set_sources_assignment_filter([])
# All the proto imports should be relative to the project root.
proto_in_dir = "//"
if (defined(invoker.proto_in_dir)) {
proto_in_dir = invoker.proto_in_dir
}
assert(defined(invoker.proto_out_dir),
"proto_out_dir must be explicitly defined")
proto_out_dir = invoker.proto_out_dir
# We don't support generate_python in the standalone build, but still must
# check that the caller sets this to false. This is because when building in
# the chromium tree, chromium's proto_library.gni in chrome (!= this) defaults
# generate_python = true.
assert(defined(invoker.generate_python) && !invoker.generate_python)
# If false will not generate the default .pb.{cc,h} files. Used for custom
# codegen plugins.
generate_cc = true
if (defined(invoker.generate_cc)) {
generate_cc = invoker.generate_cc
}
generate_descriptor = ""
if (defined(invoker.generate_descriptor)) {
generate_descriptor = invoker.generate_descriptor
}
if (defined(invoker.generator_plugin_label)) {
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")
generate_with_plugin = true
} else if (defined(invoker.generator_plugin_script)) {
plugin_path = invoker.generator_plugin_script
generate_with_plugin = true
} else {
generate_with_plugin = false
}
if (generate_with_plugin) {
if (defined(invoker.generator_plugin_suffix)) {
generator_plugin_suffixes = [
"${invoker.generator_plugin_suffix}.h",
"${invoker.generator_plugin_suffix}.cc",
]
} else {
generator_plugin_suffixes = invoker.generator_plugin_suffixes
}
}
cc_out_dir = "$root_gen_dir/" + proto_out_dir
rel_cc_out_dir = rebase_path(cc_out_dir, root_build_dir)
protos = rebase_path(proto_sources, proto_in_dir)
protogens = []
if (generate_descriptor != "") {
protogens += [ "$root_gen_dir/" + generate_descriptor ]
}
foreach(proto, protos) {
proto_dir = get_path_info(proto, "dir")
proto_name = get_path_info(proto, "name")
proto_path = proto_dir + "/" + proto_name
if (generate_cc) {
protogens += [
"$cc_out_dir/$proto_path.pb.h",
"$cc_out_dir/$proto_path.pb.cc",
]
}
if (generate_with_plugin) {
foreach(suffix, generator_plugin_suffixes) {
protogens += [ "$cc_out_dir/${proto_path}${suffix}" ]
}
}
}
config_name = "${target_name}_config"
action_name = "${target_name}_gen"
source_set_name = target_name
config(config_name) {
include_dirs = [ cc_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"
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"
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),
"--proto_path",
rebase_path(proto_in_dir, root_build_dir),
]
if (generate_cc) {
args += [
"--cpp_out",
rel_cc_out_dir,
]
}
if (generate_descriptor != "") {
args += [
"--include_imports",
"--descriptor_set_out",
rebase_path("$root_gen_dir/" + generate_descriptor, 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"
args += [
"--plugin=protoc-gen-plugin=$plugin_path_rebased",
"--plugin_out=$plugin_out_args",
]
}
args += rebase_path(proto_sources, root_build_dir)
inputs = [
protoc_path,
]
deps = [
protoc_label,
]
if (generate_with_plugin) {
inputs += [ plugin_path ]
if (defined(plugin_host_label)) {
# Action depends on native generator plugin but for host toolchain only.
deps += [ plugin_host_label ]
}
}
if (defined(invoker.proto_deps)) {
deps += invoker.proto_deps
}
if (defined(invoker.deps)) {
deps += invoker.deps
}
} # action "${target_name}_gen"
# 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 (!defined(invoker.public_configs)) {
public_configs = []
}
public_configs += [
"//:protobuf_gen_config",
":$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",
]
}
deps += [ ":$action_name" ]
if (defined(invoker.deps)) {
deps += invoker.deps
}
if (defined(invoker.link_deps)) {
deps += invoker.link_deps
}
} # source_set(target_name)
} # template
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