chromium/third_party/blink/renderer/platform/wtf/BUILD.gn

# Copyright 2017 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/features.gni")

assert(use_blink)

import("//build/buildflag_header.gni")
import("//build/config/compiler/compiler.gni")
import("//testing/test.gni")
import("//third_party/blink/public/public_features.gni")
import("//third_party/blink/renderer/config.gni")

visibility = [
  ":*",
  "//:gn_all",
  "//mojo/public/cpp/bindings/*",
  "//third_party/blink/*",
]

config("wtf_config") {
  if (is_win) {
    cflags = [
      # Don't complain about calling specific versions of templatized
      # functions (e.g. in RefPtrHashMap.h).
      "/wd4344",
    ]

    if (is_component_build) {
      # Chromium windows multi-dll build enables C++ exceptions and this causes
      # wtf to generate 4291 warning due to operator new/delete
      # implementations. Disable the warning for chromium windows multi-dll
      # build.
      cflags += [ "/wd4291" ]
    }
  }
}

component("wtf") {
  output_name = "blink_platform_wtf"

  sources = [
    "allocator/allocator.h",
    "allocator/partition_allocator.cc",
    "allocator/partition_allocator.h",
    "allocator/partitions.cc",
    "allocator/partitions.h",
    "assertions.h",
    "atomic_operations.cc",
    "atomic_operations.h",
    "bit_field.h",
    "bloom_filter.h",
    "casting.h",
    "container_annotations.h",
    "cross_thread_copier.cc",
    "cross_thread_copier.h",
    "cross_thread_copier_base.h",
    "cross_thread_copier_gfx.h",
    "cross_thread_copier_gpu.h",
    "cross_thread_copier_media.h",
    "cross_thread_copier_mojo.h",
    "cross_thread_copier_public.h",
    "cross_thread_copier_skia.h",
    "cross_thread_copier_std.h",
    "cross_thread_functional.h",
    "date_math.cc",
    "date_math.h",
    "decimal.cc",
    "decimal.h",
    "deque.h",
    "doubly_linked_list.h",
    "dtoa.cc",
    "dtoa.h",
    "dynamic_annotations.cc",
    "dynamic_annotations.h",
    "forward.h",
    "functional.h",
    "gc_plugin.h",
    "get_ptr.h",
    "hash_counted_set.h",
    "hash_functions.h",
    "hash_map.h",
    "hash_set.h",
    "hash_table.cc",
    "hash_table.h",
    "hash_table_deleted_value_type.h",
    "hash_traits.h",
    "key_value_pair.h",
    "leak_annotations.h",
    "linked_hash_set.h",
    "math_extras.h",
    "pod_arena.h",
    "pod_free_list_arena.h",
    "pod_interval.h",
    "pod_interval_tree.h",
    "pod_red_black_tree.h",
    "ref_counted.h",
    "sanitizers.h",
    "sequence_bound.h",
    "shared_buffer.cc",
    "shared_buffer.h",
    "size_assertions.cc",
    "size_assertions.h",
    "stack_util.cc",
    "stack_util.h",
    "static_constructors.h",
    "std_lib_extras.h",
    "text/ascii_ctype.cc",
    "text/ascii_ctype.h",
    "text/ascii_fast_path.h",
    "text/atomic_string.cc",
    "text/atomic_string.h",
    "text/atomic_string_encoding.h",
    "text/atomic_string_hash.h",
    "text/atomic_string_table.cc",
    "text/atomic_string_table.h",
    "text/base64.cc",
    "text/base64.h",
    "text/case_folding_hash.h",
    "text/case_map.cc",
    "text/case_map.h",
    "text/character_names.h",
    "text/character_visitor.h",
    "text/code_point_iterator.h",
    "text/copy_lchars_from_uchar_source.h",
    "text/encoding_tables.cc",
    "text/encoding_tables.h",
    "text/integer_to_string_conversion.h",
    "text/line_ending.cc",
    "text/line_ending.h",
    "text/math_transform.cc",
    "text/math_transform.h",
    "text/number_parsing_options.h",
    "text/parsing_utilities.h",
    "text/string_buffer.h",
    "text/string_builder.cc",
    "text/string_builder.h",
    "text/string_concatenate.cc",
    "text/string_concatenate.h",
    "text/string_hash.h",
    "text/string_hasher.h",
    "text/string_impl.cc",
    "text/string_impl.h",
    "text/string_operators.h",
    "text/string_statics.cc",
    "text/string_statics.h",
    "text/string_to_number.cc",
    "text/string_to_number.h",
    "text/string_utf8_adaptor.cc",
    "text/string_utf8_adaptor.h",
    "text/string_view.cc",
    "text/string_view.h",
    "text/text_codec.cc",
    "text/text_codec.h",
    "text/text_codec_ascii_fast_path.h",
    "text/text_codec_cjk.cc",
    "text/text_codec_cjk.h",
    "text/text_codec_icu.cc",
    "text/text_codec_icu.h",
    "text/text_codec_latin1.cc",
    "text/text_codec_latin1.h",
    "text/text_codec_replacement.cc",
    "text/text_codec_replacement.h",
    "text/text_codec_user_defined.cc",
    "text/text_codec_user_defined.h",
    "text/text_codec_utf16.cc",
    "text/text_codec_utf16.h",
    "text/text_codec_utf8.cc",
    "text/text_codec_utf8.h",
    "text/text_encoding.cc",
    "text/text_encoding.h",
    "text/text_encoding_registry.cc",
    "text/text_encoding_registry.h",
    "text/text_offset_map.cc",
    "text/text_offset_map.h",
    "text/text_position.cc",
    "text/text_position.h",
    "text/text_stream.cc",
    "text/text_stream.h",
    "text/unicode.h",
    "text/unicode_string.h",
    "text/utf8.cc",
    "text/utf8.h",
    "text/wtf_string.cc",
    "text/wtf_string.h",
    "text/wtf_uchar.h",
    "thread_safe_ref_counted.h",
    "thread_specific.h",
    "threading.cc",
    "threading.h",
    "threading_primitives.cc",
    "threading_primitives.h",
    "type_traits.h",
    "uuid.cc",
    "uuid.h",
    "vector.h",
    "vector_backed_linked_list.h",
    "vector_traits.h",
    "wtf.cc",
    "wtf.h",
    "wtf_export.h",
    "wtf_size_t.h",
  ]

  configs += [
    "//third_party/blink/renderer:config",
    "//third_party/blink/renderer:non_test_config",
    "//third_party/blink/renderer:blink_pch",
  ]

  defines = [ "WTF_IMPLEMENTATION=1" ]

  public_configs = [
    ":wtf_config",
    "//third_party/blink/renderer:features",
  ]

  deps = [
    "//base/allocator:buildflags",
    "//build:chromeos_buildflags",
    "//third_party/blink/public/common:common",
    "//third_party/modp_b64",
    "//third_party/rapidhash",

    # TODO(tkent): WTF should not depend on it.
    "//third_party/blink/public/common:headers",
  ]

  public_deps = [
    "//base",
    "//base/third_party/double_conversion",
    "//components/crash/core/common:crash_key",
    "//third_party/icu",
  ]

  public_deps += [ "//v8:cppgc_headers" ]

  # Rules changing the |sources| list are temporarily commented out, until
  # those files are actually moved to here.

  if (is_apple) {
    sources += [
      "text/atomic_string_cf.cc",
      "text/string_apple.mm",
      "text/string_impl_apple.mm",
    ]
  }

  if (is_win) {
    cflags = [ "/wd4068" ]  # Unknown pragma.

    # Inject Visual Studio debug visualizers for our types into all targets
    # that reference this.
    all_dependent_configs = [ "//tools/win/DebugVisualizers:blink" ]
    inputs = [
      # blink.natvis listed as an input here instead of in
      # //tools/win/DebugVisualizers:blink to prevent unnecessary size increase
      # in generated build files.
      "//tools/win/DebugVisualizers/blink.natvis",
    ]
  }

  if (is_android) {
    libs = [ "log" ]
  }

  if (is_apple) {
    frameworks = [
      "CoreFoundation.framework",
      "Foundation.framework",
    ]
  }

  if (using_mismatched_sample_profile) {
    configs -= [ "//build/config/compiler:afdo_optimize_size" ]
  }

  configs -= [ "//build/config/compiler:default_symbols" ]
  configs += blink_symbols_config
}

