BUILD.gn (14582B)
1 # Copyright 2018 The Chromium Authors 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 # Flags specified here must not impact ABI. Code compiled with and without these 6 # opts will be linked together, and in some cases headers compiled with and 7 # without these options will be part of the same program. 8 9 import("//chromium/build/config/c++/c++.gni") 10 import("//chromium/build/config/nacl/config.gni") 11 import("//chromium/build/config/sanitizers/sanitizers.gni") 12 import("//chromium/build/toolchain/toolchain.gni") 13 import("//build_overrides/build.gni") 14 import("//third_party/abseil-cpp/absl.gni") 15 16 config("absl_component_build") { 17 defines = [ "ABSL_CONSUME_DLL" ] 18 } 19 20 assert(!is_nacl || is_nacl_saigo, 21 "base must not be built in most nacl toolchains") 22 23 component("absl") { 24 public_deps = [ ":absl_component_deps" ] 25 if (is_component_build) { 26 public_configs = [ ":absl_component_build" ] 27 28 if (is_win && is_clang) { 29 if (target_cpu == "x64") { 30 if (is_debug) { 31 sources = [ "symbols_x64_dbg.def" ] 32 } else { 33 if (is_asan) { 34 sources = [ "symbols_x64_rel_asan.def" ] 35 } else { 36 sources = [ "symbols_x64_rel.def" ] 37 } 38 } 39 } 40 if (target_cpu == "x86") { 41 if (is_debug) { 42 sources = [ "symbols_x86_dbg.def" ] 43 } else { 44 sources = [ "symbols_x86_rel.def" ] 45 } 46 } 47 if (target_cpu == "arm64") { 48 if (is_debug) { 49 sources = [ "symbols_arm64_dbg.def" ] 50 } else { 51 sources = [ "symbols_arm64_rel.def" ] 52 } 53 } 54 } 55 } 56 } 57 58 group("absl_component_deps") { 59 public_deps = [ 60 "//third_party/abseil-cpp/absl/algorithm", 61 "//third_party/abseil-cpp/absl/algorithm:container", 62 "//third_party/abseil-cpp/absl/base", 63 "//third_party/abseil-cpp/absl/base:config", 64 "//third_party/abseil-cpp/absl/base:core_headers", 65 "//third_party/abseil-cpp/absl/base:log_severity", 66 "//third_party/abseil-cpp/absl/base:no_destructor", 67 "//third_party/abseil-cpp/absl/base:nullability", 68 "//third_party/abseil-cpp/absl/base:prefetch", 69 "//third_party/abseil-cpp/absl/cleanup", 70 "//third_party/abseil-cpp/absl/container:btree", 71 "//third_party/abseil-cpp/absl/container:fixed_array", 72 "//third_party/abseil-cpp/absl/container:flat_hash_map", 73 "//third_party/abseil-cpp/absl/container:flat_hash_set", 74 "//third_party/abseil-cpp/absl/container:inlined_vector", 75 "//third_party/abseil-cpp/absl/container:node_hash_map", 76 "//third_party/abseil-cpp/absl/container:node_hash_set", 77 "//third_party/abseil-cpp/absl/debugging:failure_signal_handler", 78 "//third_party/abseil-cpp/absl/debugging:stacktrace", 79 "//third_party/abseil-cpp/absl/debugging:symbolize", 80 "//third_party/abseil-cpp/absl/functional:any_invocable", 81 "//third_party/abseil-cpp/absl/functional:bind_front", 82 "//third_party/abseil-cpp/absl/functional:function_ref", 83 "//third_party/abseil-cpp/absl/functional:overload", 84 "//third_party/abseil-cpp/absl/hash", 85 "//third_party/abseil-cpp/absl/log:absl_check", 86 "//third_party/abseil-cpp/absl/log:absl_log", 87 "//third_party/abseil-cpp/absl/log:absl_vlog_is_on", 88 "//third_party/abseil-cpp/absl/log:die_if_null", 89 "//third_party/abseil-cpp/absl/log:globals", 90 "//third_party/abseil-cpp/absl/log:initialize", 91 "//third_party/abseil-cpp/absl/log:log_entry", 92 "//third_party/abseil-cpp/absl/log:log_sink", 93 "//third_party/abseil-cpp/absl/log:log_sink_registry", 94 "//third_party/abseil-cpp/absl/memory", 95 "//third_party/abseil-cpp/absl/meta:type_traits", 96 "//third_party/abseil-cpp/absl/numeric:bits", 97 "//third_party/abseil-cpp/absl/numeric:int128", 98 "//third_party/abseil-cpp/absl/random", 99 "//third_party/abseil-cpp/absl/random:bit_gen_ref", 100 "//third_party/abseil-cpp/absl/random:distributions", 101 "//third_party/abseil-cpp/absl/status", 102 "//third_party/abseil-cpp/absl/status:statusor", 103 "//third_party/abseil-cpp/absl/strings", 104 "//third_party/abseil-cpp/absl/strings:cord", 105 "//third_party/abseil-cpp/absl/strings:has_ostream_operator", 106 "//third_party/abseil-cpp/absl/strings:str_format", 107 "//third_party/abseil-cpp/absl/strings:string_view", 108 "//third_party/abseil-cpp/absl/synchronization", 109 "//third_party/abseil-cpp/absl/time", 110 "//third_party/abseil-cpp/absl/types:optional", 111 "//third_party/abseil-cpp/absl/types:span", 112 "//third_party/abseil-cpp/absl/types:variant", 113 "//third_party/abseil-cpp/absl/utility", 114 ] 115 116 # Dependencies that preferably shouldn't be public in chromium. 117 public_deps += [ 118 # public in abseil, but deprecated in chromium, yet used. 119 "//third_party/abseil-cpp/absl/base:dynamic_annotations", 120 121 # base/logging.cc uses this non-public absl dependency while there no better 122 # alternative to inject abort hook. See notes in `base/logging.cc`. 123 "//third_party/abseil-cpp/absl/base:raw_logging_internal", 124 125 # absl internal utilities used by protobuf. 126 "//third_party/abseil-cpp/absl/container:layout", 127 ] 128 129 if (is_component_build) { 130 public_deps += [ ":absl_full_deps" ] 131 } 132 133 # The following dependencies currently don't build with NaCl. 134 # TODO(https://crbug.com/1114625): Fix build errors and remove this section. 135 if (is_nacl) { 136 public_deps -= 137 [ "//third_party/abseil-cpp/absl/debugging:failure_signal_handler" ] 138 } 139 140 visibility = [ ":absl" ] 141 142 if (moz_webrtc_build) { 143 # rewrite deps for our new abseil-cpp location 144 if (defined(public_deps)) { 145 modified_deps = [] 146 foreach (dep, public_deps) { 147 newdep = string_replace(dep, "//third_party/abseil-cpp/", "//") 148 modified_deps += [ newdep ] 149 } 150 public_deps = [] 151 public_deps = modified_deps 152 } 153 } 154 } 155 156 # Some third-party libraries use additional parts of absl that are banned in 157 # Chrome (e.g. flags generates static initializers that are undesirable in 158 # non-test binaries). These third-party libraries can depend on `absl_full` 159 # instead of `absl` to use those banned subsets of Abseil as well. 160 source_set("absl_full") { 161 public_deps = [ ":absl" ] 162 163 # In component builds, `absl` itself depends on `absl_full_deps` directly so 164 # that all of absl is built as a single shared library. This is to prevent 165 # globals from being duplicated between both `absl` and `absl_full` (e.g. 166 # inline variables), and the subtle breakage that could cause. 167 # 168 # Deps violations will still be enforced by the non-component build. 169 if (!is_component_build) { 170 public_deps += [ ":absl_full_deps" ] 171 } 172 173 if (build_with_chromium) { 174 visibility = [ 175 # Used by some test executables, but not by anything that is a 176 # part of Chrome. 177 "//components/optimization_guide/internal/*", 178 "//third_party/fuzztest:*", 179 "//third_party/webrtc/*", 180 181 # GoogleTest doesn't actually need absl_full, but this makes gn check 182 # happier. 183 "//third_party/googletest:*", 184 ] 185 } 186 } 187 188 group("absl_full_deps") { 189 if (!moz_webrtc_build) { 190 public_deps = [ 191 # Banned because each flag registration generates a static initializer, and 192 # the flag registration mechanism is problematic in component builds. 193 "//third_party/abseil-cpp/absl/flags:config", 194 "//third_party/abseil-cpp/absl/flags:flag", 195 "//third_party/abseil-cpp/absl/flags:parse", 196 "//third_party/abseil-cpp/absl/flags:reflection", 197 "//third_party/abseil-cpp/absl/flags:usage", 198 199 # Banned because the LOG and CHECK macros conflict with Chrome's version of 200 # those macros. 201 "//third_party/abseil-cpp/absl/log", 202 "//third_party/abseil-cpp/absl/log:check", 203 ] 204 205 visibility = [ 206 ":absl_component_deps", 207 ":absl_full", 208 ] 209 210 public_configs = [ "//third_party/abseil-cpp/absl/flags:absl_flags_config" ] 211 } 212 } 213 214 config("absl_include_config") { 215 include_dirs = [ "." ] 216 } 217 218 config("absl_define_config") { 219 defines = [ "ABSL_ALLOCATOR_NOTHROW=1" ] 220 221 if (is_win && !use_custom_libcxx) { 222 defines += [ 223 # See crbug.com/1101367: Acknowledge extended alignment when using 224 # MSVC's standard library. 225 "_ENABLE_EXTENDED_ALIGNED_STORAGE", 226 ] 227 } 228 } 229 230 config("absl_default_cflags_cc") { 231 cflags_cc = [] 232 if (is_clang) { 233 cflags_cc += [ 234 # TODO(crbug.com/588506): Explicitly enable conversion warnings. 235 "-Wbool-conversion", 236 "-Wconstant-conversion", 237 "-Wenum-conversion", 238 "-Wint-conversion", 239 "-Wliteral-conversion", 240 "-Wnon-literal-null-conversion", 241 "-Wnull-conversion", 242 "-Wobjc-literal-conversion", 243 "-Wstring-conversion", 244 ] 245 if (!is_nacl) { 246 cflags_cc += [ "-Wbitfield-enum-conversion" ] 247 } 248 } 249 } 250 251 config("absl_test_cflags_cc") { 252 cflags_cc = [] 253 if (is_clang || !is_win) { 254 cflags_cc += [ 255 "-Wno-conversion-null", 256 "-Wno-missing-declarations", 257 "-Wno-unused-function", 258 "-Wno-unused-parameter", 259 "-Wno-unused-private-field", 260 ] 261 } 262 if (is_win) { 263 cflags_cc += [ 264 "/wd4101", # unreferenced local variable 265 ] 266 } 267 } 268 269 config("absl_test_config") { 270 cflags_cc = [] 271 if (is_win && !is_clang) { 272 cflags_cc += [ "/wd4996" ] 273 } 274 if (is_clang) { 275 cflags_cc += [ 276 "-Wno-deprecated-declarations", 277 "-Wno-implicit-const-int-float-conversion", 278 "-Wno-unused-private-field", 279 "-Wno-unused-function", 280 ] 281 } 282 } 283 284 if (absl_build_tests) { 285 import("//testing/test.gni") 286 287 if (!is_component_build) { 288 test("absl_tests") { 289 testonly = true 290 deps = [ 291 "absl/algorithm:algorithm_test", 292 "absl/algorithm:container_test", 293 "absl/base:attributes_test", 294 "absl/base:config_test", 295 "absl/base:iterator_traits_test", 296 "absl/base:no_destructor_test", 297 "absl/base:nullability_default_nonnull_test", 298 "absl/base:nullability_test", 299 "absl/base:poison_test", 300 "absl/base:prefetch_test", 301 "absl/base:tracing_internal_strong_test", 302 "absl/base:tracing_internal_weak_test", 303 "absl/cleanup:cleanup_test", 304 "absl/container:common_policy_traits_test", 305 "absl/container:fixed_array_test", 306 "absl/container:flat_hash_map_test", 307 "absl/container:flat_hash_set_test", 308 "absl/container:hash_function_defaults_test", 309 "absl/container:inlined_vector_test", 310 "absl/container:node_hash_map_test", 311 "absl/container:node_hash_set_test", 312 "absl/container:node_slot_policy_test", 313 "absl/container:raw_hash_set_allocator_test", 314 "absl/container:sample_element_size_test", 315 "absl/crc:crc32c_test", 316 "absl/crc:crc_cord_state_test", 317 "absl/crc:crc_memcpy_test", 318 "absl/crc:non_temporal_memcpy_test", 319 "absl/debugging:bounded_utf8_length_sequence_test", 320 "absl/debugging:decode_rust_punycode_test", 321 "absl/debugging:demangle_rust_test", 322 "absl/debugging:stacktrace_test", 323 "absl/debugging:utf8_for_code_point_test", 324 "absl/flags:flag_test", 325 "absl/functional:any_invocable_test", 326 "absl/functional:function_ref_test", 327 "absl/functional:overload_test", 328 "absl/hash:hash_instantiated_test", 329 "absl/hash:hash_test", 330 "absl/hash:low_level_hash_test", 331 "absl/log:absl_check_test", 332 "absl/log:absl_log_basic_test", 333 "absl/log:die_if_null_test", 334 "absl/log:flags_test", 335 "absl/log:globals_test", 336 "absl/log:log_entry_test", 337 "absl/log:log_format_test", 338 "absl/log:log_macro_hygiene_test", 339 "absl/log:log_modifier_methods_test", 340 "absl/log:log_sink_test", 341 "absl/log:log_streamer_test", 342 "absl/log:scoped_mock_log_test", 343 "absl/log:stripping_test", 344 "absl/log:vlog_is_on_test", 345 "absl/log/internal:fnmatch_test", 346 "absl/log/internal:stderr_log_sink_test", 347 "absl/log/internal:structured_proto_test", 348 "absl/memory:memory_test", 349 "absl/meta:type_traits_test", 350 "absl/numeric:int128_test", 351 "absl/profiling:exponential_biased_test", 352 "absl/profiling:periodic_sampler_test", 353 "absl/random:distributions_test", 354 "absl/random:mock_distributions_test", 355 "absl/random/internal:nonsecure_base_test", 356 "absl/status:status_matchers_test", 357 "absl/status:status_test", 358 "absl/status:statusor_test", 359 "absl/strings:ascii_test", 360 "absl/strings:char_formatting_test", 361 "absl/strings:charset_test", 362 "absl/strings:cord_buffer_test", 363 "absl/strings:cord_data_edge_test", 364 "absl/strings:cord_rep_btree_navigator_test", 365 "absl/strings:cord_rep_btree_reader_test", 366 "absl/strings:cord_rep_btree_test", 367 "absl/strings:cord_rep_crc_test", 368 "absl/strings:cord_test", 369 "absl/strings:cordz_functions_test", 370 "absl/strings:cordz_handle_test", 371 "absl/strings:cordz_info_statistics_test", 372 "absl/strings:cordz_info_test", 373 "absl/strings:cordz_sample_token_test", 374 "absl/strings:cordz_test", 375 "absl/strings:cordz_update_scope_test", 376 "absl/strings:cordz_update_tracker_test", 377 "absl/strings:damerau_levenshtein_distance_test", 378 "absl/strings:has_absl_stringify_test", 379 "absl/strings:has_ostream_operator_test", 380 "absl/strings:match_test", 381 "absl/strings:str_cat_test", 382 "absl/strings:str_format_arg_test", 383 "absl/strings:str_format_bind_test", 384 "absl/strings:str_format_checker_test", 385 "absl/strings:str_format_convert_test", 386 "absl/strings:str_format_extension_test", 387 "absl/strings:str_format_output_test", 388 "absl/strings:str_format_parser_test", 389 "absl/strings:str_format_test", 390 "absl/strings:str_replace_test", 391 "absl/strings:string_view_test", 392 "absl/synchronization:barrier_test", 393 "absl/synchronization:graphcycles_test", 394 "absl/synchronization:kernel_timeout_internal_test", 395 "absl/synchronization:mutex_test", 396 "absl/synchronization:per_thread_sem_test", 397 "absl/synchronization:waiter_test", 398 "absl/time:time_test", 399 "absl/types:span_test", 400 "absl/types:variant_test", 401 "//third_party/googletest:gtest_main", 402 ] 403 } 404 } 405 406 test("absl_hardening_tests") { 407 testonly = true 408 sources = [ "absl_hardening_test.cc" ] 409 deps = [ 410 ":absl", 411 "//base/test:run_all_unittests", 412 "//third_party/googletest:gtest", 413 ] 414 } 415 }