1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
|
# 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.
if (is_android) {
import("//build/config/android/rules.gni")
}
# Includes default args like 'enable_js_protobuf'.
import("proto_library.gni")
import("proto_sources.gni")
if (enable_js_protobuf) {
import("//third_party/closure_compiler/compile_js.gni")
}
config("protobuf_config") {
include_dirs = [ "src" ]
defines = [ "GOOGLE_PROTOBUF_NO_RTTI" ]
if (!is_win) {
defines += [ "HAVE_PTHREAD" ]
}
}
config("protobuf_config_internal") {
include_dirs = [ "./third_party/utf8_range" ]
if (is_clang) {
cflags = [
# For src/google/protobuf/map.cc:
"-Wno-deprecated-this-capture",
]
}
}
if (is_component_build) {
config("protobuf_use_dlls") {
defines = [ "PROTOBUF_USE_DLLS" ]
}
}
# This config should be applied to targets using generated code from the proto
# compiler. It sets up the include directories properly.
config("using_proto") {
include_dirs = [ "src" ]
}
component("protobuf_lite") {
sources = protobuf_lite_sources
public = protobuf_headers
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":protobuf_config_internal" ]
# Build protobuf_lite with full optimizations so Clang can optimize the
# initializer out. See 0029-make-initializers-optimizable.patch.
if (!is_debug && is_android) {
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_max" ]
}
# Remove coverage and Sanitizers other than ASan for a performance boost when
# fuzzing. ASan can't be removed here because of a bug preventing unsanitized
# code from using libc++, which protobuf_full uses.
configs -= not_fuzzed_remove_nonasan_configs
configs += [ "//build/config/sanitizers:not_fuzzed" ]
if (is_win) {
configs -= [ "//build/config/win:lean_and_mean" ]
}
public_configs = [ ":protobuf_config" ]
deps = [ ":utf8_range" ]
public_deps = [ "${protobuf_abseil_dir}:absl" ]
# Required for component builds. See http://crbug.com/172800.
if (is_component_build) {
public_configs += [ ":protobuf_use_dlls" ]
defines = [ "LIBPROTOBUF_EXPORTS" ]
}
}
# This is the full, heavy protobuf lib that's needed for c++ .protos that don't
# specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls
# into that category. Do not use in Chrome code.
static_library("protobuf_full") {
if (defined(build_with_chromium) && build_with_chromium) {
# Prevent people from depending on this outside our file.
visibility = [
":*",
# Used for testing protobuf generation.
"//base/test:proto_test_support",
# requires descriptors & reflection; testonly.
"//third_party/libprotobuf-mutator:*",
# Chromecast requires descriptors and reflection.
"//chromecast/*",
# libassistant requires descriptors and reflection for testing.
"//libassistant/*",
# Perfetto uses the full library for testing.
"//third_party/perfetto/gn:protobuf_full",
# Some tests inside ChromeOS need reflection to parse golden files.
# Not included in production code.
"//chrome/browser/ash/child_accounts/time_limit_consistency_test:usage_time_limit_unittests",
# The protobuf-based SQLite and GPU fuzzers need protobuf_full and are not
# included in Chrome.
"//gpu:gl_lpm_fuzzer_proto",
"//gpu:gl_lpm_fuzzer_proto_gen",
"//gpu:gl_lpm_shader_to_string_unittest",
"//third_party/sqlite:sqlite3_lpm_corpus_gen",
# The protobuf-based Mojo LPM fuzzer needs protobuf_full and is not included
# in Chrome.
"//mojo/public/tools/fuzzers:mojolpm",
# The root store tool is not part of Chrome itself, and needs to parse
# human-readable protobufs. Protobuf is stored in //net/cert however as
# browser needs to be able to parse serialized protobuf (which is exposed
# as a separate lite BUILD rule).
"//net/cert:root_store_proto_full",
# The spirv-fuzz fuzzer tool needs protobuf_full and is not included in
# Chrome.
"//third_party/spirv-tools/src:spirv-fuzz",
"//third_party/spirv-tools/src:spvtools_fuzz",
"//third_party/spirv-tools/src:spvtools_fuzz_proto",
# Some fuzzers for tint need protobuf_full and are not included in Chrome.
"//third_party/dawn/src/tint/*",
# Dawn LPM Fuzzers
"//third_party/dawn/src/dawn/fuzzers:dawn_lpm_proto",
"//third_party/dawn/src/dawn/fuzzers:dawn_lpm_proto_gen",
# The Cast Core gRPC generator tool.
"//third_party/cast_core/public/src/build/chromium:cast_core_grpc_generator",
# The proto_extras plugin generates code that some of the above fuzzers
# use, and thus needs to know the full types.
"//components/proto_extras:protobuf_full_support",
]
}
deps = [ ":utf8_range" ]
# In component build, protobuf_full can't depend on protobuf_lite because
# it uses non-PROTOBUF_EXPORT symbols; in non-component build, protobuf_full
# must have protobuf_lite as a dependency instead of building
# protobuf_lite_sources to avoid ODR violations in targets that link both.
# See crbug.com/1338164.
if (is_component_build) {
sources = protobuf_lite_sources + protobuf_sources
} else {
sources = protobuf_sources
deps += [ ":protobuf_lite" ]
}
public = protobuf_headers
public_deps = [ "${protobuf_abseil_dir}:absl" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":protobuf_config_internal" ]
# Remove coverage and Sanitizers other than ASan for a performance boost when
# fuzzing. ASan can't be removed here because of a bug preventing unsanitized
# code from using libc++, which protobuf_full uses.
configs -= not_fuzzed_remove_nonasan_configs
configs += [ "//build/config/sanitizers:not_fuzzed" ]
if (is_win) {
configs -= [ "//build/config/win:lean_and_mean" ]
}
public_configs = [ ":protobuf_config" ]
}
# Only compile the compiler for the host architecture.
if (current_toolchain == host_toolchain) {
# Code for compiling bindings for individual languages are pulled into
# separate build targets for two reasons:
# 1. To avoid naming collisions between files in the same source set.
# 2. Because Chromium doesn't need a lot of the languages.
# Note we have to separate the 3 Java directories (java/, java/full/ and
# java/lite/) into 3 different GN targets because they contain .cc files with
# identical names (e.g. message.cc), and source_set() doesn't support multiple
# .cc files with the same basename. We use a single target for the headers as
# these directories tend to cross-#include each other which makes things
# challenging for GN header dependency checks.
source_set("protoc_java_all_headers") {
sources = protoc_java_all_headers
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":protobuf_config_internal" ]
public_deps = [ ":protobuf_full" ]
}
source_set("protoc_java") {
sources = protoc_java_sources
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":protobuf_config_internal" ]
public_deps = [
":protobuf_full",
":protoc_java_all_headers",
]
}
source_set("protoc_java_full") {
sources = protoc_java_full_sources
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":protobuf_config_internal" ]
public_deps = [
":protobuf_full",
":protoc_java_all_headers",
]
}
source_set("protoc_java_lite") {
sources = protoc_java_lite_sources
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":protobuf_config_internal" ]
public_deps = [
":protobuf_full",
":protoc_java_all_headers",
]
}
source_set("protoc_cpp") {
sources = protoc_cpp_sources + protoc_cpp_headers
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":protobuf_config_internal" ]
public_deps = [ ":protobuf_full" ]
}
source_set("protoc_python") {
sources = protoc_python_sources + protoc_python_headers
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":protobuf_config_internal" ]
public_deps = [ ":protobuf_full" ]
}
# protoc generates language-specific bindings from protos.
static_library("protoc_lib") {
sources = protoc_sources + protoc_headers
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":protobuf_config_internal" ]
public_configs = [ ":protobuf_config" ]
public_deps = [ ":protobuf_full" ]
deps = [
":protoc_cpp",
":protoc_java",
":protoc_java_all_headers",
":protoc_java_full",
":protoc_java_lite",
":protoc_python",
]
allow_circular_includes_from = [
":protoc_java",
":protoc_java_all_headers",
":protoc_java_full",
":protoc_java_lite",
":protoc_cpp",
":protoc_python",
]
}
executable("protoc") {
sources = [ "src/google/protobuf/compiler/main.cc" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":protobuf_config_internal" ]
deps = [
":protoc_cpp",
":protoc_java",
":protoc_java_full",
":protoc_java_lite",
":protoc_lib",
":protoc_python",
]
if (enable_js_protobuf) {
deps += [ "//third_party/protobuf-javascript:protoc-gen-js" ]
}
}
}
source_set("utf8_range") {
sources = [
"third_party/utf8_range/utf8_range.c",
"third_party/utf8_range/utf8_range.h",
"third_party/utf8_range/utf8_validity.h",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":protobuf_config_internal" ]
deps = [ "${protobuf_abseil_dir}:absl" ]
}
copy("copy_google_protobuf") {
# See README.chromium for how this file is generated.
sources = pyproto_sources + [ "python/google/protobuf/descriptor_pb2.py" ]
outputs = [ "$proto_python_root/google/protobuf/{{source_file_part}}" ]
}
copy("copy_google_protobuf_internal") {
# See README.chromium for how this file is generated.
sources = pyproto_internal_sources +
[ "python/google/protobuf/internal/python_edition_defaults.py" ]
outputs =
[ "$proto_python_root/google/protobuf/internal/{{source_file_part}}" ]
}
# Build time dependency for action rules.
group("py_proto") {
public_deps = [
":copy_google_protobuf",
":copy_google_protobuf_internal",
]
}
# Note: This exists for Cronet in AOSP where we can't import prebuilts. We import
# the raw sources and compile them using a specialized pipeline. See crbug.com/419480317.
if (is_android && is_cronet_for_aosp_build) {
android_library("proto_runtime_lite_java") {
sources = javaproto_sources
}
}
# Runtime dependency if the target needs the python scripts.
group("py_proto_runtime") {
deps = [ ":py_proto" ]
# Targets that depend on this should depend on the copied data files.
data = get_target_outputs(":copy_google_protobuf")
data += get_target_outputs(":copy_google_protobuf_internal")
}
# JS protobuf library.
if (enable_js_protobuf) {
js_library("js_proto") {
sources = [
"//third_party/google-closure-library/closure/goog/array/array.js",
"//third_party/google-closure-library/closure/goog/asserts/asserts.js",
"//third_party/google-closure-library/closure/goog/asserts/dom.js",
"//third_party/google-closure-library/closure/goog/async/throwexception.js",
"//third_party/google-closure-library/closure/goog/base.js",
"//third_party/google-closure-library/closure/goog/crypt/base64.js",
"//third_party/google-closure-library/closure/goog/crypt/crypt.js",
"//third_party/google-closure-library/closure/goog/debug/error.js",
"//third_party/google-closure-library/closure/goog/dom/asserts.js",
"//third_party/google-closure-library/closure/goog/dom/browserfeature.js",
"//third_party/google-closure-library/closure/goog/dom/dom.js",
"//third_party/google-closure-library/closure/goog/dom/element.js",
"//third_party/google-closure-library/closure/goog/dom/htmlelement.js",
"//third_party/google-closure-library/closure/goog/dom/nodetype.js",
"//third_party/google-closure-library/closure/goog/dom/safe.js",
"//third_party/google-closure-library/closure/goog/dom/tagname.js",
"//third_party/google-closure-library/closure/goog/dom/tags.js",
"//third_party/google-closure-library/closure/goog/flags/flags.js",
"//third_party/google-closure-library/closure/goog/fs/blob.js",
"//third_party/google-closure-library/closure/goog/fs/url.js",
"//third_party/google-closure-library/closure/goog/functions/functions.js",
"//third_party/google-closure-library/closure/goog/goog.js",
"//third_party/google-closure-library/closure/goog/html/safehtml.js",
"//third_party/google-closure-library/closure/goog/html/safescript.js",
"//third_party/google-closure-library/closure/goog/html/safestyle.js",
"//third_party/google-closure-library/closure/goog/html/safestylesheet.js",
"//third_party/google-closure-library/closure/goog/html/safeurl.js",
"//third_party/google-closure-library/closure/goog/html/trustedresourceurl.js",
"//third_party/google-closure-library/closure/goog/html/trustedtypes.js",
"//third_party/google-closure-library/closure/goog/html/uncheckedconversions.js",
"//third_party/google-closure-library/closure/goog/i18n/bidi.js",
"//third_party/google-closure-library/closure/goog/labs/useragent/browser.js",
"//third_party/google-closure-library/closure/goog/labs/useragent/engine.js",
"//third_party/google-closure-library/closure/goog/labs/useragent/highentropy/highentropydata.js",
"//third_party/google-closure-library/closure/goog/labs/useragent/highentropy/highentropyvalue.js",
"//third_party/google-closure-library/closure/goog/labs/useragent/platform.js",
"//third_party/google-closure-library/closure/goog/labs/useragent/useragent.js",
"//third_party/google-closure-library/closure/goog/labs/useragent/util.js",
"//third_party/google-closure-library/closure/goog/math/coordinate.js",
"//third_party/google-closure-library/closure/goog/math/math.js",
"//third_party/google-closure-library/closure/goog/math/size.js",
"//third_party/google-closure-library/closure/goog/memoize/memoize.js",
"//third_party/google-closure-library/closure/goog/object/object.js",
"//third_party/google-closure-library/closure/goog/reflect/reflect.js",
"//third_party/google-closure-library/closure/goog/string/const.js",
"//third_party/google-closure-library/closure/goog/string/internal.js",
"//third_party/google-closure-library/closure/goog/string/string.js",
"//third_party/google-closure-library/closure/goog/string/typedstring.js",
"//third_party/google-closure-library/closure/goog/useragent/product.js",
"//third_party/google-closure-library/closure/goog/useragent/useragent.js",
"//third_party/protobuf-javascript/src/asserts.js",
"//third_party/protobuf-javascript/src/binary/arith.js",
"//third_party/protobuf-javascript/src/binary/constants.js",
"//third_party/protobuf-javascript/src/binary/decoder.js",
"//third_party/protobuf-javascript/src/binary/encoder.js",
"//third_party/protobuf-javascript/src/binary/reader.js",
"//third_party/protobuf-javascript/src/binary/utf8.js",
"//third_party/protobuf-javascript/src/binary/utils.js",
"//third_party/protobuf-javascript/src/binary/writer.js",
"//third_party/protobuf-javascript/src/map.js",
"//third_party/protobuf-javascript/src/message.js",
]
}
}
|