test("wtf_unittests") {
  deps = [ ":wtf_unittests_sources" ]
}

source_set("wtf_unittests_sources") {
  visibility = []  # Allow re-assignment of list.
  visibility = [ "*" ]
  testonly = true

  sources = [
    "allocator/allocator_test.cc",
    "allocator/partitions_test.cc",
    "assertions_test.cc",
    "atomic_operations_test.cc",
    "bit_field_test.cc",
    "bloom_filter_test.cc",
    "casting_test.cc",
    "cross_thread_functional_test.cc",
    "decimal_test.cc",
    "deque_test.cc",
    "doubly_linked_list_test.cc",
    "dtoa_test.cc",
    "functional_test.cc",
    "hash_map_test.cc",
    "hash_set_test.cc",
    "linked_hash_set_test.cc",
    "math_extras_test.cc",
    "pod_arena_test.cc",
    "pod_arena_test_helpers.h",
    "pod_free_list_arena_test.cc",
    "pod_interval_tree_test.cc",
    "pod_red_black_tree_test.cc",
    "pod_tree_test_helpers.cc",
    "pod_tree_test_helpers.h",
    "sequence_bound_test.cc",
    "shared_buffer_test.cc",
    "testing/run_all_tests.cc",
    "text/ascii_ctype_test.cc",
    "text/atomic_string_table_test.cc",
    "text/atomic_string_test.cc",
    "text/base64_test.cc",
    "text/case_map_test.cc",
    "text/code_point_iterator_test.cc",
    "text/encoding_tables_test.cc",
    "text/integer_to_string_conversion_test.cc",
    "text/line_ending_test.cc",
    "text/math_transform_test.cc",
    "text/string_buffer_test.cc",
    "text/string_builder_test.cc",
    "text/string_hasher_test.cc",
    "text/string_impl_test.cc",
    "text/string_to_number_test.cc",
    "text/string_view_test.cc",
    "text/text_codec_cjk_test.cc",
    "text/text_codec_icu_test.cc",
    "text/text_codec_replacement_test.cc",
    "text/text_codec_test.cc",
    "text/text_codec_utf8_test.cc",
    "text/text_encoding_test.cc",
    "text/text_offset_map_test.cc",
    "text/wtf_string_test.cc",
    "threading_primitives_test.cc",
    "type_traits_test.cc",
    "uuid_test.cc",
    "vector_backed_linked_list_test.cc",
    "vector_test.cc",
  ]

  if (is_win) {
    cflags = [ "/wd4068" ]  # Unknown pragma.
  }

  configs += [
    "//third_party/blink/renderer:config",
    "//third_party/blink/renderer:blink_pch",
  ]

  deps = [
    ":wtf",
    "//base",
    "//base/test:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]
}