chromium/base/BUILD.gn

# Copyright 2013 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# HOW TO WRITE CONDITIONALS IN THIS FILE
# ======================================
#
# In many other places, one would write a conditional that expresses all the
# cases when a source file is used or unused, and then either add or subtract
# it from the sources list in that case
#
# Since base includes so many low-level things that vary widely and
# unpredictably for the various build types, we prefer a slightly different
# style. Instead, there are big per-platform blocks of inclusions and
# exclusions. If a given file has an inclusion or exclusion rule that applies
# for multiple conditions, prefer to duplicate it in both lists. This makes it
# a bit easier to see which files apply in which cases rather than having a
# huge sequence of random-looking conditionals.

import("//base/allocator/allocator.gni")
import("//base/allocator/partition_allocator/partition_alloc.gni")
import("//base/debug/debug.gni")
import("//base/trace_event/tracing.gni")
import("//build/buildflag_header.gni")
import("//build/config/arm.gni")
import("//build/config/c++/c++.gni")
import("//build/config/cast.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/cronet/config.gni")
import("//build/config/dcheck_always_on.gni")
import("//build/config/ios/config.gni")
import("//build/config/logging.gni")
import("//build/config/nacl/config.gni")
import("//build/config/profiling/profiling.gni")
import("//build/config/rust.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/sysroot.gni")
import("//build/config/ui.gni")
import("//build/nocompile.gni")
import("//build/timestamp.gni")
import("//build/util/process_version.gni")
import("//build_overrides/build.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")

if (is_ios) {
  # Used to access ios_is_app_extension variable definition.
  import("//build/config/ios/ios_sdk.gni")
}

if (is_mac) {
  # Used to generate fuzzer corpus :base_mach_port_rendezvous_convert_corpus.
  import("//third_party/protobuf/proto_library.gni")
}

if (is_win) {
  import("//build/config/win/control_flow_guard.gni")
}

declare_args() {
  # Unsafe developer build. Has developer-friendly features that may weaken or
  # disable security measures like sandboxing or ASLR.
  # IMPORTANT: Unsafe developer builds should never be distributed to end users.
  is_unsafe_developer_build = !is_official_build

  # Set to true to disable COM init check hooks.
  com_init_check_hook_disabled = false

  # Set to true to enable mutex priority inheritance. See the comments in
  # LockImpl::PriorityInheritanceAvailable() in lock_impl_posix.cc for the
  # platform requirements to safely enable priority inheritance.
  enable_mutex_priority_inheritance = false

  # Control whether the ios stack sampling profiler is enabled. This flag is
  # only supported on iOS 64-bit architecture, but some project build //base
  # for 32-bit architecture.
  ios_stack_profiler_enabled = true
}

# Mutex priority inheritance is disabled by default due to security
# vulnerabilities in older versions of Linux kernel and glibc. However,
# Chromecast builds have full control over the platform and ensure that
# the kernel and glibc versions used have patched the vulnerabilities,
# so it is safe to use mutex priority inheritance on Chromecast platform.
assert(!enable_mutex_priority_inheritance || is_castos || is_cast_android,
       "Do not enable PI mutexes without consulting the security team")

assert(!is_nacl || is_nacl_saigo,
       "base must not be built in most nacl toolchains")

# This is here instead of in //build because //build is DEPS'd in by a few
# subprojects that still support MSVC.
assert(!is_win || is_clang,
       "only clang-cl is supported on Windows, see https://crbug.com/988071")

if (is_android || is_robolectric) {
  import("//build/config/android/rules.gni")
  import("//third_party/jni_zero/jni_zero.gni")
}

if (is_fuchsia) {
  import("//third_party/fuchsia-gn-sdk/src/fidl_library.gni")
}

# The Rust implementation of base::JSONReader. NaCl depends on base and doesn't
# have a Rust toolchain, so we need a fallback to C++ for it until it removes
# its dependency on //base.
#
# TODO(crbug.com/40811643): Drop toolchain_has_rust and move the C++ parser into
# components/nacl to just run in-process there. Don't compile base::JSONReader
# on NaCL at all.
build_rust_json_reader = toolchain_has_rust && enable_rust_json

# Rust to C++ type conversions. Also can not be enabled while NaCl depends on
# //base.
build_rust_base_conversions = toolchain_has_rust && enable_rust_base_conversions

assert(build_rust_base_conversions || !build_rust_json_reader,
       "Cannot enable Rust JSON decoder without also base conversions")

buildflag_header("rust_buildflags") {
  header = "rust_buildflags.h"
  flags = [
    "BUILD_RUST_JSON_READER=$build_rust_json_reader",
    "BUILD_RUST_BASE_CONVERSIONS=$build_rust_base_conversions",
  ]
}

if (is_win) {
  # This is in a separate config so the flags can be applied to dependents.
  # ldflags in GN aren't automatically inherited.
  config("base_win_linker_flags") {
    ldflags = [
      # Linking with shcore.lib causes the shcore api forwarder dll to load.
      "/DELAYLOAD:api-ms-win-shcore-scaling-l1-1-1.dll",

      # Linking with OneCore.lib causes the next three dlls to load.
      "/DELAYLOAD:api-ms-win-core-realtime-l1-1-1.dll",
      "/DELAYLOAD:api-ms-win-power-base-l1-1-0.dll",
      "/DELAYLOAD:api-ms-win-power-setting-l1-1-0.dll",
      "/DELAYLOAD:cfgmgr32.dll",
      "/DELAYLOAD:powrprof.dll",
      "/DELAYLOAD:setupapi.dll",
      "/DELAYLOAD:shcore.dll",
    ]
  }
}

if (is_android) {
  config("android_system_libs") {
    libs = [
      "android",
      "log",  # Used by logging.cc.
    ]
  }
}

if (is_fuchsia) {
  config("fuchsia_sync_lib") {
    libs = [
      "sync",  # Used by spinning_mutex.h.
    ]
  }
}

buildflag_header("ios_cronet_buildflags") {
  header = "ios_cronet_buildflags.h"
  header_dir = "base/message_loop"
  flags = [ "CRONET_BUILD=$is_cronet_build" ]
}

use_epoll = is_linux || is_chromeos || is_android

# Base and everything it depends on should be a static library rather than
# a source set. Base is more of a "library" in the classic sense in that many
# small parts of it are used in many different contexts. This combined with a
# few static initializers floating around means that dead code stripping
# still leaves a lot of code behind that isn't always used. For example, this
# saves more than 40K for a smaller target like chrome_elf.
#
# Use static libraries for the helper stuff as well for things like
# //base/debug since those targets refer back to base code, which will force
# base compilation units to be linked in where they wouldn't have otherwise.
# This does not include test code (test support and anything in the test
# directory) which should use source_set as is recommended for GN targets).
component("base") {
  sources = [
    "allocator/allocator_check.cc",
    "allocator/allocator_check.h",
    "allocator/dispatcher/configuration.h",
    "allocator/dispatcher/dispatcher.cc",
    "allocator/dispatcher/dispatcher.h",
    "allocator/dispatcher/initializer.h",
    "allocator/dispatcher/internal/dispatch_data.cc",
    "allocator/dispatcher/internal/dispatch_data.h",
    "allocator/dispatcher/internal/dispatcher_internal.h",
    "allocator/dispatcher/internal/tools.h",
    "allocator/dispatcher/memory_tagging.cc",
    "allocator/dispatcher/memory_tagging.h",
    "allocator/dispatcher/notification_data.h",
    "allocator/dispatcher/reentry_guard.cc",
    "allocator/dispatcher/reentry_guard.h",
    "allocator/dispatcher/subsystem.h",
    "allocator/dispatcher/tls.cc",
    "allocator/dispatcher/tls.h",
    "at_exit.cc",
    "at_exit.h",
    "atomic_ref_count.h",
    "atomic_sequence_num.h",
    "atomicops.h",
    "atomicops_internals_atomicword_compat.h",
    "atomicops_internals_portable.h",
    "auto_reset.h",
    "barrier_callback.h",
    "barrier_closure.cc",
    "barrier_closure.h",
    "base64.cc",
    "base64.h",
    "base64url.cc",
    "base64url.h",
    "base_switches.h",
    "big_endian.h",
    "bit_cast.h",
    "bits.h",
    "build_time.h",
    "callback_list.cc",
    "callback_list.h",
    "cancelable_callback.h",
    "check.cc",
    "check.h",
    "check_deref.h",
    "check_is_test.cc",
    "check_is_test.h",
    "check_op.cc",
    "check_op.h",
    "command_line.cc",
    "command_line.h",
    "compiler_specific.h",
    "component_export.h",
    "containers/adapters.h",
    "containers/buffer_iterator.h",
    "containers/checked_iterators.h",
    "containers/circular_deque.h",
    "containers/contains.h",
    "containers/dynamic_extent.h",
    "containers/enum_set.h",
    "containers/extend.h",
    "containers/fixed_flat_map.h",
    "containers/fixed_flat_set.h",
    "containers/flat_map.h",
    "containers/flat_set.h",
    "containers/flat_tree.h",
    "containers/heap_array.h",
    "containers/id_map.h",
    "containers/intrusive_heap.cc",
    "containers/intrusive_heap.h",
    "containers/linked_list.cc",
    "containers/linked_list.h",
    "containers/lru_cache.h",
    "containers/map_util.h",
    "containers/small_map.h",
    "containers/span.h",
    "containers/span_or_size.h",
    "containers/span_reader.h",
    "containers/span_writer.h",
    "containers/stack.h",
    "containers/to_value_list.h",
    "containers/to_vector.h",
    "containers/unique_ptr_adapters.h",
    "containers/util.h",
    "containers/vector_buffer.h",
    "cpu_reduction_experiment.cc",
    "cpu_reduction_experiment.h",
    "critical_closure.h",
    "dcheck_is_on.h",
    "debug/alias.cc",
    "debug/alias.h",
    "debug/asan_invalid_access.cc",
    "debug/asan_invalid_access.h",
    "debug/asan_service.cc",
    "debug/asan_service.h",
    "debug/debugger.cc",
    "debug/debugger.h",
    "debug/dump_without_crashing.cc",
    "debug/dump_without_crashing.h",
    "debug/leak_annotations.h",
    "debug/profiler.cc",
    "debug/profiler.h",
    "debug/task_trace.cc",
    "debug/task_trace.h",
    "environment.cc",
    "environment.h",
    "export_template.h",
    "feature_list.cc",
    "feature_list.h",
    "features.cc",
    "features.h",
    "file_version_info.h",
    "files/block_tests_writing_to_special_dirs.cc",
    "files/block_tests_writing_to_special_dirs.h",
    "files/dir_reader_fallback.h",
    "files/file.cc",
    "files/file.h",
    "files/file_error_or.h",
    "files/file_path.cc",
    "files/file_path.h",
    "files/file_tracing.cc",
    "files/file_tracing.h",
    "files/memory_mapped_file.cc",
    "files/memory_mapped_file.h",
    "files/platform_file.h",
    "files/safe_base_name.cc",
    "files/safe_base_name.h",
    "files/scoped_file.cc",
    "files/scoped_file.h",
    "format_macros.h",
    "functional/bind.h",
    "functional/bind_internal.h",
    "functional/callback.h",
    "functional/callback_forward.h",
    "functional/callback_helpers.cc",
    "functional/callback_helpers.h",
    "functional/callback_internal.cc",
    "functional/callback_internal.h",
    "functional/callback_tags.h",
    "functional/concurrent_callbacks.h",
    "functional/concurrent_closures.cc",
    "functional/concurrent_closures.h",
    "functional/disallow_unretained.h",
    "functional/function_ref.h",
    "functional/overloaded.h",
    "functional/unretained_traits.h",
    "gtest_prod_util.h",
    "hash/hash.cc",
    "hash/hash.h",
    "hash/legacy_hash.cc",
    "hash/legacy_hash.h",
    "json/json_common.h",
    "json/json_parser.cc",
    "json/json_parser.h",
    "json/json_reader.cc",
    "json/json_reader.h",
    "json/json_string_value_serializer.cc",
    "json/json_string_value_serializer.h",
    "json/json_value_converter.cc",
    "json/json_value_converter.h",
    "json/json_writer.cc",
    "json/json_writer.h",
    "json/string_escape.cc",
    "json/string_escape.h",
    "json/values_util.cc",
    "json/values_util.h",
    "lazy_instance.h",
    "lazy_instance_helpers.cc",
    "lazy_instance_helpers.h",
    "linux_util.cc",
    "linux_util.h",
    "location.cc",
    "location.h",
    "logging.cc",
    "logging.h",
    "macros/concat.h",
    "macros/if.h",
    "macros/is_empty.h",
    "macros/remove_parens.h",
    "macros/uniquify.h",
    "memory/aligned_memory.cc",
    "memory/aligned_memory.h",
    "memory/free_deleter.h",
    "memory/memory_pressure_listener.cc",
    "memory/memory_pressure_listener.h",
    "memory/memory_pressure_monitor.cc",
    "memory/memory_pressure_monitor.h",
    "memory/page_size.h",
    "memory/platform_shared_memory_handle.cc",
    "memory/platform_shared_memory_handle.h",
    "memory/platform_shared_memory_mapper.h",
    "memory/platform_shared_memory_region.cc",
    "memory/platform_shared_memory_region.h",
    "memory/post_delayed_memory_reduction_task.cc",
    "memory/post_delayed_memory_reduction_task.h",
    "memory/protected_memory.h",
    "memory/ptr_util.h",
    "memory/raw_ptr.h",
    "memory/raw_ptr_asan_bound_arg_tracker.cc",
    "memory/raw_ptr_asan_bound_arg_tracker.h",
    "memory/raw_ptr_asan_hooks.cc",
    "memory/raw_ptr_asan_hooks.h",
    "memory/raw_ptr_asan_service.cc",
    "memory/raw_ptr_asan_service.h",
    "memory/raw_ptr_cast.h",
    "memory/raw_ptr_exclusion.h",
    "memory/raw_ref.h",
    "memory/raw_scoped_refptr_mismatch_checker.h",
    "memory/raw_span.h",
    "memory/read_only_shared_memory_region.cc",
    "memory/read_only_shared_memory_region.h",
    "memory/ref_counted.cc",
    "memory/ref_counted.h",
    "memory/ref_counted_delete_on_sequence.h",
    "memory/ref_counted_memory.cc",
    "memory/ref_counted_memory.h",
    "memory/safe_ref.h",
    "memory/safe_ref_traits.h",
    "memory/safety_checks.h",
    "memory/scoped_policy.h",
    "memory/scoped_refptr.h",
    "memory/shared_memory_hooks.h",
    "memory/shared_memory_mapper.cc",
    "memory/shared_memory_mapper.h",
    "memory/shared_memory_mapping.cc",
    "memory/shared_memory_mapping.h",
    "memory/shared_memory_safety_checker.h",
    "memory/shared_memory_security_policy.cc",
    "memory/shared_memory_security_policy.h",
    "memory/shared_memory_tracker.cc",
    "memory/shared_memory_tracker.h",
    "memory/singleton.h",
    "memory/stack_allocated.h",
    "memory/structured_shared_memory.h",
    "memory/unsafe_shared_memory_pool.cc",
    "memory/unsafe_shared_memory_pool.h",
    "memory/unsafe_shared_memory_region.cc",
    "memory/unsafe_shared_memory_region.h",
    "memory/values_equivalent.h",
    "memory/weak_auto_reset.h",
    "memory/weak_ptr.cc",
    "memory/weak_ptr.h",
    "memory/writable_shared_memory_region.cc",
    "memory/writable_shared_memory_region.h",
    "message_loop/message_pump.cc",
    "message_loop/message_pump.h",
    "message_loop/message_pump_default.cc",
    "message_loop/message_pump_default.h",
    "message_loop/message_pump_for_io.h",
    "message_loop/message_pump_for_ui.h",
    "message_loop/message_pump_type.h",
    "message_loop/work_id_provider.cc",
    "message_loop/work_id_provider.h",
    "metrics/bucket_ranges.cc",
    "metrics/bucket_ranges.h",
    "metrics/crc32.cc",
    "metrics/crc32.h",
    "metrics/dummy_histogram.cc",
    "metrics/dummy_histogram.h",
    "metrics/field_trial.cc",
    "metrics/field_trial.h",
    "metrics/field_trial_list_including_low_anonymity.cc",
    "metrics/field_trial_list_including_low_anonymity.h",
    "metrics/field_trial_param_associator.cc",
    "metrics/field_trial_param_associator.h",
    "metrics/field_trial_params.cc",
    "metrics/field_trial_params.h",
    "metrics/histogram.cc",
    "metrics/histogram.h",
    "metrics/histogram_base.cc",
    "metrics/histogram_base.h",
    "metrics/histogram_delta_serialization.cc",
    "metrics/histogram_delta_serialization.h",
    "metrics/histogram_flattener.h",
    "metrics/histogram_functions.cc",
    "metrics/histogram_functions.h",
    "metrics/histogram_functions_internal_overloads.h",
    "metrics/histogram_macros.h",
    "metrics/histogram_macros_internal.h",
    "metrics/histogram_macros_local.h",
    "metrics/histogram_samples.cc",
    "metrics/histogram_samples.h",
    "metrics/histogram_snapshot_manager.cc",
    "metrics/histogram_snapshot_manager.h",
    "metrics/metrics_hashes.cc",
    "metrics/metrics_hashes.h",
    "metrics/persistent_histogram_allocator.cc",
    "metrics/persistent_histogram_allocator.h",
    "metrics/persistent_memory_allocator.cc",
    "metrics/persistent_memory_allocator.h",
    "metrics/persistent_sample_map.cc",
    "metrics/persistent_sample_map.h",
    "metrics/ranges_manager.cc",
    "metrics/ranges_manager.h",
    "metrics/record_histogram_checker.h",
    "metrics/sample_map.cc",
    "metrics/sample_map.h",
    "metrics/sample_vector.cc",
    "metrics/sample_vector.h",
    "metrics/single_sample_metrics.cc",
    "metrics/single_sample_metrics.h",
    "metrics/sparse_histogram.cc",
    "metrics/sparse_histogram.h",
    "metrics/statistics_recorder.cc",
    "metrics/statistics_recorder.h",
    "metrics/user_metrics.cc",
    "metrics/user_metrics.h",
    "metrics/user_metrics_action.h",
    "no_destructor.h",
    "not_fatal_until.h",
    "notimplemented.h",
    "notreached.h",
    "observer_list.h",
    "observer_list_internal.cc",
    "observer_list_internal.h",
    "observer_list_threadsafe.cc",
    "observer_list_threadsafe.h",
    "observer_list_types.cc",
    "observer_list_types.h",
    "one_shot_event.cc",
    "one_shot_event.h",
    "parameter_pack.h",
    "pending_task.cc",
    "pending_task.h",
    "pickle.cc",
    "pickle.h",
    "power_monitor/battery_level_provider.cc",
    "power_monitor/battery_level_provider.h",
    "power_monitor/battery_state_sampler.cc",
    "power_monitor/battery_state_sampler.h",
    "power_monitor/cpu_frequency_utils.cc",
    "power_monitor/cpu_frequency_utils.h",
    "power_monitor/power_monitor.cc",
    "power_monitor/power_monitor.h",
    "power_monitor/power_monitor_device_source.cc",
    "power_monitor/power_monitor_device_source.h",
    "power_monitor/power_monitor_features.cc",
    "power_monitor/power_monitor_features.h",
    "power_monitor/power_monitor_source.cc",
    "power_monitor/power_monitor_source.h",
    "power_monitor/power_observer.h",
    "power_monitor/sampling_event_source.cc",
    "power_monitor/sampling_event_source.h",
    "power_monitor/timer_sampling_event_source.cc",
    "power_monitor/timer_sampling_event_source.h",
    "process/current_process.cc",
    "process/current_process.h",
    "process/current_process_test.h",
    "process/environment_internal.cc",
    "process/environment_internal.h",
    "process/process.h",
    "process/process_handle.cc",
    "process/process_handle.h",
    "process/process_info.h",
    "process/set_process_title.cc",
    "process/set_process_title.h",
    "profiler/call_stack_profile_params.h",
    "profiler/frame.cc",
    "profiler/frame.h",
    "profiler/metadata_recorder.cc",
    "profiler/metadata_recorder.h",
    "profiler/module_cache.cc",
    "profiler/module_cache.h",
    "profiler/process_type.h",
    "profiler/profile_builder.h",
    "profiler/register_context.h",
    "profiler/sample_metadata.cc",
    "profiler/sample_metadata.h",
    "profiler/sampling_profiler_thread_token.cc",
    "profiler/sampling_profiler_thread_token.h",
    "profiler/stack_buffer.cc",
    "profiler/stack_buffer.h",
    "profiler/stack_copier.cc",
    "profiler/stack_copier.h",
    "profiler/stack_copier_suspend.cc",
    "profiler/stack_copier_suspend.h",
    "profiler/stack_sampler.cc",
    "profiler/stack_sampler.h",
    "profiler/stack_sampling_profiler.cc",
    "profiler/stack_sampling_profiler.h",
    "profiler/stack_unwind_data.cc",
    "profiler/stack_unwind_data.h",
    "profiler/suspendable_thread_delegate.h",
    "profiler/thread_delegate.h",
    "profiler/unwinder.cc",
    "profiler/unwinder.h",
    "rand_util.cc",
    "rand_util.h",
    "ranges/algorithm.h",
    "ranges/from_range.h",
    "ranges/functional.h",
    "ranges/ranges.h",
    "run_loop.cc",
    "run_loop.h",
    "sampling_heap_profiler/lock_free_address_hash_set.cc",
    "sampling_heap_profiler/lock_free_address_hash_set.h",
    "sampling_heap_profiler/poisson_allocation_sampler.cc",
    "sampling_heap_profiler/poisson_allocation_sampler.h",
    "sampling_heap_profiler/sampling_heap_profiler.cc",
    "sampling_heap_profiler/sampling_heap_profiler.h",
    "scoped_add_feature_flags.cc",
    "scoped_add_feature_flags.h",
    "scoped_clear_last_error.h",
    "scoped_environment_variable_override.cc",
    "scoped_environment_variable_override.h",
    "scoped_generic.h",
    "scoped_multi_source_observation.h",
    "scoped_observation.h",
    "scoped_observation_traits.h",
    "sequence_checker.cc",
    "sequence_checker.h",
    "sequence_checker_impl.cc",
    "sequence_checker_impl.h",
    "sequence_token.cc",
    "sequence_token.h",
    "state_transitions.h",
    "stl_util.h",
    "strings/abseil_string_number_conversions.cc",
    "strings/abseil_string_number_conversions.h",
    "strings/cstring_view.h",
    "strings/escape.cc",
    "strings/escape.h",
    "strings/latin1_string_conversions.cc",
    "strings/latin1_string_conversions.h",
    "strings/levenshtein_distance.cc",
    "strings/levenshtein_distance.h",
    "strings/pattern.cc",
    "strings/pattern.h",
    "strings/safe_sprintf.cc",
    "strings/safe_sprintf.h",
    "strings/strcat.cc",
    "strings/strcat.h",
    "strings/strcat_internal.h",
    "strings/string_number_conversions.cc",
    "strings/string_number_conversions.h",
    "strings/string_number_conversions_internal.h",
    "strings/string_split.cc",
    "strings/string_split.h",
    "strings/string_split_internal.h",
    "strings/string_tokenizer.h",
    "strings/string_util.cc",
    "strings/string_util.h",
    "strings/string_util_constants.cc",
    "strings/string_util_impl_helpers.h",
    "strings/string_util_internal.h",
    "strings/stringize_macros.h",
    "strings/stringprintf.cc",
    "strings/stringprintf.h",
    "strings/sys_string_conversions.h",
    "strings/to_string.h",
    "strings/utf_offset_string_conversions.cc",
    "strings/utf_offset_string_conversions.h",
    "strings/utf_ostream_operators.cc",
    "strings/utf_ostream_operators.h",
    "strings/utf_string_conversion_utils.cc",
    "strings/utf_string_conversion_utils.h",
    "strings/utf_string_conversions.cc",
    "strings/utf_string_conversions.h",
    "substring_set_matcher/matcher_string_pattern.cc",
    "substring_set_matcher/matcher_string_pattern.h",
    "substring_set_matcher/substring_set_matcher.cc",
    "substring_set_matcher/substring_set_matcher.h",
    "supports_user_data.cc",
    "supports_user_data.h",
    "synchronization/atomic_flag.cc",
    "synchronization/atomic_flag.h",
    "synchronization/condition_variable.h",
    "synchronization/lock.cc",
    "synchronization/lock.h",
    "synchronization/lock_impl.h",
    "synchronization/lock_subtle.h",
    "synchronization/waitable_event.cc",
    "synchronization/waitable_event.h",
    "synchronization/waitable_event_watcher.h",
    "sys_byteorder.h",
    "syslog_logging.cc",
    "syslog_logging.h",
    "system/system_monitor.cc",
    "system/system_monitor.h",
    "task/bind_post_task.h",
    "task/bind_post_task_internal.h",
    "task/cancelable_task_tracker.cc",
    "task/cancelable_task_tracker.h",
    "task/common/checked_lock.h",
    "task/common/checked_lock_impl.cc",
    "task/common/checked_lock_impl.h",
    "task/common/lazy_now.cc",
    "task/common/lazy_now.h",
    "task/common/operations_controller.cc",
    "task/common/operations_controller.h",
    "task/common/scoped_defer_task_posting.cc",
    "task/common/scoped_defer_task_posting.h",
    "task/common/task_annotator.cc",
    "task/common/task_annotator.h",
    "task/current_thread.cc",
    "task/current_thread.h",
    "task/default_delayed_task_handle_delegate.cc",
    "task/default_delayed_task_handle_delegate.h",
    "task/deferred_sequenced_task_runner.cc",
    "task/deferred_sequenced_task_runner.h",
    "task/delay_policy.h",
    "task/delayed_task_handle.cc",
    "task/delayed_task_handle.h",
    "task/lazy_thread_pool_task_runner.cc",
    "task/lazy_thread_pool_task_runner.h",
    "task/post_job.cc",
    "task/post_job.h",
    "task/post_task_and_reply_with_result_internal.h",
    "task/scoped_set_task_priority_for_current_thread.cc",
    "task/scoped_set_task_priority_for_current_thread.h",
    "task/sequence_manager/associated_thread_id.cc",
    "task/sequence_manager/associated_thread_id.h",
    "task/sequence_manager/atomic_flag_set.cc",
    "task/sequence_manager/atomic_flag_set.h",
    "task/sequence_manager/delayed_task_handle_delegate.cc",
    "task/sequence_manager/delayed_task_handle_delegate.h",
    "task/sequence_manager/enqueue_order.h",
    "task/sequence_manager/enqueue_order_generator.cc",
    "task/sequence_manager/enqueue_order_generator.h",
    "task/sequence_manager/fence.cc",
    "task/sequence_manager/fence.h",
    "task/sequence_manager/lazily_deallocated_deque.h",
    "task/sequence_manager/sequence_manager.cc",
    "task/sequence_manager/sequence_manager.h",
    "task/sequence_manager/sequence_manager_impl.cc",
    "task/sequence_manager/sequence_manager_impl.h",
    "task/sequence_manager/sequenced_task_source.cc",
    "task/sequence_manager/sequenced_task_source.h",
    "task/sequence_manager/task_order.cc",
    "task/sequence_manager/task_order.h",
    "task/sequence_manager/task_queue.cc",
    "task/sequence_manager/task_queue.h",
    "task/sequence_manager/task_queue_impl.cc",
    "task/sequence_manager/task_queue_impl.h",
    "task/sequence_manager/task_queue_selector.cc",
    "task/sequence_manager/task_queue_selector.h",
    "task/sequence_manager/task_time_observer.cc",
    "task/sequence_manager/task_time_observer.h",
    "task/sequence_manager/tasks.cc",
    "task/sequence_manager/tasks.h",
    "task/sequence_manager/thread_controller.cc",
    "task/sequence_manager/thread_controller.h",
    "task/sequence_manager/thread_controller_impl.cc",
    "task/sequence_manager/thread_controller_impl.h",
    "task/sequence_manager/thread_controller_power_monitor.cc",
    "task/sequence_manager/thread_controller_power_monitor.h",
    "task/sequence_manager/thread_controller_with_message_pump_impl.cc",
    "task/sequence_manager/thread_controller_with_message_pump_impl.h",
    "task/sequence_manager/time_domain.cc",
    "task/sequence_manager/time_domain.h",
    "task/sequence_manager/wake_up_queue.cc",
    "task/sequence_manager/wake_up_queue.h",
    "task/sequence_manager/work_deduplicator.cc",
    "task/sequence_manager/work_deduplicator.h",
    "task/sequence_manager/work_queue.cc",
    "task/sequence_manager/work_queue.h",
    "task/sequence_manager/work_queue_sets.cc",
    "task/sequence_manager/work_queue_sets.h",
    "task/sequence_manager/work_tracker.cc",
    "task/sequence_manager/work_tracker.h",
    "task/sequenced_task_runner.cc",
    "task/sequenced_task_runner.h",
    "task/sequenced_task_runner_helpers.h",
    "task/single_thread_task_executor.cc",
    "task/single_thread_task_executor.h",
    "task/single_thread_task_runner.cc",
    "task/single_thread_task_runner.h",
    "task/single_thread_task_runner_thread_mode.h",
    "task/task_features.cc",
    "task/task_features.h",
    "task/task_observer.h",
    "task/task_runner.cc",
    "task/task_runner.h",
    "task/task_traits.cc",
    "task/task_traits.h",
    "task/thread_pool.cc",
    "task/thread_pool.h",
    "task/thread_pool/delayed_priority_queue.cc",
    "task/thread_pool/delayed_priority_queue.h",
    "task/thread_pool/delayed_task_manager.cc",
    "task/thread_pool/delayed_task_manager.h",
    "task/thread_pool/environment_config.cc",
    "task/thread_pool/environment_config.h",
    "task/thread_pool/job_task_source.cc",
    "task/thread_pool/job_task_source.h",
    "task/thread_pool/pooled_parallel_task_runner.cc",
    "task/thread_pool/pooled_parallel_task_runner.h",
    "task/thread_pool/pooled_sequenced_task_runner.cc",
    "task/thread_pool/pooled_sequenced_task_runner.h",
    "task/thread_pool/pooled_single_thread_task_runner_manager.cc",
    "task/thread_pool/pooled_single_thread_task_runner_manager.h",
    "task/thread_pool/pooled_task_runner_delegate.cc",
    "task/thread_pool/pooled_task_runner_delegate.h",
    "task/thread_pool/priority_queue.cc",
    "task/thread_pool/priority_queue.h",
    "task/thread_pool/sequence.cc",
    "task/thread_pool/sequence.h",
    "task/thread_pool/service_thread.cc",
    "task/thread_pool/service_thread.h",
    "task/thread_pool/task.cc",
    "task/thread_pool/task.h",
    "task/thread_pool/task_source.cc",
    "task/thread_pool/task_source.h",
    "task/thread_pool/task_source_sort_key.cc",
    "task/thread_pool/task_source_sort_key.h",
    "task/thread_pool/task_tracker.cc",
    "task/thread_pool/task_tracker.h",
    "task/thread_pool/thread_group.cc",
    "task/thread_pool/thread_group.h",
    "task/thread_pool/thread_group_impl.cc",
    "task/thread_pool/thread_group_impl.h",
    "task/thread_pool/thread_pool_impl.cc",
    "task/thread_pool/thread_pool_impl.h",
    "task/thread_pool/thread_pool_instance.cc",
    "task/thread_pool/thread_pool_instance.h",
    "task/thread_pool/tracked_ref.h",
    "task/thread_pool/worker_thread.cc",
    "task/thread_pool/worker_thread.h",
    "task/thread_pool/worker_thread_observer.h",
    "task/thread_pool/worker_thread_set.cc",
    "task/thread_pool/worker_thread_set.h",
    "task/updateable_sequenced_task_runner.h",
    "test/scoped_logging_settings.h",
    "test/spin_wait.h",
    "third_party/nspr/prtime.cc",
    "third_party/nspr/prtime.h",
    "thread_annotations.h",
    "threading/hang_watcher.cc",
    "threading/hang_watcher.h",
    "threading/platform_thread.cc",
    "threading/platform_thread.h",
    "threading/platform_thread_ref.cc",
    "threading/platform_thread_ref.h",
    "threading/post_task_and_reply_impl.cc",
    "threading/post_task_and_reply_impl.h",
    "threading/scoped_blocking_call.cc",
    "threading/scoped_blocking_call.h",
    "threading/scoped_blocking_call_internal.cc",
    "threading/scoped_blocking_call_internal.h",
    "threading/scoped_thread_priority.cc",
    "threading/scoped_thread_priority.h",
    "threading/sequence_bound.h",
    "threading/sequence_bound_internal.h",
    "threading/sequence_local_storage_map.cc",
    "threading/sequence_local_storage_map.h",
    "threading/sequence_local_storage_slot.cc",
    "threading/sequence_local_storage_slot.h",
    "threading/simple_thread.cc",
    "threading/simple_thread.h",
    "threading/thread.cc",
    "threading/thread.h",
    "threading/thread_checker.cc",
    "threading/thread_checker.h",
    "threading/thread_checker_impl.cc",
    "threading/thread_checker_impl.h",
    "threading/thread_collision_warner.cc",
    "threading/thread_collision_warner.h",
    "threading/thread_id_name_manager.cc",
    "threading/thread_id_name_manager.h",
    "threading/thread_local.h",
    "threading/thread_local_internal.h",
    "threading/thread_local_storage.cc",
    "threading/thread_local_storage.h",
    "threading/thread_restrictions.cc",
    "threading/thread_restrictions.h",
    "threading/threading_features.h",
    "threading/watchdog.cc",
    "threading/watchdog.h",
    "time/clock.cc",
    "time/clock.h",
    "time/default_clock.cc",
    "time/default_clock.h",
    "time/default_tick_clock.cc",
    "time/default_tick_clock.h",
    "time/tick_clock.cc",
    "time/tick_clock.h",
    "time/time.cc",
    "time/time.h",
    "time/time_delta_from_string.cc",
    "time/time_delta_from_string.h",
    "time/time_override.cc",
    "time/time_override.h",
    "timer/elapsed_timer.cc",
    "timer/elapsed_timer.h",
    "timer/hi_res_timer_manager.h",
    "timer/lap_timer.cc",
    "timer/lap_timer.h",
    "timer/timer.cc",
    "timer/timer.h",
    "timer/wall_clock_timer.cc",
    "timer/wall_clock_timer.h",
    "token.cc",
    "token.h",
    "trace_event/base_tracing.h",
    "trace_event/base_tracing_forward.h",
    "trace_event/common/trace_event_common.h",
    "trace_event/heap_profiler_allocation_context.cc",
    "trace_event/heap_profiler_allocation_context.h",
    "trace_event/heap_profiler_allocation_context_tracker.cc",
    "trace_event/heap_profiler_allocation_context_tracker.h",
    "trace_event/memory_allocator_dump_guid.cc",
    "trace_event/memory_allocator_dump_guid.h",
    "trace_event/named_trigger.cc",
    "trace_event/named_trigger.h",
    "trace_event/trace_id_helper.cc",
    "trace_event/trace_id_helper.h",
    "traits_bag.h",
    "tuple.h",
    "types/always_false.h",
    "types/cxx23_is_scoped_enum.h",
    "types/cxx23_to_underlying.h",
    "types/expected.h",
    "types/expected_internal.h",
    "types/expected_macros.h",
    "types/fixed_array.h",
    "types/id_type.h",
    "types/is_complete.h",
    "types/is_instantiation.h",
    "types/optional_ref.h",
    "types/optional_util.h",
    "types/pass_key.h",
    "types/strong_alias.h",
    "types/supports_ostream_operator.h",
    "types/to_address.h",
    "types/token_type.h",
    "types/variant_util.h",
    "unguessable_token.cc",
    "unguessable_token.h",
    "uuid.cc",
    "uuid.h",
    "value_iterators.cc",
    "value_iterators.h",
    "values.cc",
    "values.h",
    "version.cc",
    "version.h",
    "vlog.cc",
    "vlog.h",
  ]

  # Various files that are unused in the Chromium build, but presumably here to
  # make downstream's life easier. They are not included in the main sources
  # list to avoid breaking GN formatting's auto-sorting.
  sources += [
    #"process/process_handle_freebsd.cc",
    #"process/process_iterator_freebsd.cc",
    #"process/process_metrics_freebsd.cc",
    #"system/sys_info_freebsd.cc",
    #"process/process_iterator_openbsd.cc",
    #"process/process_handle_openbsd.cc",
    #"process/process_metrics_openbsd.cc",
    #"system/sys_info_openbsd.cc",
  ]

  if (is_apple || current_os == "freebsd" || current_os == "openbsd") {
    sources += [
      "posix/sysctl.cc",
      "posix/sysctl.h",
    ]
  }

  if (is_posix) {
    sources += [
      "debug/debugger_posix.cc",
      "file_descriptor_posix.cc",
      "file_descriptor_posix.h",
      "files/dir_reader_posix.h",
      "files/file_posix.cc",
      "files/memory_mapped_file_posix.cc",
      "memory/protected_memory_posix.cc",
      "message_loop/watchable_io_message_pump_posix.cc",
      "message_loop/watchable_io_message_pump_posix.h",
      "posix/eintr_wrapper.h",
      "posix/file_descriptor_shuffle.cc",
      "posix/file_descriptor_shuffle.h",
      "posix/global_descriptors.cc",
      "posix/global_descriptors.h",
      "posix/safe_strerror.cc",
      "posix/safe_strerror.h",
      "process/process_handle_posix.cc",
      "strings/string_util_posix.h",
      "synchronization/condition_variable_posix.cc",
      "synchronization/lock_impl_posix.cc",
      "threading/platform_thread_posix.cc",
      "threading/thread_local_storage_posix.cc",
      "time/time_conversion_posix.cc",
      "timer/hi_res_timer_manager_posix.cc",
    ]
  }

  if (is_linux || is_chromeos) {
    sources += [
      "debug/proc_maps_linux.cc",
      "debug/proc_maps_linux.h",
      "files/dir_reader_linux.h",
      "files/scoped_file_linux.cc",
      "process/internal_linux.cc",
      "process/internal_linux.h",
      "process/memory_linux.cc",
      "process/process_handle_linux.cc",
      "process/process_iterator_linux.cc",
      "process/process_linux.cc",
      "process/process_metrics_linux.cc",
      "threading/platform_thread_linux.cc",
      "threading/platform_thread_linux_base.cc",
      "threading/thread_type_delegate.cc",
      "threading/thread_type_delegate.h",
    ]
  }

  if (is_chromeos) {
    sources += [
      "process/process_priority_delegate.h",
      "threading/cross_process_platform_thread_delegate.h",
      "threading/platform_thread_cros.cc",
    ]
  }

  if (is_chromeos_ash) {
    sources += [ "feature_visitor.h" ]
  }

  if (is_linux || is_chromeos || is_android) {
    sources += [
      "files/file_path_watcher_inotify.cc",
      "files/file_path_watcher_inotify.h",
    ]
  }

  all_dependent_configs = []
  defines = [ "BASE_IMPLEMENTATION" ]
  data = []
  data_deps = []
  libs = []
  frameworks = []

  configs += [
    "//build/config:precompiled_headers",
    "//build/config/compiler:prevent_unsafe_narrowing",
    "//build/config/compiler:wexit_time_destructors",
    "//build/config/compiler:wglobal_constructors",
  ]

  deps = [
    ":check_version_internal",
    "//base/allocator:buildflags",
    "//base/third_party/cityhash",
    "//base/third_party/cityhash_v103",
    "//base/third_party/double_conversion",
    "//base/third_party/superfasthash",
    "//build:blink_buildflags",
    "//build:branding_buildflags",
    "//build:ios_buildflags",
    "//build/config/compiler:compiler_buildflags",
    "//third_party/modp_b64",
  ]
  if (!is_nacl) {
    # Used by metrics/crc32, except on NaCl builds.
    deps += [ "//third_party/zlib" ]
  }

  # `raw_ptr` cannot be made a component due to CRT symbol issues.
  # Its gateway to being a component is through `//base`, so we have
  # to provide the appropriate `#define` here.
  defines += [ "IS_RAW_PTR_IMPL" ]

  if (build_rust_json_reader) {
    deps += [ "//third_party/rust/serde_json_lenient/v0_2/wrapper" ]
  }

  # native_unwinder_android is intended for use solely via a dynamic feature
  # module, to avoid increasing Chrome's executable size.
  assert_no_deps = [ ":native_unwinder_android" ]

  public_deps = [
    ":anchor_functions_buildflags",
    ":base_static",
    ":build_date",
    ":cfi_buildflags",
    ":clang_profiling_buildflags",
    ":debugging_buildflags",
    ":feature_list_buildflags",
    ":ios_cronet_buildflags",
    ":logging_buildflags",
    ":orderfile_buildflags",
    ":power_monitor_buildflags",
    ":profiler_buildflags",
    ":protected_memory_buildflags",
    ":rust_buildflags",
    ":sanitizer_buildflags",
    ":synchronization_buildflags",
    ":tracing_buildflags",
    "//base/allocator/partition_allocator:buildflags",
    "//base/allocator/partition_allocator:raw_ptr",
    "//base/numerics:base_numerics",
    "//base/third_party/icu",
    "//build:chromecast_buildflags",
    "//build:chromeos_buildflags",
    "//third_party/abseil-cpp:absl",
  ]

  if (build_rust_base_conversions) {
    sources += [
      "containers/span_rust.h",
      "strings/string_view_rust.h",
    ]

    # Base provides conversions between CXX types and base types (e.g.
    # std::string_view).
    public_deps += [ "//build/rust:cxx_cppdeps" ]
  }

  # Needed for <atomic> if using newer C++ library than sysroot, except if
  # building inside the cros_sdk environment - use host_toolchain as a
  # more robust check for this.
  if (!use_sysroot && (is_android || is_chromeos || (is_linux && !is_castos)) &&
      host_toolchain != "//build/toolchain/cros:host") {
    libs += [ "atomic" ]
  }

  if (use_allocator_shim) {
    if (is_apple) {
      sources += [ "allocator/early_zone_registration_apple.h" ]
    }
  }

  if (use_clang_profiling) {
    # Call-sites use this conditional on the CLANG_PROFILING macro, for clarity.
    sources += [
      "test/clang_profiling.cc",
      "test/clang_profiling.h",
    ]
    if (is_android) {
      sources += [ "test/clang_profiling_android.cc" ]
    }
  }

  # Allow more direct string conversions on platforms with native utf8
  # strings
  if (is_apple || is_chromeos || is_castos || is_cast_android || is_fuchsia) {
    defines += [ "SYSTEM_NATIVE_UTF8" ]
  }

  # Android.
  if (is_android) {
    sources += [
      "android/android_hardware_buffer_compat.cc",
      "android/android_hardware_buffer_compat.h",
      "android/android_image_reader_compat.cc",
      "android/android_image_reader_compat.h",
      "android/apk_assets.cc",
      "android/apk_assets.h",
      "android/application_status_listener.cc",
      "android/application_status_listener.h",
      "android/base_feature_map.cc",
      "android/build_info.cc",
      "android/build_info.h",
      "android/bundle_utils.cc",
      "android/bundle_utils.h",
      "android/child_process_binding_types.h",
      "android/child_process_service.cc",
      "android/content_uri_utils.cc",
      "android/content_uri_utils.h",
      "android/cpu_features.cc",
      "android/early_trace_event_binding.cc",
      "android/early_trace_event_binding.h",
      "android/event_log.cc",
      "android/event_log.h",
      "android/feature_list_jni.cc",
      "android/feature_map.cc",
      "android/feature_map.h",
      "android/features_jni.cc",
      "android/field_trial_list.cc",
      "android/important_file_writer_android.cc",
      "android/input_hint_checker.cc",
      "android/input_hint_checker.h",
      "android/int_string_callback.cc",
      "android/int_string_callback.h",
      "android/jank_metric_uma_recorder.cc",
      "android/jank_metric_uma_recorder.h",
      "android/java_handler_thread.cc",
      "android/java_handler_thread.h",
      "android/java_heap_dump_generator.cc",
      "android/java_heap_dump_generator.h",
      "android/java_runtime.cc",
      "android/java_runtime.h",
      "android/library_loader/anchor_functions.cc",
      "android/library_loader/anchor_functions.h",
      "android/library_loader/library_prefetcher.cc",
      "android/library_loader/library_prefetcher.h",
      "android/library_loader/library_prefetcher_hooks.cc",
      "android/locale_utils.cc",
      "android/locale_utils.h",
      "android/meminfo_dump_provider.cc",
      "android/meminfo_dump_provider.h",
      "android/memory_pressure_listener_android.cc",
      "android/memory_pressure_listener_android.h",
      "android/memory_purge_manager_android.cc",
      "android/memory_purge_manager_android.h",
      "android/path_service_android.cc",
      "android/path_utils.cc",
      "android/path_utils.h",
      "android/pmf_utils.cc",
      "android/pmf_utils.h",
      "android/pre_freeze_background_memory_trimmer.cc",
      "android/pre_freeze_background_memory_trimmer.h",
      "android/radio_utils.cc",
      "android/radio_utils.h",
      "android/requires_api.h",
      "android/scoped_hardware_buffer_fence_sync.cc",
      "android/scoped_hardware_buffer_fence_sync.h",
      "android/scoped_hardware_buffer_handle.cc",
      "android/scoped_hardware_buffer_handle.h",
      "android/shared_preferences/shared_preferences_manager.cc",
      "android/shared_preferences/shared_preferences_manager.h",
      "android/statistics_recorder_android.cc",
      "android/sys_utils.cc",
      "android/sys_utils.h",
      "android/task_scheduler/post_task_android.cc",
      "android/task_scheduler/post_task_android.h",
      "android/task_scheduler/task_runner_android.cc",
      "android/task_scheduler/task_runner_android.h",
      "android/task_scheduler/task_traits_android.h",
      "android/thread_instruction_count.cc",
      "android/thread_instruction_count.h",
      "android/timezone_utils.cc",
      "android/timezone_utils.h",
      "debug/stack_trace_android.cc",
      "files/file_util_android.cc",
      "files/scoped_file_android.cc",
      "memory/platform_shared_memory_mapper_android.cc",
      "memory/platform_shared_memory_region_android.cc",
      "message_loop/message_pump_android.cc",
      "message_loop/message_pump_android.h",
      "os_compat_android.cc",
      "os_compat_android.h",
      "process/process_android.cc",
      "profiler/native_unwinder_android_map_delegate.h",
      "profiler/native_unwinder_android_memory_regions_map.h",
      "profiler/stack_sampler_android.cc",
      "system/sys_info_android.cc",
      "threading/platform_thread_android.cc",

      # Android uses some Linux sources.
      "debug/elf_reader.cc",
      "debug/elf_reader.h",
      "debug/proc_maps_linux.cc",
      "debug/proc_maps_linux.h",
      "power_monitor/power_monitor_device_source_android.cc",
      "process/internal_linux.cc",
      "process/internal_linux.h",
      "process/memory_linux.cc",
      "process/process_handle_linux.cc",
      "process/process_iterator_linux.cc",
      "process/process_metrics_linux.cc",
      "system/sys_info_linux.cc",
    ]

    deps += [
      ":base_jni",
      ":base_shared_preferences_jni",
      ":callback_jni",
      ":command_line_jni",
      ":content_uri_utils_jni",
      ":jank_tracker_jni",
      ":library_loader_jni",
      ":memory_jni",
      ":metrics_jni",
      ":process_launcher_jni",
      ":sys_utils_jni",
      ":tasks_jni",
      "//third_party/ashmem",
      "//third_party/cpu_features:ndk_compat",
    ]

    # Needs to be a public config so that dependent targets link against it as
    # well when doing a component build.
    public_configs = [ ":android_system_libs" ]

    if (can_unwind_with_cfi_table) {
      sources += [
        "trace_event/cfi_backtrace_android.cc",
        "trace_event/cfi_backtrace_android.h",
      ]
    }
    if (current_cpu == "arm") {
      sources += [
        "profiler/chrome_unwind_info_android.cc",
        "profiler/chrome_unwind_info_android.h",
        "profiler/chrome_unwinder_android.cc",
        "profiler/chrome_unwinder_android.h",
      ]
    }

    if (current_cpu == "arm64") {
      sources += [
        "profiler/frame_pointer_unwinder.cc",
        "profiler/frame_pointer_unwinder.h",
      ]
    }

    # This is actually a linker script, but it can be added to the link in the
    # same way as a library.
    libs += [ "android/library_loader/anchor_functions.lds" ]
  }  # is_android

  if (build_allocation_stack_trace_recorder) {
    sources += [
      "debug/allocation_trace.cc",
      "debug/allocation_trace.h",
    ]
  }

  if (is_robolectric) {
    # Make jni.h available.
    configs += [ "//third_party/jdk" ]
    deps += [ ":base_robolectric_jni" ]
  }
  if (is_android || is_robolectric) {
    sources += [
      "android/base_jni_onload.cc",
      "android/base_jni_onload.h",
      "android/callback_android.cc",
      "android/callback_android.h",
      "android/command_line_android.cc",
      "android/java_exception_reporter.cc",
      "android/java_exception_reporter.h",
      "android/jni_android.cc",
      "android/jni_android.h",
      "android/jni_array.cc",
      "android/jni_array.h",
      "android/jni_bytebuffer.cc",
      "android/jni_bytebuffer.h",
      "android/jni_registrar.cc",
      "android/jni_registrar.h",
      "android/jni_string.cc",
      "android/jni_string.h",
      "android/jni_utils.cc",
      "android/jni_utils.h",
      "android/jni_weak_ref.h",
      "android/library_loader/library_loader_hooks.cc",
      "android/library_loader/library_loader_hooks.h",
      "android/native_uma_recorder.cc",
      "android/scoped_java_ref.h",
      "android/token_android.cc",
      "android/token_android.h",
      "android/trace_event_binding.cc",
      "android/trace_event_binding.h",
      "android/unguessable_token_android.cc",
      "android/unguessable_token_android.h",
    ]
    deps += [ "//build:robolectric_buildflags" ]
    public_deps += [ "//third_party/jni_zero:jni_zero" ]
  }  # is_android || is_robolectric

  if (is_android && !is_robolectric) {
    # The robolectic toolchain doesn't provide the NDK headers required for data
    # and function type definitions used by BinderApi et al.
    sources += [
      "android/binder.cc",
      "android/binder.h",
      "android/binder_box.cc",
      "android/binder_box.h",
    ]
  }

  # Chromeos.
  if (is_chromeos) {
    sources += [
      "logging_chromeos.cc",
      "system/sys_info_chromeos.cc",
    ]

    sources += [ "power_monitor/power_monitor_device_source_chromeos.cc" ]

    if (current_cpu == "x64" || current_cpu == "arm64") {
      sources += [
        "profiler/frame_pointer_unwinder.cc",
        "profiler/frame_pointer_unwinder.h",
      ]
    }
  }

  # Fuchsia.
  if (is_fuchsia) {
    sources += [
      "base_paths_fuchsia.cc",
      "debug/debugger_fuchsia.cc",
      "debug/elf_reader.cc",
      "debug/elf_reader.h",
      "debug/stack_trace_fuchsia.cc",
      "file_descriptor_posix.cc",
      "file_descriptor_posix.h",
      "files/dir_reader_posix.h",
      "files/file_path_watcher_stub.cc",  # See crbug.com/851641.
      "files/file_posix.cc",
      "files/memory_mapped_file_posix.cc",
      "fuchsia/default_job.cc",
      "fuchsia/default_job.h",
      "fuchsia/fidl_event_handler.h",
      "fuchsia/file_utils.cc",
      "fuchsia/file_utils.h",
      "fuchsia/filtered_service_directory.cc",
      "fuchsia/filtered_service_directory.h",
      "fuchsia/fuchsia_component_connect.h",
      "fuchsia/fuchsia_logging.cc",
      "fuchsia/fuchsia_logging.h",
      "fuchsia/intl_profile_watcher.cc",
      "fuchsia/intl_profile_watcher.h",
      "fuchsia/koid.cc",
      "fuchsia/koid.h",
      "fuchsia/mem_buffer_util.cc",
      "fuchsia/mem_buffer_util.h",
      "fuchsia/process_context.cc",
      "fuchsia/process_context.h",
      "fuchsia/process_lifecycle.cc",
      "fuchsia/process_lifecycle.h",
      "fuchsia/scheduler.h",
      "fuchsia/scoped_fx_logger.cc",
      "fuchsia/scoped_fx_logger.h",
      "fuchsia/scoped_service_binding.h",
      "fuchsia/scoped_service_publisher.h",
      "fuchsia/startup_context.cc",
      "fuchsia/startup_context.h",
      "fuchsia/system_info.cc",
      "fuchsia/system_info.h",
      "memory/platform_shared_memory_mapper_fuchsia.cc",
      "memory/platform_shared_memory_region_fuchsia.cc",
      "memory/protected_memory_posix.cc",
      "message_loop/message_pump_fuchsia.cc",
      "message_loop/message_pump_fuchsia.h",
      "message_loop/watchable_io_message_pump_posix.cc",
      "message_loop/watchable_io_message_pump_posix.h",
      "native_library_fuchsia.cc",
      "posix/eintr_wrapper.h",
      "posix/file_descriptor_shuffle.cc",
      "posix/file_descriptor_shuffle.h",
      "posix/global_descriptors.cc",
      "posix/global_descriptors.h",
      "posix/safe_strerror.cc",
      "posix/safe_strerror.h",
      "process/kill_fuchsia.cc",
      "process/launch_fuchsia.cc",
      "process/memory_fuchsia.cc",
      "process/process_fuchsia.cc",
      "process/process_handle_fuchsia.cc",
      "process/process_iterator_fuchsia.cc",
      "process/process_metrics_fuchsia.cc",
      "profiler/module_cache_posix.cc",
      "rand_util_fuchsia.cc",
      "strings/string_util_posix.h",
      "strings/sys_string_conversions_posix.cc",
      "synchronization/condition_variable_posix.cc",
      "synchronization/lock_impl_posix.cc",
      "synchronization/waitable_event_posix.cc",
      "synchronization/waitable_event_watcher_posix.cc",
      "system/sys_info_fuchsia.cc",
      "threading/platform_thread_fuchsia.cc",
      "threading/platform_thread_posix.cc",
      "threading/thread_local_storage_posix.cc",
      "time/time_conversion_posix.cc",
      "time/time_exploded_icu.cc",
      "time/time_fuchsia.cc",
      "timer/hi_res_timer_manager_posix.cc",
    ]

    # These only need to be public deps because of includes of their headers
    # by public //base headers, which requires they be on the include path.
    # TODO(crbug.com/40575514): Move these back to |deps|.
    public_deps += [
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.component.runner:fuchsia.component.runner_hlcpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.intl:fuchsia.intl_hlcpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io:fuchsia.io_cpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io:fuchsia.io_hlcpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.logger:fuchsia.logger_cpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.mem:fuchsia.mem_hlcpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.process.lifecycle:fuchsia.process.lifecycle_cpp",
      "//third_party/fuchsia-sdk/sdk/pkg/async",
      "//third_party/fuchsia-sdk/sdk/pkg/component_incoming_cpp",
      "//third_party/fuchsia-sdk/sdk/pkg/fdio",
      "//third_party/fuchsia-sdk/sdk/pkg/fidl_cpp",
      "//third_party/fuchsia-sdk/sdk/pkg/fidl_cpp_wire",
      "//third_party/fuchsia-sdk/sdk/pkg/sync",
      "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
      "//third_party/fuchsia-sdk/sdk/pkg/syslog_structured_backend",
      "//third_party/fuchsia-sdk/sdk/pkg/vfs_cpp",
      "//third_party/fuchsia-sdk/sdk/pkg/zx",
    ]

    deps += [
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.buildinfo:fuchsia.buildinfo_cpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.hwinfo:fuchsia.hwinfo_cpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io:fuchsia.io_cpp_hlcpp_conversion",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.media:fuchsia.media_cpp",
      "//third_party/fuchsia-sdk/sdk/pkg/async-default",
      "//third_party/fuchsia-sdk/sdk/pkg/async-loop-cpp",
      "//third_party/fuchsia-sdk/sdk/pkg/async-loop-default",
      "//third_party/fuchsia-sdk/sdk/pkg/fidl",
      "//third_party/fuchsia-sdk/sdk/pkg/inspect_component_cpp",
      "//third_party/icu",
    ]

    # Needed for users of spinning_mutex.h, which for performance reasons,
    # contains inlined calls to `libsync` inside the header file.
    # It appends an entry to the "libs" section of the dependent target.
    public_configs = [ ":fuchsia_sync_lib" ]
  }

  # Several helpers in //base are backed by BoringSSL; however, NaCl builds
  # cannot easily depend on BoringSSL due to the nacl_io library, so NaCl builds
  # still retain a dedicated local implementation of the functionality.
  #
  # TODO(crbug.com/40511454) Use only boringssl when NaCl is removed.
  sources += [
    "hash/md5.h",
    "hash/md5_constexpr.h",
    "hash/md5_constexpr_internal.h",
    "hash/sha1.h",
  ]
  if (is_nacl) {
    sources += [
      "hash/md5_nacl.cc",
      "hash/md5_nacl.h",
      "hash/sha1_nacl.cc",
      "hash/sha1_nacl.h",
    ]
  } else {
    sources += [
      "hash/md5_boringssl.cc",
      "hash/md5_boringssl.h",
      "hash/sha1_boringssl.cc",
      "hash/sha1_boringssl.h",
    ]
    public_deps += [ "//third_party/boringssl" ]
  }

  # NaCl.
  if (is_nacl) {
    # Explicitly include the linux file.
    sources += [
      "debug/stack_trace_nacl.cc",
      "files/file_path_watcher_stub.cc",
      "memory/page_size_nacl.cc",
      "os_compat_nacl.cc",
      "os_compat_nacl.h",
      "process/process_stubs.cc",
      "rand_util_nacl.cc",
      "sync_socket_nacl.cc",
      "system/sys_info_nacl.cc",
      "threading/platform_thread_linux_base.cc",
      "threading/platform_thread_nacl.cc",
    ]
  } else {
    sources += [
      "base_paths.cc",
      "base_paths.h",
      "cpu.cc",
      "cpu.h",
      "debug/crash_logging.cc",
      "debug/crash_logging.h",
      "debug/stack_trace.cc",
      "debug/stack_trace.h",
      "files/file_enumerator.cc",
      "files/file_enumerator.h",
      "files/file_proxy.cc",
      "files/file_proxy.h",
      "files/file_util.cc",
      "files/file_util.h",
      "files/important_file_writer.cc",
      "files/important_file_writer.h",
      "files/important_file_writer_cleaner.cc",
      "files/important_file_writer_cleaner.h",
      "files/scoped_temp_dir.cc",
      "files/scoped_temp_dir.h",
      "files/scoped_temp_file.cc",
      "files/scoped_temp_file.h",
      "json/json_file_value_serializer.cc",
      "json/json_file_value_serializer.h",
      "memory/discardable_memory.cc",
      "memory/discardable_memory.h",
      "memory/discardable_memory_allocator.cc",
      "memory/discardable_memory_allocator.h",
      "memory/discardable_memory_internal.h",
      "metrics/persistent_histogram_storage.cc",
      "metrics/persistent_histogram_storage.h",
      "native_library.cc",
      "native_library.h",
      "path_service.cc",
      "path_service.h",
      "process/process_metrics.cc",
      "process/process_metrics.h",
      "scoped_native_library.cc",
      "scoped_native_library.h",
      "system/sys_info.cc",
      "system/sys_info.h",
      "system/sys_info_internal.h",
      "task/thread_pool/initialization_util.cc",
      "task/thread_pool/initialization_util.h",
    ]

    if (is_win) {
      sources += [
        "base_paths_win.cc",
        "base_paths_win.h",
      ]
    }

    if (is_apple) {
      sources += [
        "base_paths_apple.cc",
        "base_paths_apple.h",
      ]
    }

    if (is_mac) {
      sources += [
        "base_paths_mac.h",
        "base_paths_mac.mm",
      ]
    }

    if (is_android) {
      sources += [
        "base_paths_android.cc",
        "base_paths_android.h",
      ]
    }

    if (is_posix) {
      sources += [
        "base_paths_posix.h",
        "memory/madv_free_discardable_memory_allocator_posix.cc",
        "memory/madv_free_discardable_memory_allocator_posix.h",
        "memory/madv_free_discardable_memory_posix.cc",
        "memory/madv_free_discardable_memory_posix.h",
        "posix/unix_domain_socket.cc",
        "posix/unix_domain_socket.h",
        "rand_util_posix.cc",
        "system/sys_info_posix.cc",
      ]
    }

    if (is_posix || is_fuchsia) {
      sources += [
        "files/file_descriptor_watcher_posix.cc",
        "files/file_descriptor_watcher_posix.h",
        "files/file_enumerator_posix.cc",
        "files/file_util_posix.cc",
        "memory/page_size_posix.cc",
      ]
    }

    if ((is_posix && !is_ios) || is_fuchsia) {
      sources += [
        "process/process_metrics_posix.cc",
        "sync_socket_posix.cc",
      ]
    }

    if (is_posix && !is_apple) {
      sources += [
        "native_library_posix.cc",
        "posix/can_lower_nice_to.cc",
        "posix/can_lower_nice_to.h",
        "process/launch_posix.cc",
        "profiler/module_cache_posix.cc",
        "profiler/stack_base_address_posix.cc",
        "profiler/stack_base_address_posix.h",
        "profiler/stack_copier_signal.cc",
        "profiler/stack_copier_signal.h",
        "profiler/thread_delegate_posix.cc",
        "profiler/thread_delegate_posix.h",
      ]
    }

    if (is_posix && !is_android) {
      sources += [ "debug/stack_trace_posix.cc" ]
    }

    if (is_posix && !is_ios) {
      sources += [ "process/process_posix.cc" ]
    }

    if (use_blink) {
      sources += [
        "memory/discardable_shared_memory.cc",
        "memory/discardable_shared_memory.h",
        "memory/shared_memory_switch.cc",
        "memory/shared_memory_switch.h",
        "metrics/histogram_shared_memory.cc",
        "metrics/histogram_shared_memory.h",
        "process/kill.cc",
        "process/kill.h",
        "process/launch.cc",
        "process/launch.h",
        "process/memory.cc",
        "process/memory.h",
        "process/process_iterator.cc",
        "process/process_iterator.h",
      ]

      if (is_posix) {
        sources += [ "process/kill_posix.cc" ]
      }
    }

    if (is_linux || is_chromeos) {
      sources += [
        "base_paths_posix.cc",
        "debug/elf_reader.cc",
        "debug/elf_reader.h",
        "stack_canary_linux.cc",
        "stack_canary_linux.h",
      ]
    }
    if (use_partition_alloc) {
      # Add stuff that doesn't work in NaCl.
      sources += [
        # PartitionAlloc uses SpinLock, which doesn't work in NaCl (see below).
        "allocator/miracle_parameter.cc",
        "allocator/miracle_parameter.h",
        "allocator/partition_alloc_features.cc",
        "allocator/partition_alloc_features.h",
        "allocator/partition_alloc_support.cc",
        "allocator/partition_alloc_support.h",
      ]
    }

    # Need this to pass gn check, because gn check doesn't see
    # BUILDFLAG(USE_PARTITION_ALLOC). A linker will remove all
    # partition_alloc code if use_partition_alloc = false because no code uses
    # partition_alloc.
    public_deps += [
      "allocator/partition_allocator:partition_alloc",
      "allocator/partition_allocator:raw_ptr",
    ]
  }

  # Windows.
  if (is_win) {
    sources += [
      "debug/debugger_win.cc",
      "debug/gdi_debug_util_win.cc",
      "debug/gdi_debug_util_win.h",
      "debug/handle_hooks_win.cc",
      "debug/handle_hooks_win.h",
      "debug/invalid_access_win.cc",
      "debug/invalid_access_win.h",
      "debug/stack_trace_win.cc",
      "enterprise_util.cc",
      "enterprise_util.h",
      "enterprise_util_win.cc",
      "file_version_info_win.cc",
      "file_version_info_win.h",
      "files/file_enumerator_win.cc",
      "files/file_path_watcher_win.cc",
      "files/file_util_win.cc",
      "files/file_win.cc",
      "files/memory_mapped_file_win.cc",
      "logging_win.cc",
      "logging_win.h",
      "memory/page_size_win.cc",
      "memory/platform_shared_memory_mapper_win.cc",
      "memory/platform_shared_memory_region_win.cc",
      "memory/protected_memory_win.cc",
      "message_loop/message_pump_win.cc",
      "message_loop/message_pump_win.h",
      "moving_window.h",
      "native_library_win.cc",
      "power_monitor/battery_level_provider_win.cc",
      "power_monitor/power_monitor_device_source_win.cc",
      "power_monitor/speed_limit_observer_win.cc",
      "power_monitor/speed_limit_observer_win.h",
      "process/kill_win.cc",
      "process/launch_win.cc",
      "process/memory_win.cc",
      "process/process_handle_win.cc",
      "process/process_info_win.cc",
      "process/process_iterator_win.cc",
      "process/process_metrics_win.cc",
      "process/process_win.cc",
      "profiler/module_cache_win.cc",
      "profiler/native_unwinder_win.cc",
      "profiler/native_unwinder_win.h",
      "profiler/stack_sampler_win.cc",
      "profiler/suspendable_thread_delegate_win.cc",
      "profiler/suspendable_thread_delegate_win.h",
      "profiler/win32_stack_frame_unwinder.cc",
      "profiler/win32_stack_frame_unwinder.h",
      "rand_util_win.cc",
      "scoped_clear_last_error_win.cc",
      "strings/strcat_win.cc",
      "strings/strcat_win.h",
      "strings/string_number_conversions_win.cc",
      "strings/string_number_conversions_win.h",
      "strings/string_split_win.cc",
      "strings/string_split_win.h",
      "strings/string_util_win.cc",
      "strings/string_util_win.h",
      "strings/sys_string_conversions_win.cc",
      "sync_socket_win.cc",
      "synchronization/condition_variable_win.cc",
      "synchronization/lock_impl_win.cc",
      "synchronization/waitable_event_watcher_win.cc",
      "synchronization/waitable_event_win.cc",
      "system/sys_info_win.cc",
      "threading/platform_thread_win.cc",
      "threading/platform_thread_win.h",
      "threading/thread_local_storage_win.cc",
      "time/time_win.cc",
      "timer/hi_res_timer_manager_win.cc",
      "win/access_control_list.cc",
      "win/access_control_list.h",
      "win/access_token.cc",
      "win/access_token.h",
      "win/async_operation.h",
      "win/atl.h",
      "win/atl_throw.cc",
      "win/atl_throw.h",
      "win/com_init_balancer.cc",
      "win/com_init_balancer.h",
      "win/com_init_check_hook.cc",
      "win/com_init_check_hook.h",
      "win/com_init_util.cc",
      "win/com_init_util.h",
      "win/core_winrt_util.cc",
      "win/core_winrt_util.h",
      "win/current_module.h",
      "win/dark_mode_support.cc",
      "win/dark_mode_support.h",
      "win/default_apps_util.cc",
      "win/default_apps_util.h",
      "win/embedded_i18n/language_selector.cc",
      "win/embedded_i18n/language_selector.h",
      "win/enum_variant.cc",
      "win/enum_variant.h",
      "win/event_trace_consumer.h",
      "win/event_trace_controller.cc",
      "win/event_trace_controller.h",
      "win/event_trace_provider.cc",
      "win/event_trace_provider.h",
      "win/hstring_reference.cc",
      "win/hstring_reference.h",
      "win/i18n.cc",
      "win/i18n.h",
      "win/iat_patch_function.cc",
      "win/iat_patch_function.h",
      "win/map.h",
      "win/message_window.cc",
      "win/message_window.h",
      "win/nt_status.cc",
      "win/nt_status.h",
      "win/object_watcher.cc",
      "win/object_watcher.h",
      "win/patch_util.cc",
      "win/patch_util.h",
      "win/pe_image_reader.cc",
      "win/pe_image_reader.h",
      "win/post_async_results.h",
      "win/process_startup_helper.cc",
      "win/process_startup_helper.h",
      "win/propvarutil.h",
      "win/reference.h",
      "win/registry.cc",
      "win/registry.h",
      "win/resource_exhaustion.cc",
      "win/resource_exhaustion.h",
      "win/resource_util.cc",
      "win/resource_util.h",
      "win/scoped_bstr.cc",
      "win/scoped_bstr.h",
      "win/scoped_co_mem.h",
      "win/scoped_com_initializer.cc",
      "win/scoped_com_initializer.h",
      "win/scoped_gdi_object.h",
      "win/scoped_handle.cc",
      "win/scoped_handle.h",
      "win/scoped_handle_verifier.cc",
      "win/scoped_handle_verifier.h",
      "win/scoped_hdc.h",
      "win/scoped_hglobal.h",
      "win/scoped_hstring.cc",
      "win/scoped_hstring.h",
      "win/scoped_localalloc.h",
      "win/scoped_pdh_query.cc",
      "win/scoped_pdh_query.h",
      "win/scoped_process_information.cc",
      "win/scoped_process_information.h",
      "win/scoped_propvariant.h",
      "win/scoped_safearray.h",
      "win/scoped_select_object.h",
      "win/scoped_variant.cc",
      "win/scoped_variant.h",
      "win/scoped_windows_thread_environment.h",
      "win/scoped_winrt_initializer.cc",
      "win/scoped_winrt_initializer.h",
      "win/security_descriptor.cc",
      "win/security_descriptor.h",
      "win/security_util.cc",
      "win/security_util.h",
      "win/shlwapi.h",
      "win/shortcut.cc",
      "win/shortcut.h",
      "win/sid.cc",
      "win/sid.h",
      "win/sphelper.h",
      "win/startup_information.cc",
      "win/startup_information.h",
      "win/variant_conversions.h",
      "win/variant_vector.cc",
      "win/variant_vector.h",
      "win/vector.cc",
      "win/vector.h",
      "win/win_handle_types.h",
      "win/win_handle_types_list.inc",
      "win/win_util.cc",
      "win/win_util.h",
      "win/wincrypt_shim.h",
      "win/window_enumerator.cc",
      "win/window_enumerator.h",
      "win/windows_defines.inc",
      "win/windows_h_disallowed.h",
      "win/windows_types.h",
      "win/windows_undefines.inc",
      "win/windows_version.cc",
      "win/windows_version.h",
      "win/windowsx_shim.h",
      "win/winrt_foundation_helpers.h",
      "win/winrt_storage_util.cc",
      "win/winrt_storage_util.h",
      "win/wmi.cc",
      "win/wmi.h",
      "win/wrapped_window_proc.cc",
      "win/wrapped_window_proc.h",
    ]

    deps += [ "//base/win:base_win_buildflags" ]

    if (com_init_check_hook_disabled) {
      defines += [ "COM_INIT_CHECK_HOOK_DISABLED" ]
    }

    libs += [
      "cfgmgr32.lib",
      "ntdll.lib",
      "onecore.lib",
      "pdh.lib",
      "powrprof.lib",
      "propsys.lib",
      "setupapi.lib",
      "shcore.lib",
      "userenv.lib",
      "wbemuuid.lib",
      "winmm.lib",
    ]
    all_dependent_configs += [
      ":base_win_linker_flags",
      "//tools/win/DebugVisualizers:chrome",
    ]
    inputs = [
      # chrome.natvis listed as an input here instead of in
      # //tools/win/DebugVisualizers:chrome to prevent unnecessary size increase
      # in generated build files.
      "//tools/win/DebugVisualizers/chrome.natvis",
    ]
  }

  if (!is_win) {
    sources += [
      "file_descriptor_store.cc",
      "file_descriptor_store.h",
    ]
  }

  # Mac or iOS.
  if (is_apple) {
    sources += [
      "apple/backup_util.h",
      "apple/backup_util.mm",
      "apple/bridging.h",
      "apple/bundle_locations.h",
      "apple/bundle_locations.mm",
      "apple/call_with_eh_frame.cc",
      "apple/call_with_eh_frame.h",
      "apple/call_with_eh_frame_asm.S",
      "apple/dispatch_source_mach.cc",
      "apple/dispatch_source_mach.h",
      "apple/foundation_util.h",
      "apple/foundation_util.mm",
      "apple/mach_logging.cc",
      "apple/mach_logging.h",
      "apple/osstatus_logging.h",
      "apple/osstatus_logging.mm",
      "apple/owned_objc.h",
      "apple/owned_objc.mm",
      "apple/scoped_cffiledescriptorref.h",
      "apple/scoped_cftyperef.h",
      "apple/scoped_dispatch_object.h",
      "apple/scoped_mach_port.cc",
      "apple/scoped_mach_port.h",
      "apple/scoped_mach_vm.cc",
      "apple/scoped_mach_vm.h",
      "apple/scoped_nsautorelease_pool.h",
      "apple/scoped_nsautorelease_pool.mm",
      "apple/scoped_nsobject.h",
      "apple/scoped_objc_class_swizzler.h",
      "apple/scoped_objc_class_swizzler.mm",
      "apple/scoped_typeref.h",
      "file_version_info_apple.h",
      "file_version_info_apple.mm",
      "files/file_util_apple.mm",
      "memory/platform_shared_memory_mapper_apple.cc",
      "memory/platform_shared_memory_region_apple.cc",
      "message_loop/message_pump_apple.h",
      "message_loop/message_pump_apple.mm",
      "process/process_metrics_apple.cc",
      "profiler/module_cache_apple.cc",
      "strings/sys_string_conversions_apple.mm",
      "synchronization/waitable_event_apple.cc",
      "system/sys_info_apple.mm",
      "threading/platform_thread_apple.mm",
      "time/time_apple.mm",
    ]
    frameworks += [
      "CoreFoundation.framework",
      "CoreGraphics.framework",
      "CoreText.framework",
      "Foundation.framework",
      "Security.framework",
    ]
  }

  # Desktop Mac.
  if (is_mac) {
    sources += [
      "enterprise_util.cc",
      "enterprise_util.h",
      "enterprise_util_mac.mm",
      "files/file_path_watcher_fsevents.cc",
      "files/file_path_watcher_fsevents.h",
      "files/file_path_watcher_kqueue.cc",
      "files/file_path_watcher_kqueue.h",
      "files/file_path_watcher_mac.cc",
      "mac/authorization_util.h",
      "mac/authorization_util.mm",
      "mac/close_nocancel.cc",
      "mac/launch_application.h",
      "mac/launch_application.mm",
      "mac/launch_services_spi.h",
      "mac/launchd.cc",
      "mac/launchd.h",
      "mac/login_util.cc",
      "mac/login_util.h",
      "mac/mac_util.h",
      "mac/mac_util.mm",
      "mac/mach_port_rendezvous.cc",
      "mac/mach_port_rendezvous.h",
      "mac/os_crash_dumps.cc",
      "mac/os_crash_dumps.h",
      "mac/scoped_aedesc.h",
      "mac/scoped_authorizationref.h",
      "mac/scoped_authorizationref.mm",
      "mac/scoped_ionotificationportref.h",
      "mac/scoped_ioobject.h",
      "mac/scoped_ioplugininterface.h",
      "mac/scoped_launch_data.h",
      "mac/scoped_mach_msg_destroy.h",
      "mac/scoped_sending_event.h",
      "mac/scoped_sending_event.mm",
      "message_loop/message_pump_kqueue.cc",
      "message_loop/message_pump_kqueue.h",
      "native_library_mac.mm",
      "power_monitor/battery_level_provider_mac.mm",
      "power_monitor/battery_state_sampler_mac.cc",
      "power_monitor/iopm_power_source_sampling_event_source.cc",
      "power_monitor/iopm_power_source_sampling_event_source.h",
      "power_monitor/power_monitor_device_source_mac.mm",
      "power_monitor/thermal_state_observer_mac.h",
      "power_monitor/thermal_state_observer_mac.mm",
      "process/kill_mac.cc",
      "process/launch_mac.cc",
      "process/memory_mac.mm",
      "process/port_provider_mac.cc",
      "process/port_provider_mac.h",
      "process/process_handle_mac.cc",
      "process/process_info_mac.cc",
      "process/process_iterator_mac.cc",
      "process/process_mac.cc",
      "process/process_metrics_mac.cc",
      "profiler/frame_pointer_unwinder.cc",
      "profiler/frame_pointer_unwinder.h",
      "profiler/stack_sampler_mac.cc",
      "profiler/suspendable_thread_delegate_mac.cc",
      "profiler/suspendable_thread_delegate_mac.h",
      "synchronization/waitable_event_watcher_mac.cc",
      "system/sys_info_mac.mm",
    ]

    libs += [
      "bsm",
      "pmenergy",
      "pmsample",
    ]
    frameworks += [
      "ApplicationServices.framework",
      "AppKit.framework",
      "CoreFoundation.framework",
      "IOKit.framework",
      "OpenDirectory.framework",
    ]
  }

  # iOS
  if (is_ios) {
    sources += [
      "base_paths_ios.h",
      "base_paths_ios.mm",
      "ios/block_types.h",
      "ios/crb_protocol_observers.h",
      "ios/crb_protocol_observers.mm",
      "ios/device_util.h",
      "ios/device_util.mm",
      "ios/ios_util.h",
      "ios/ios_util.mm",
      "ios/ns_error_util.h",
      "ios/ns_error_util.mm",
      "ios/ns_range.h",
      "native_library_ios.mm",
      "power_monitor/power_monitor_device_source_ios.mm",
      "process/process_metrics_ios.cc",
      "process/process_metrics_posix.cc",
      "profiler/stack_sampler_ios.cc",
      "system/sys_info_ios.mm",
    ]

    if (!ios_is_app_extension) {
      sources += [
        "critical_closure_internal_ios.mm",
        "ios/scoped_critical_action.h",
        "ios/scoped_critical_action.mm",
      ]
    }

    if (use_blink) {
      sources += [
        "files/file_path_watcher_kqueue.cc",
        "files/file_path_watcher_kqueue.h",
        "files/file_path_watcher_mac.cc",
        "ios/sim_header_shims.h",
        "mac/mach_port_rendezvous.cc",
        "mac/mach_port_rendezvous.h",
        "process/kill_ios.cc",
        "process/memory_mac.mm",
        "process/port_provider_mac.cc",
        "process/port_provider_mac.h",
        "process/process_handle_mac.cc",
        "process/process_ios.cc",
        "process/process_iterator_mac.cc",
        "process/process_mac.cc",
        "process/process_posix.cc",
        "sync_socket_posix.cc",
        "synchronization/waitable_event_watcher_mac.cc",
      ]

      # We include launch_mac on simulator builds so unittests can fork.
      if (target_environment == "simulator") {
        sources += [
          "process/kill_mac.cc",
          "process/launch_mac.cc",
        ]
      } else {
        sources += [ "process/launch_ios.cc" ]
      }
    } else {
      sources += [
        "process/launch_ios.cc",
        "process/memory_stubs.cc",
        "process/process_stubs.cc",
      ]
    }

    if (is_cronet_build) {
      sources += [
        "message_loop/message_pump_io_ios.cc",
        "message_loop/message_pump_io_ios.h",
      ]
    } else {
      sources += [
        "message_loop/message_pump_kqueue.cc",
        "message_loop/message_pump_kqueue.h",
      ]
    }

    if (ios_stack_profiler_enabled) {
      sources += [
        "profiler/frame_pointer_unwinder.cc",
        "profiler/frame_pointer_unwinder.h",
        "profiler/suspendable_thread_delegate_mac.cc",
        "profiler/suspendable_thread_delegate_mac.h",
      ]
    }
    if (!use_allocator_shim) {
      sources -= [
        "sampling_heap_profiler/poisson_allocation_sampler.cc",
        "sampling_heap_profiler/poisson_allocation_sampler.h",
        "sampling_heap_profiler/sampling_heap_profiler.cc",
        "sampling_heap_profiler/sampling_heap_profiler.h",
      ]
    }

    frameworks += [
      "Foundation.framework",
      "UIKit.framework",
    ]
  }

  # Linux.
  if (is_linux || is_chromeos) {
    # TODO(brettw) this will need to be parameterized at some point.
    linux_configs = []
    if (use_glib) {
      linux_configs += [ "//build/config/linux:glib" ]
    }

    configs += linux_configs
    all_dependent_configs += linux_configs
    sources += [
      "process/set_process_title_linux.cc",
      "process/set_process_title_linux.h",
      "system/sys_info_linux.cc",
    ]
    if (!is_cronet_build) {
      # These dependencies are not required on Android.
      sources += [
        "nix/mime_util_xdg.cc",
        "nix/mime_util_xdg.h",
        "nix/scoped_xdg_activation_token_injector.cc",
        "nix/scoped_xdg_activation_token_injector.h",
        "nix/xdg_util.cc",
        "nix/xdg_util.h",
      ]
      defines += [ "USE_SYMBOLIZE" ]
      deps += [
        ":dwarf_helpers",
        "//base/third_party/symbolize",
        "//base/third_party/xdg_user_dirs",
      ]
    }
  } else {
    if (!is_android) {
      sources -= [
        "linux_util.cc",
        "linux_util.h",
      ]
    }
  }

  if (use_blink) {
    sources += [
      "files/file_path_watcher.cc",
      "files/file_path_watcher.h",
      "sync_socket.cc",
      "sync_socket.h",
    ]
  }

  if (use_epoll) {
    sources += [
      "message_loop/message_pump_epoll.cc",
      "message_loop/message_pump_epoll.h",
    ]
  }

  # Android and MacOS have their own custom shared memory handle
  # implementations. e.g. due to supporting both POSIX and native handles.
  if (is_posix && !is_android && !is_apple) {
    sources += [
      "memory/platform_shared_memory_mapper_posix.cc",
      "memory/platform_shared_memory_region_posix.cc",
    ]
  }

  if (is_posix && !is_apple) {
    sources += [
      "strings/sys_string_conversions_posix.cc",
      "synchronization/waitable_event_posix.cc",
      "synchronization/waitable_event_watcher_posix.cc",
      "threading/platform_thread_internal_posix.cc",
      "threading/platform_thread_internal_posix.h",
      "time/time_now_posix.cc",
    ]

    # TODO(b/167763382) Find an alternate solution for Chromecast devices, since
    # adding the icui18n and icuuc deps significantly increases the binary size.
    if (!is_castos && !is_cast_android) {
      sources += [ "time/time_exploded_icu.cc" ]

      # The ICU dependency is only needed on systems with a 32-bit time_t.
      # However, that cannot be determined from build variables, like
      # |current_cpu|, since some 32-bit systems have a 64-bit time_t (and vice
      # versa). Thus, the dependency is taken here for all POSIX platforms and
      # the compiler+linker should be able to easily detect when the ICU
      # routines will not be called and delete them in the final linking.
      deps += [
        "//third_party/icu:icui18n",
        "//third_party/icu:icuuc",
      ]
    }
  }

  if (is_posix) {
    sources += [ "time/time_exploded_posix.cc" ]
  }

  if ((is_posix && !is_apple && !is_android) || is_fuchsia) {
    sources += [ "profiler/stack_sampler_posix.cc" ]
  }

  if ((is_posix && !is_apple && !is_android && !is_chromeos) || is_fuchsia) {
    sources += [ "power_monitor/power_monitor_device_source_stub.cc" ]
  }

  # On ARC++-enabled ChromeOS system, we need TimeTicks::FromUptimeMillis to
  # interpret time values sent from Android container.
  if (is_android || is_chromeos) {
    sources += [ "time/time_android.cc" ]
  }

  if (use_glib) {
    sources += [
      "message_loop/message_pump_glib.cc",
      "message_loop/message_pump_glib.h",
    ]
  }

  if (enable_base_tracing) {
    sources += [
      "trace_event/auto_open_close_event.h",
      "trace_event/builtin_categories.cc",
      "trace_event/builtin_categories.h",
      "trace_event/category_registry.cc",
      "trace_event/category_registry.h",
      "trace_event/heap_profiler.h",
      "trace_event/interned_args_helper.cc",
      "trace_event/interned_args_helper.h",
      "trace_event/log_message.cc",
      "trace_event/log_message.h",
      "trace_event/malloc_dump_provider.cc",
      "trace_event/malloc_dump_provider.h",
      "trace_event/memory_allocator_dump.cc",
      "trace_event/memory_allocator_dump.h",
      "trace_event/memory_dump_manager.cc",
      "trace_event/memory_dump_manager.h",
      "trace_event/memory_dump_manager_test_utils.h",
      "trace_event/memory_dump_provider.h",
      "trace_event/memory_dump_provider_info.cc",
      "trace_event/memory_dump_provider_info.h",
      "trace_event/memory_dump_request_args.cc",
      "trace_event/memory_dump_request_args.h",
      "trace_event/memory_dump_scheduler.cc",
      "trace_event/memory_dump_scheduler.h",
      "trace_event/memory_infra_background_allowlist.cc",
      "trace_event/memory_infra_background_allowlist.h",
      "trace_event/memory_pressure_level_proto.cc",
      "trace_event/memory_pressure_level_proto.h",
      "trace_event/memory_usage_estimator.cc",
      "trace_event/memory_usage_estimator.h",
      "trace_event/optional_trace_event.h",
      "trace_event/process_memory_dump.cc",
      "trace_event/process_memory_dump.h",
      "trace_event/trace_arguments.cc",
      "trace_event/trace_arguments.h",
      "trace_event/trace_buffer.cc",
      "trace_event/trace_buffer.h",
      "trace_event/trace_category.h",
      "trace_event/trace_config.cc",
      "trace_event/trace_config.h",
      "trace_event/trace_config_category_filter.cc",
      "trace_event/trace_config_category_filter.h",
      "trace_event/trace_event.h",
      "trace_event/trace_event_impl.cc",
      "trace_event/trace_event_impl.h",
      "trace_event/trace_event_memory_overhead.cc",
      "trace_event/trace_event_memory_overhead.h",
      "trace_event/trace_log.cc",
      "trace_event/trace_log.h",
      "trace_event/trace_log_constants.cc",
      "trace_event/traced_value.cc",
      "trace_event/traced_value.h",
      "trace_event/traced_value_support.h",
      "trace_event/tracing_agent.cc",
      "trace_event/tracing_agent.h",
      "trace_event/typed_macros.h",
      "trace_event/typed_macros_embedder_support.h",
      "trace_event/typed_macros_internal.cc",
      "trace_event/typed_macros_internal.h",
      "tracing/perfetto_platform.cc",
      "tracing/perfetto_platform.h",
      "tracing/perfetto_task_runner.cc",
      "tracing/perfetto_task_runner.h",
      "tracing/trace_time.cc",
      "tracing/trace_time.h",
      "tracing/tracing_tls.cc",
      "tracing/tracing_tls.h",
    ]

    public_deps += [
      "//base/tracing/protos:chrome_track_event_zero",
      "//third_party/perfetto:libperfetto",
    ]

    deps += [
      "//base/tracing/protos:chrome_track_event",
      "//third_party/perfetto/include/perfetto/protozero",
    ]

    all_dependent_configs += [ "//third_party/perfetto/gn:public_config" ]

    if (is_win) {
      sources += [
        "trace_event/etw_interceptor_win.cc",
        "trace_event/etw_interceptor_win.h",
        "trace_event/trace_event_etw_export_win.cc",
        "trace_event/trace_event_etw_export_win.h",
        "trace_event/trace_logging_minimal_win.cc",
        "trace_event/trace_logging_minimal_win.h",
      ]
    }

    if (is_android) {
      sources += [
        "trace_event/application_state_proto_android.cc",
        "trace_event/application_state_proto_android.h",
        "trace_event/cpufreq_monitor_android.cc",
        "trace_event/cpufreq_monitor_android.h",
        "trace_event/java_heap_dump_provider_android.cc",
        "trace_event/java_heap_dump_provider_android.h",
      ]
    }

    if (use_partition_alloc_as_malloc) {
      sources += [
        "trace_event/address_space_dump_provider.cc",
        "trace_event/address_space_dump_provider.h",
      ]
    }
  } else {
    sources += [
      "trace_event/trace_event_stub.cc",
      "trace_event/trace_event_stub.h",
    ]
  }

  if (using_sanitizer && !is_fuchsia) {
    data += [ "//tools/valgrind/asan/" ]
    data_deps +=
        [ "//build/config/clang:llvm-symbolizer_data($host_toolchain)" ]
  }

  if (!is_debug) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }
}

if (is_linux || is_chromeos) {
  # Split out as a separate target for two reasons:
  # - the line number reader is 2x slower in debug builds if not optimized,
  #   leading to a worse dev experience and test timeouts.
  # - it would be nice to upstream this logic into something like Abseil. The
  #   logic that drives the base symbolizer is already imported more or less
  #   directly from Abseil.
  source_set("dwarf_helpers") {
    sources = [
      "debug/buffered_dwarf_reader.cc",
      "debug/buffered_dwarf_reader.h",
      "debug/dwarf_line_no.cc",
      "debug/dwarf_line_no.h",
    ]

    deps = [
      "//base/allocator/partition_allocator:raw_ptr",
      "//base/numerics:base_numerics",
      "//base/third_party/symbolize",
    ]

    defines = [ "USE_SYMBOLIZE" ]

    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }
}

# Build flags for Control Flow Integrity
# https://www.chromium.org/developers/testing/control-flow-integrity
buildflag_header("cfi_buildflags") {
  header = "cfi_buildflags.h"

  flags = [
    # TODO(pcc): remove CFI_CAST_CHECK, see https://crbug.com/626794.
    "CFI_CAST_CHECK=$is_cfi && $use_cfi_cast",
    "CFI_DIAG=$is_cfi && $use_cfi_diag",
    "CFI_ICALL_CHECK=$is_cfi && $use_cfi_icall",
    "CFI_ENFORCEMENT_TRAP=$is_cfi && !$use_cfi_diag",
    "CFI_ENFORCEMENT_DIAGNOSTIC=$is_cfi && $use_cfi_diag && !$use_cfi_recover",
  ]
}

buildflag_header("debugging_buildflags") {
  header = "debugging_buildflags.h"
  header_dir = "base/debug"
  enable_gdbinit_warning =
      is_debug && (strip_absolute_paths_from_debug_symbols || use_custom_libcxx)
  enable_lldbinit_warning =
      is_debug && strip_absolute_paths_from_debug_symbols && is_mac

  # TODO(crbug.com/40258939): Try and enable these checks on Android too.
  enable_commandline_sequence_checks =
      (is_debug || dcheck_always_on) && !is_android

  if (enable_stack_trace_line_numbers) {
    assert(
        symbol_level > 0,
        "symbol_level must be set to greater than 0 for source line numbers.")
  }
  _enable_stack_trace_line_numbers =
      !print_unsymbolized_stack_traces && enable_stack_trace_line_numbers

  flags = [
    "DCHECK_IS_CONFIGURABLE=$dcheck_is_configurable",
    "ENABLE_PROFILING=$enable_profiling",
    "CAN_UNWIND_WITH_FRAME_POINTERS=$can_unwind_with_frame_pointers",
    "UNSAFE_DEVELOPER_BUILD=$is_unsafe_developer_build",
    "CAN_UNWIND_WITH_CFI_TABLE=$can_unwind_with_cfi_table",
    "EXCLUDE_UNWIND_TABLES=$exclude_unwind_tables",
    "ENABLE_GDBINIT_WARNING=$enable_gdbinit_warning",
    "ENABLE_LLDBINIT_WARNING=$enable_lldbinit_warning",
    "EXPENSIVE_DCHECKS_ARE_ON=$enable_expensive_dchecks",
    "ENABLE_STACK_TRACE_LINE_NUMBERS=$_enable_stack_trace_line_numbers",
    "ENABLE_COMMANDLINE_SEQUENCE_CHECKS=$enable_commandline_sequence_checks",
    "ENABLE_ALLOCATION_STACK_TRACE_RECORDER=$build_allocation_stack_trace_recorder",
    "ENABLE_ALLOCATION_TRACE_RECORDER_FULL_REPORTING=$build_allocation_trace_recorder_full_reporting",
    "PRINT_UNSYMBOLIZED_STACK_TRACES=$print_unsymbolized_stack_traces",
  ]
}

buildflag_header("feature_list_buildflags") {
  header = "feature_list_buildflags.h"

  if (is_chromeos_ash) {
    flags = [
      "ENABLE_BANNED_BASE_FEATURE_PREFIX=true",
      "BANNED_BASE_FEATURE_PREFIX=\"CrOSLateBoot\"",
    ]
  } else {
    flags = [ "ENABLE_BANNED_BASE_FEATURE_PREFIX=false" ]
  }
}

buildflag_header("logging_buildflags") {
  header = "logging_buildflags.h"

  flags = [ "ENABLE_LOG_ERROR_NOT_REACHED=$enable_log_error_not_reached" ]
}

buildflag_header("orderfile_buildflags") {
  header = "orderfile_buildflags.h"
  header_dir = "base/android/orderfile"
  using_order_profiling = is_android && use_order_profiling
  using_devtools_dumping =
      is_android && devtools_instrumentation_dumping && enable_base_tracing

  flags = [
    "DEVTOOLS_INSTRUMENTATION_DUMPING=$using_devtools_dumping",
    "ORDERFILE_INSTRUMENTATION=$using_order_profiling",
  ]
}

# Build flags for ProtectedMemory
buildflag_header("protected_memory_buildflags") {
  header = "protected_memory_buildflags.h"
  header_dir = "base/memory"

  protected_memory_enabled =
      !is_component_build && (is_win || is_linux || is_android || is_mac)

  flags = [ "PROTECTED_MEMORY_ENABLED=$protected_memory_enabled" ]
}

buildflag_header("synchronization_buildflags") {
  header = "synchronization_buildflags.h"
  header_dir = "base/synchronization"

  flags =
      [ "ENABLE_MUTEX_PRIORITY_INHERITANCE=$enable_mutex_priority_inheritance" ]
}

buildflag_header("anchor_functions_buildflags") {
  header = "anchor_functions_buildflags.h"
  header_dir = "base/android/library_loader"
  _supports_code_ordering =
      is_android && (current_cpu == "arm" || current_cpu == "arm64" ||
                     current_cpu == "x86" || current_cpu == "x64")

  flags = [
    "USE_LLD=$use_lld",
    "SUPPORTS_CODE_ORDERING=$_supports_code_ordering",
  ]
}

buildflag_header("clang_profiling_buildflags") {
  header = "clang_profiling_buildflags.h"
  header_dir = "base"

  flags = [
    "CLANG_PROFILING=$use_clang_profiling",
    "CLANG_PROFILING_INSIDE_SANDBOX=$use_clang_profiling_inside_sandbox",
    "USE_CLANG_COVERAGE=$use_clang_coverage",
  ]
}

buildflag_header("sanitizer_buildflags") {
  header = "sanitizer_buildflags.h"
  header_dir = "base"

  flags = [
    "IS_HWASAN=$is_hwasan",
    "IS_UBSAN=$is_ubsan",
    "IS_UBSAN_SECURITY=$is_ubsan_security",
    "USING_SANITIZER=$using_sanitizer",
  ]
}

buildflag_header("tracing_buildflags") {
  header = "tracing_buildflags.h"

  flags = [
    "ENABLE_BASE_TRACING=$enable_base_tracing",
    "USE_PERFETTO_TRACE_PROCESSOR=$use_perfetto_trace_processor",
    "OPTIONAL_TRACE_EVENTS_ENABLED=$optional_trace_events_enabled",
  ]
}

buildflag_header("profiler_buildflags") {
  header = "profiler_buildflags.h"
  header_dir = "base/profiler"

  flags = [
    "ENABLE_ARM_CFI_TABLE=$enable_arm_cfi_table",
    "IOS_STACK_PROFILER_ENABLED=$ios_stack_profiler_enabled",
  ]
}

buildflag_header("power_monitor_buildflags") {
  header = "power_monitor_buildflags.h"
  header_dir = "base/power_monitor"
  _has_battery_provider_impl = is_win || is_mac

  flags = [ "HAS_BATTERY_LEVEL_PROVIDER_IMPL=$_has_battery_provider_impl" ]
}

buildflag_header("fuzzing_buildflags") {
  header = "fuzzing_buildflags.h"
  flags = [ "USE_FUZZING_ENGINE=$use_fuzzing_engine" ]
}

# This is the subset of files from base that should not be used with a dynamic
# library. Note that this library cannot depend on base because base depends on
# base_static.
static_library("base_static") {
  sources = [
    "base_export.h",
    "base_switches.cc",
    "base_switches.h",
    "immediate_crash.h",
  ]

  deps = [
    ":fuzzing_buildflags",
    "//build:chromeos_buildflags",
  ]

  if (is_win) {
    sources += [
      "win/static_constants.cc",
      "win/static_constants.h",
    ]

    public_deps = [ "//base/win:pe_image" ]

    # Disable sanitizer coverage in win/pe_image.cc. It is called by the sandbox
    # before sanitizer coverage can initialize. http://crbug.com/484711
    configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ]
    configs +=
        [ "//build/config/sanitizers:default_sanitizer_flags_but_coverage" ]
  }

  if (!is_debug) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }
}

component("i18n") {
  output_name = "base_i18n"
  sources = [
    "i18n/base_i18n_export.h",
    "i18n/base_i18n_switches.cc",
    "i18n/base_i18n_switches.h",
    "i18n/break_iterator.cc",
    "i18n/break_iterator.h",
    "i18n/case_conversion.cc",
    "i18n/case_conversion.h",
    "i18n/char_iterator.cc",
    "i18n/char_iterator.h",
    "i18n/character_encoding.cc",
    "i18n/character_encoding.h",
    "i18n/encoding_detection.cc",
    "i18n/encoding_detection.h",
    "i18n/file_util_icu.cc",
    "i18n/file_util_icu.h",
    "i18n/i18n_constants.cc",
    "i18n/i18n_constants.h",
    "i18n/icu_string_conversions.cc",
    "i18n/icu_string_conversions.h",
    "i18n/icu_util.cc",
    "i18n/icu_util.h",
    "i18n/message_formatter.cc",
    "i18n/message_formatter.h",
    "i18n/number_formatting.cc",
    "i18n/number_formatting.h",
    "i18n/rtl.cc",
    "i18n/rtl.h",
    "i18n/streaming_utf8_validator.cc",
    "i18n/streaming_utf8_validator.h",
    "i18n/string_compare.cc",
    "i18n/string_compare.h",
    "i18n/string_search.cc",
    "i18n/string_search.h",
    "i18n/time_formatting.cc",
    "i18n/time_formatting.h",
    "i18n/timezone.cc",
    "i18n/timezone.h",
    "i18n/unicodestring.h",
    "i18n/utf8_validator_tables.cc",
    "i18n/utf8_validator_tables.h",
  ]
  defines = [ "BASE_I18N_IMPLEMENTATION" ]
  configs += [ "//build/config/compiler:wexit_time_destructors" ]
  public_deps = [
    ":base",
    "//third_party/ced",
    "//third_party/icu",
  ]
  deps = [
    "//build:chromecast_buildflags",
    "//build:chromeos_buildflags",
  ]

  if (!is_debug) {
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }

  if (is_mac) {
    frameworks = [ "CoreFoundation.framework" ]
  }
}

executable("containers_memory_benchmark") {
  sources = [ "containers/containers_memory_benchmark.cc" ]
  deps = [ ":base" ]
  testonly = true
}

test("base_perftests") {
  sources = [
    "big_endian_perftest.cc",
    "hash/hash_perftest.cc",
    "json/json_perftest.cc",
    "message_loop/message_pump_perftest.cc",
    "observer_list_perftest.cc",
    "rand_util_perftest.cc",
    "strings/string_util_perftest.cc",
    "substring_set_matcher/substring_set_matcher_perftest.cc",
    "synchronization/lock_perftest.cc",
    "synchronization/waitable_event_perftest.cc",
    "task/job_perftest.cc",
    "task/sequence_manager/sequence_manager_perftest.cc",
    "task/thread_pool/thread_pool_perftest.cc",
    "threading/counter_perftest.cc",
    "threading/thread_local_storage_perftest.cc",
    "threading/thread_perftest.cc",
    "types/expected_macros_perftest.cc",
  ]

  deps = [
    ":base",
    ":debugging_buildflags",
    "//base/test:test_support",
    "//base/test:test_support_perf",
    "//testing/gtest",
    "//testing/perf",
    "//third_party/google_benchmark",
  ]

  # TODO(crbug.com/40158212): Move partition_alloc tests into its repository.
  if (use_partition_alloc) {
    sources += [
      "allocator/partition_allocator/src/partition_alloc/partition_alloc_perftest.cc",
      "allocator/partition_allocator/src/partition_alloc/partition_lock_perftest.cc",
    ]
    deps += [ "allocator/partition_allocator/src/partition_alloc:test_support" ]
  }

  data_deps = [
    # Needed for isolate script to execute.
    "//testing:run_perf_test",
  ]

  if (is_android) {
    deps += [ "//testing/android/native_test:native_test_native_code" ]
    shard_timeout = 600
  }

  if (is_fuchsia) {
    # Run these performance tests against the actual system.
    run_as_chromium_system_test = true
  }

  if (!is_official_build) {
    # The extra data tables required by stack traces are turned off for official
    # build, only do stack trace perftest for unofficial build
    sources += [ "debug/stack_trace_perftest.cc" ]
  }

  if (build_allocation_stack_trace_recorder) {
    sources += [ "debug/allocation_trace_perftest.cc" ]
  }
}

test("base_i18n_perftests") {
  sources = [ "i18n/streaming_utf8_validator_perftest.cc" ]
  deps = [
    ":base",
    ":i18n",
    "//base/test:test_support",
    "//base/test:test_support_perf",
    "//testing/gtest",
  ]
}

if (!is_ios) {
  executable("build_utf8_validator_tables") {
    sources = [ "i18n/build_utf8_validator_tables.cc" ]
    deps = [
      ":base",
      "//build/win:default_exe_manifest",
      "//third_party/icu:icuuc",
    ]
  }

  executable("check_example") {
    sources = [ "check_example.cc" ]
    deps = [
      ":base",
      "//build/win:default_exe_manifest",
    ]
  }

  executable("json_perftest_decodebench") {
    sources = [ "json/json_perftest_decodebench.cc" ]
    deps = [ ":base" ]
  }
}

if (is_win) {
  # Target to manually rebuild pe_image_test.dll which is checked into
  # base/test/data/pe_image.
  shared_library("pe_image_test") {
    sources = [ "win/pe_image_test.cc" ]
    ldflags = [
      "/DELAYLOAD:cfgmgr32.dll",
      "/DELAYLOAD:shell32.dll",
      "/SUBSYSTEM:WINDOWS",
    ]
    libs = [
      "cfgmgr32.lib",
      "shell32.lib",
    ]
  }

  loadable_module("scoped_handle_test_dll") {
    sources = [ "win/scoped_handle_test_dll.cc" ]
    deps = [
      ":base",
      "//base/win:base_win_buildflags",
    ]
  }
}

if ((is_win && (current_cpu == "x64" || current_cpu == "arm64")) || is_mac ||
    (is_android && (current_cpu == "arm" || current_cpu == "arm64")) ||
    (is_chromeos && (current_cpu == "x64" || current_cpu == "arm64"))) {
  # Must be a loadable module so that it can be loaded/unloaded at runtime
  # during testing.
  loadable_module("base_profiler_test_support_library") {
    testonly = true
    sources = [ "profiler/test_support_library.cc" ]

    # Don't link libc++ and libc++abi into the shared library.
    # libc++abi uses `thread_local`, and that interferes with
    # the ability to unload shared libraries on some systems.
    no_default_deps = true
    if (!toolchain_for_rust_host_build_tools) {
      deps = [ "//build/config:common_deps_without_libcxx" ]
      configs += [ "//build/config/sanitizers:link_shared_library" ]
    }
  }
}

if (is_android && (current_cpu == "arm" || current_cpu == "arm64")) {
  # Use separate library for
  # |LibunwindstackUnwinderAndroidTest.ReparsesMapsOnNewDynamicLibraryLoad|
  # testcase. We can't use the existing `base_profiler_test_support_library`
  # library for this test since this gets loaded by other tests and unloading
  # a library in Android doesn't guarantee it will actually be unloaded.
  # And in the test we would like to observe the change in /proc/self/maps
  # on loading a dynamic library.
  loadable_module("base_profiler_reparsing_test_support_library") {
    testonly = true
    sources = [ "profiler/test_support_library.cc" ]

    # For consistency with base_profiler_reparsing_test_support_library.
    no_default_deps = true
    if (!toolchain_for_rust_host_build_tools) {
      deps = [ "//build/config:common_deps_without_libcxx" ]
      configs += [ "//build/config/sanitizers:link_shared_library" ]
    }
  }
}

if (is_android) {
  source_set("native_unwinder_android") {
    # This target is intended to be used only within the stack_unwinder dynamic
    # feature module, to avoid binary size increase in Chrome due to the
    # libunwindstack dependency. The additional :* visibility is needed to allow
    # use by base test targets.
    visibility = [
      ":*",
      "//chrome/android/modules/stack_unwinder/internal:*",
    ]
    sources = [
      "profiler/libunwindstack_unwinder_android.cc",
      "profiler/libunwindstack_unwinder_android.h",
      "profiler/native_unwinder_android.cc",
      "profiler/native_unwinder_android.h",
      "profiler/native_unwinder_android_memory_regions_map_impl.cc",
      "profiler/native_unwinder_android_memory_regions_map_impl.h",
    ]

    public_deps = [
      ":base",
      "//third_party/libunwindstack",
    ]
  }
}

source_set("base_stack_sampling_profiler_test_util") {
  testonly = true
  sources = [
    "profiler/stack_sampling_profiler_test_util.cc",
    "profiler/stack_sampling_profiler_test_util.h",
  ]
  deps = [
    ":base",
    "//base/test:test_support",
    "//testing/gtest",
  ]
  if (is_android) {
    sources += [
      "profiler/stack_sampling_profiler_java_test_util.cc",
      "profiler/stack_sampling_profiler_java_test_util.h",
    ]
    deps += [
      ":base_profiler_test_support_jni",
      ":native_unwinder_android",
    ]
  }
}

if (is_apple) {
  bundle_data("base_unittests_bundle_data") {
    testonly = true
    sources = [
      "//tools/metrics/actions/actions.xml",
      "//tools/metrics/histograms/enums.xml",
      "//tools/metrics/histograms/test_data/histograms.xml",
      "test/data/file_util/binary_file.bin",
      "test/data/file_util/binary_file_diff.bin",
      "test/data/file_util/binary_file_same.bin",
      "test/data/file_util/blank_line.txt",
      "test/data/file_util/blank_line_crlf.txt",
      "test/data/file_util/crlf.txt",
      "test/data/file_util/different.txt",
      "test/data/file_util/different_first.txt",
      "test/data/file_util/different_last.txt",
      "test/data/file_util/empty1.txt",
      "test/data/file_util/empty2.txt",
      "test/data/file_util/first1.txt",
      "test/data/file_util/first2.txt",
      "test/data/file_util/original.txt",
      "test/data/file_util/same.txt",
      "test/data/file_util/same_length.txt",
      "test/data/file_util/shortened.txt",
      "test/data/json/bom_feff.json",
      "test/data/pe_image_reader/signed.exe",
      "test/data/serializer_nested_test.json",
      "test/data/serializer_test.json",
      "test/data/serializer_test_nowhitespace.json",
    ]
    outputs = [ "{{bundle_resources_dir}}/" +
                "{{source_root_relative_dir}}/{{source_file_part}}" ]
  }
}

# Generated file whose location is verified in DIR_GEN_TEST_DATA_ROOT test.
generated_file("generate_file_for_test") {
  testonly = true
  outputs = [ "$target_gen_dir/generated_file_for_test.txt" ]
  data = [ "$target_gen_dir/generated_file_for_test.txt" ]
  contents = "Hello world"
}

if (is_ios) {
  bundle_data("base_test_proto_bundle_data") {
    testonly = true
    public_deps = [ "//base/test:test_proto_descriptor" ]
    sources = [ "$root_gen_dir/base/test/test_proto.descriptor" ]
    outputs = [ "{{bundle_resources_dir}}/gen/base/test/{{source_file_part}}" ]
  }

  bundle_data("base_generated_test_file_bundle_data") {
    testonly = true
    public_deps = [ ":generate_file_for_test" ]
    sources = [ "$target_gen_dir/generated_file_for_test.txt" ]
    outputs = [ "{{bundle_resources_dir}}/gen/base/{{source_file_part}}" ]
  }
}

if (is_apple) {
  source_set("base_unittests_noarc") {
    testonly = true
    sources = [ "apple/scoped_nsobject_unittest.mm" ]

    # Do not compile with ARC because this target has tests for code that does
    # not compile with ARC.
    configs -= [ "//build/config/compiler:enable_arc" ]
    deps = [
      ":base",
      "//base/test:test_support",
      "//testing/gtest",
    ]
  }
}

if (!is_nacl && (is_linux || is_chromeos)) {
  # This test must compile with -fstack-protector-all
  source_set("stack_canary_linux_unittests") {
    testonly = true

    sources = [ "stack_canary_linux_unittest.cc" ]
    cflags = [ "-fstack-protector-all" ]

    deps = [
      "//base",
      "//testing/gtest",
    ]
  }
}

if (is_fuchsia) {
  fidl_library("testfidl") {
    library_name = "base.testfidl"

    sources = [ "fuchsia/test.test-fidl" ]
  }

  # TODO(crbug.com/40256912): remove this once all users are migrated to natural bindings.
  source_set("test_interface_impl") {
    testonly = true
    sources = [
      "fuchsia/test_interface_impl.cc",
      "fuchsia/test_interface_impl.h",
    ]
    deps = [
      ":base",
      "//testing/gtest",
    ]
    public_deps = [
      ":testfidl_hlcpp",
      "//third_party/fuchsia-sdk/sdk/pkg/fidl_cpp",
      "//third_party/fuchsia-sdk/sdk/pkg/zx",
    ]
  }

  source_set("test_interface_natural_impl") {
    testonly = true
    public = [ "fuchsia/test_interface_natural_impl.h" ]
    sources = [ "fuchsia/test_interface_natural_impl.cc" ]
    deps = [
      ":base",
      "//testing/gtest",
      "//third_party/fuchsia-sdk/sdk/pkg/async",
    ]
    public_deps = [
      ":testfidl_cpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io:fuchsia.io_cpp_common",
      "//third_party/fuchsia-sdk/sdk/pkg/fidl_cpp_wire",
      "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
    ]
  }

  source_set("test_log_listener_safe") {
    testonly = true
    sources = [
      "fuchsia/test_log_listener_safe.cc",
      "fuchsia/test_log_listener_safe.h",
    ]
    deps = [
      ":base",
      "//base/test:test_support",
      "//testing/gtest",
    ]
    public_deps = [
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.logger:fuchsia.logger_hlcpp",
    ]
  }
}

source_set("path_service_unittest") {
  testonly = true

  sources = [ "path_service_unittest.cc" ]

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

  if (is_ios) {
    deps += [ ":base_generated_test_file_bundle_data" ]
  } else {
    data_deps = [ ":generate_file_for_test" ]
  }
}

test("base_unittests") {
  sources = [
    "allocator/dispatcher/dispatcher_unittest.cc",
    "allocator/dispatcher/initializer_unittest.cc",
    "allocator/dispatcher/internal/dispatcher_internal_unittest.cc",
    "allocator/dispatcher/testing/dispatcher_test.cc",
    "allocator/dispatcher/testing/dispatcher_test.h",
    "allocator/dispatcher/testing/observer_mock.h",
    "allocator/dispatcher/testing/tools.h",
    "allocator/dispatcher/tls_unittest.cc",
    "at_exit_unittest.cc",
    "atomicops_unittest.cc",
    "auto_reset_unittest.cc",
    "barrier_callback_unittest.cc",
    "barrier_closure_unittest.cc",
    "base64_unittest.cc",
    "base64url_unittest.cc",
    "bit_cast_unittest.cc",
    "bits_unittest.cc",
    "build_time_unittest.cc",
    "callback_list_unittest.cc",
    "cancelable_callback_unittest.cc",
    "check_is_test_unittest.cc",
    "check_unittest.cc",
    "command_line_unittest.cc",
    "component_export_unittest.cc",
    "containers/adapters_unittest.cc",
    "containers/buffer_iterator_unittest.cc",
    "containers/checked_iterators_unittest.cc",
    "containers/circular_deque_unittest.cc",
    "containers/contains_unittest.cc",
    "containers/enum_set_unittest.cc",
    "containers/extend_unittest.cc",
    "containers/fixed_flat_map_unittest.cc",
    "containers/fixed_flat_set_unittest.cc",
    "containers/flat_map_unittest.cc",
    "containers/flat_set_unittest.cc",
    "containers/flat_tree_unittest.cc",
    "containers/heap_array_unittest.cc",
    "containers/id_map_unittest.cc",
    "containers/intrusive_heap_unittest.cc",
    "containers/linked_list_unittest.cc",
    "containers/lru_cache_unittest.cc",
    "containers/map_util_unittest.cc",
    "containers/small_map_unittest.cc",
    "containers/span_or_size_unittest.cc",
    "containers/span_reader_unittest.cc",
    "containers/span_unittest.cc",
    "containers/span_writer_unittest.cc",
    "containers/to_value_list_unittest.cc",
    "containers/to_vector_unittest.cc",
    "containers/unique_ptr_adapters_unittest.cc",
    "containers/vector_buffer_unittest.cc",
    "cpu_unittest.cc",
    "debug/alias_unittest.cc",
    "debug/asan_service_unittest.cc",
    "debug/crash_logging_unittest.cc",
    "debug/debugger_unittest.cc",
    "debug/dump_without_crashing_unittest.cc",
    "debug/stack_trace_unittest.cc",
    "debug/task_trace_unittest.cc",
    "environment_unittest.cc",
    "feature_list_unittest.cc",
    "files/block_tests_writing_to_special_dirs_unittest.cc",
    "files/file_enumerator_unittest.cc",
    "files/file_error_or_unittest.cc",
    "files/file_path_unittest.cc",
    "files/file_path_watcher_unittest.cc",
    "files/file_proxy_unittest.cc",
    "files/file_unittest.cc",
    "files/file_util_unittest.cc",
    "files/important_file_writer_cleaner_unittest.cc",
    "files/important_file_writer_unittest.cc",
    "files/memory_mapped_file_unittest.cc",
    "files/safe_base_name_unittest.cc",
    "files/scoped_temp_dir_unittest.cc",
    "files/scoped_temp_file_unittest.cc",
    "functional/bind_unittest.cc",
    "functional/callback_helpers_unittest.cc",
    "functional/callback_unittest.cc",
    "functional/concurrent_callbacks_unittest.cc",
    "functional/concurrent_closures_unittest.cc",
    "functional/function_ref_unittest.cc",
    "functional/overloaded_unittest.cc",
    "gmock_unittest.cc",
    "hash/hash_unittest.cc",
    "hash/legacy_hash_unittest.cc",
    "hash/md5_constexpr_unittest.cc",
    "hash/md5_unittest.cc",
    "hash/sha1_unittest.cc",
    "i18n/break_iterator_unittest.cc",
    "i18n/case_conversion_unittest.cc",
    "i18n/char_iterator_unittest.cc",
    "i18n/character_encoding_unittest.cc",
    "i18n/file_util_icu_unittest.cc",
    "i18n/icu_string_conversions_unittest.cc",
    "i18n/icu_util_unittest.cc",
    "i18n/message_formatter_unittest.cc",
    "i18n/number_formatting_unittest.cc",
    "i18n/rtl_unittest.cc",
    "i18n/streaming_utf8_validator_unittest.cc",
    "i18n/string_search_unittest.cc",
    "i18n/time_formatting_unittest.cc",
    "i18n/timezone_unittest.cc",
    "i18n/transliterator_unittest.cc",
    "immediate_crash_unittest.cc",
    "json/json_parser_unittest.cc",
    "json/json_reader_unittest.cc",
    "json/json_value_converter_unittest.cc",
    "json/json_value_serializer_unittest.cc",
    "json/json_writer_unittest.cc",
    "json/string_escape_unittest.cc",
    "json/values_util_unittest.cc",
    "lazy_instance_unittest.cc",
    "logging_unittest.cc",
    "memory/aligned_memory_unittest.cc",
    "memory/discardable_memory_backing_field_trial_unittest.cc",
    "memory/discardable_shared_memory_unittest.cc",
    "memory/memory_pressure_listener_unittest.cc",
    "memory/platform_shared_memory_region_unittest.cc",
    "memory/protected_memory_unittest.cc",
    "memory/ptr_util_unittest.cc",
    "memory/raw_ptr_asan_unittest.cc",
    "memory/raw_ptr_chromium_unittest.cc",
    "memory/raw_span_unittest.cc",
    "memory/ref_counted_memory_unittest.cc",
    "memory/ref_counted_unittest.cc",
    "memory/safe_ref_unittest.cc",
    "memory/safety_checks_unittest.cc",
    "memory/shared_memory_hooks_unittest.cc",
    "memory/shared_memory_mapping_unittest.cc",
    "memory/shared_memory_region_unittest.cc",
    "memory/singleton_unittest.cc",
    "memory/structured_shared_memory_unittest.cc",
    "memory/unsafe_shared_memory_pool_unittest.cc",
    "memory/values_equivalent_unittest.cc",
    "memory/weak_auto_reset_unittest.cc",
    "memory/weak_ptr_unittest.cc",
    "message_loop/message_pump_glib_unittest.cc",
    "message_loop/message_pump_unittest.cc",
    "message_loop/work_id_provider_unittest.cc",
    "metrics/bucket_ranges_unittest.cc",
    "metrics/crc32_unittest.cc",
    "metrics/field_trial_params_unittest.cc",
    "metrics/field_trial_unittest.cc",
    "metrics/histogram_base_unittest.cc",
    "metrics/histogram_delta_serialization_unittest.cc",
    "metrics/histogram_functions_unittest.cc",
    "metrics/histogram_macros_unittest.cc",
    "metrics/histogram_samples_unittest.cc",
    "metrics/histogram_snapshot_manager_unittest.cc",
    "metrics/histogram_threadsafe_unittest.cc",
    "metrics/histogram_unittest.cc",
    "metrics/metrics_hashes_unittest.cc",
    "metrics/persistent_histogram_allocator_unittest.cc",
    "metrics/persistent_histogram_storage_unittest.cc",
    "metrics/persistent_memory_allocator_unittest.cc",
    "metrics/persistent_sample_map_unittest.cc",
    "metrics/ranges_manager_unittest.cc",
    "metrics/sample_map_unittest.cc",
    "metrics/sample_vector_unittest.cc",
    "metrics/single_sample_metrics_unittest.cc",
    "metrics/sparse_histogram_unittest.cc",
    "metrics/statistics_recorder_starvation_unittest.cc",
    "metrics/statistics_recorder_unittest.cc",
    "moving_window_unittest.cc",
    "native_library_unittest.cc",
    "no_destructor_unittest.cc",
    "observer_list_threadsafe_unittest.cc",
    "observer_list_unittest.cc",
    "one_shot_event_unittest.cc",
    "parameter_pack_unittest.cc",
    "pickle_unittest.cc",
    "power_monitor/battery_level_provider_unittest.cc",
    "power_monitor/battery_state_sampler_unittest.cc",
    "power_monitor/power_monitor_device_source_unittest.cc",
    "power_monitor/power_monitor_unittest.cc",
    "power_monitor/timer_sampling_event_source_unittest.cc",
    "process/environment_internal_unittest.cc",
    "process/launch_unittest.cc",
    "process/memory_unittest.cc",
    "process/process_metrics_unittest.cc",
    "process/process_unittest.cc",
    "process/process_util_unittest.cc",
    "profiler/metadata_recorder_unittest.cc",
    "profiler/module_cache_unittest.cc",
    "profiler/sample_metadata_unittest.cc",
    "profiler/stack_buffer_unittest.cc",
    "profiler/stack_copier_suspend_unittest.cc",
    "profiler/stack_copier_unittest.cc",
    "profiler/stack_sampler_unittest.cc",
    "profiler/stack_sampling_profiler_unittest.cc",
    "rand_util_unittest.cc",
    "ranges/algorithm_unittest.cc",
    "ranges/functional_unittest.cc",
    "run_loop_unittest.cc",
    "safe_numerics_unittest.cc",
    "sampling_heap_profiler/lock_free_address_hash_set_unittest.cc",
    "scoped_add_feature_flags_unittest.cc",
    "scoped_clear_last_error_unittest.cc",
    "scoped_generic_unittest.cc",
    "scoped_multi_source_observation_unittest.cc",
    "scoped_native_library_unittest.cc",
    "scoped_observation_unittest.cc",
    "security_unittest.cc",
    "sequence_checker_unittest.cc",
    "sequence_token_unittest.cc",
    "state_transitions_unittest.cc",
    "std_clamp_unittest.cc",
    "stl_util_unittest.cc",
    "strings/abseil_string_number_conversions_unittest.cc",
    "strings/cstring_view_unittest.cc",
    "strings/escape_unittest.cc",
    "strings/levenshtein_distance_unittest.cc",
    "strings/no_trigraphs_unittest.cc",
    "strings/pattern_unittest.cc",
    "strings/safe_sprintf_unittest.cc",
    "strings/strcat_unittest.cc",
    "strings/string_number_conversions_unittest.cc",
    "strings/string_split_unittest.cc",
    "strings/string_tokenizer_unittest.cc",
    "strings/string_util_unittest.cc",
    "strings/stringize_macros_unittest.cc",
    "strings/stringprintf_unittest.cc",
    "strings/sys_string_conversions_unittest.cc",
    "strings/to_string_unittest.cc",
    "strings/utf_offset_string_conversions_unittest.cc",
    "strings/utf_string_conversion_utils_unittest.cc",
    "strings/utf_string_conversions_unittest.cc",
    "substring_set_matcher/string_pattern_unittest.cc",
    "substring_set_matcher/substring_set_matcher_unittest.cc",
    "supports_user_data_unittest.cc",
    "sync_socket_unittest.cc",
    "synchronization/atomic_flag_unittest.cc",
    "synchronization/condition_variable_unittest.cc",
    "synchronization/lock_unittest.cc",
    "synchronization/waitable_event_unittest.cc",
    "synchronization/waitable_event_watcher_unittest.cc",
    "sys_byteorder_unittest.cc",
    "system/sys_info_unittest.cc",
    "system/system_monitor_unittest.cc",
    "task/bind_post_task_unittest.cc",
    "task/cancelable_task_tracker_unittest.cc",
    "task/common/checked_lock_unittest.cc",
    "task/common/operations_controller_unittest.cc",
    "task/common/task_annotator_unittest.cc",
    "task/default_delayed_task_handle_delegate_unittest.cc",
    "task/deferred_sequenced_task_runner_unittest.cc",
    "task/delayed_task_handle_unittest.cc",
    "task/lazy_thread_pool_task_runner_unittest.cc",
    "task/post_job_unittest.cc",
    "task/scoped_set_task_priority_for_current_thread_unittest.cc",
    "task/sequence_manager/atomic_flag_set_unittest.cc",
    "task/sequence_manager/lazily_deallocated_deque_unittest.cc",
    "task/sequence_manager/sequence_manager_impl_unittest.cc",
    "task/sequence_manager/task_order_unittest.cc",
    "task/sequence_manager/task_queue_selector_unittest.cc",
    "task/sequence_manager/task_queue_unittest.cc",
    "task/sequence_manager/test/mock_time_message_pump_unittest.cc",
    "task/sequence_manager/thread_controller_power_monitor_unittest.cc",
    "task/sequence_manager/thread_controller_with_message_pump_impl_unittest.cc",
    "task/sequence_manager/wake_up_queue_unittest.cc",
    "task/sequence_manager/work_deduplicator_unittest.cc",
    "task/sequence_manager/work_queue_sets_unittest.cc",
    "task/sequence_manager/work_queue_unittest.cc",
    "task/sequence_manager/work_tracker_unittest.cc",
    "task/sequenced_task_runner_unittest.cc",
    "task/single_thread_task_executor_unittest.cc",
    "task/single_thread_task_runner_unittest.cc",
    "task/task_runner_unittest.cc",
    "task/task_traits_unittest.cc",
    "task/thread_pool/can_run_policy_test.h",
    "task/thread_pool/delayed_priority_queue_unittest.cc",
    "task/thread_pool/delayed_task_manager_unittest.cc",
    "task/thread_pool/environment_config_unittest.cc",
    "task/thread_pool/job_task_source_unittest.cc",
    "task/thread_pool/pooled_single_thread_task_runner_manager_unittest.cc",
    "task/thread_pool/priority_queue_unittest.cc",
    "task/thread_pool/sequence_unittest.cc",
    "task/thread_pool/service_thread_unittest.cc",
    "task/thread_pool/task_source_sort_key_unittest.cc",
    "task/thread_pool/task_tracker_unittest.cc",
    "task/thread_pool/test_task_factory.cc",
    "task/thread_pool/test_task_factory.h",
    "task/thread_pool/test_utils.cc",
    "task/thread_pool/test_utils.h",
    "task/thread_pool/thread_group_impl_unittest.cc",
    "task/thread_pool/thread_group_unittest.cc",
    "task/thread_pool/thread_pool_impl_unittest.cc",
    "task/thread_pool/tracked_ref_unittest.cc",
    "task/thread_pool/worker_thread_set_unittest.cc",
    "task/thread_pool_unittest.cc",
    "test/gmock_callback_support_unittest.cc",
    "test/gmock_expected_support_unittest.cc",
    "test/gmock_move_support_unittest.cc",
    "test/gtest_links_unittest.cc",
    "test/gtest_tags_unittest.cc",
    "test/gtest_xml_unittest_result_printer_unittest.cc",
    "test/launcher/test_launcher_unittest.cc",
    "test/launcher/test_results_tracker_unittest.cc",
    "test/memory/dangling_ptr_instrumentation.cc",
    "test/memory/dangling_ptr_instrumentation.h",
    "test/metrics/action_suffix_reader_unittest.cc",
    "test/metrics/histogram_enum_reader_unittest.cc",
    "test/metrics/histogram_tester_unittest.cc",
    "test/metrics/histogram_variants_reader_unittest.cc",
    "test/metrics/user_action_tester_unittest.cc",
    "test/mock_callback_unittest.cc",
    "test/rectify_callback_unittest.cc",
    "test/repeating_test_future_unittest.cc",
    "test/run_until_unittest.cc",
    "test/scoped_feature_list_unittest.cc",
    "test/scoped_logging_settings.h",
    "test/scoped_mock_clock_override_unittest.cc",
    "test/scoped_mock_time_message_loop_task_runner_unittest.cc",
    "test/scoped_run_loop_timeout_unittest.cc",
    "test/task_environment_unittest.cc",
    "test/test_future_unittest.cc",
    "test/test_mock_time_task_runner_unittest.cc",
    "test/test_pending_task_unittest.cc",
    "test/test_proto_loader_unittest.cc",
    "test/test_waitable_event_unittest.cc",
    "thread_annotations_unittest.cc",
    "threading/hang_watcher_unittest.cc",
    "threading/platform_thread_unittest.cc",
    "threading/post_task_and_reply_impl_unittest.cc",
    "threading/scoped_blocking_call_unittest.cc",
    "threading/scoped_thread_priority_unittest.cc",
    "threading/sequence_bound_unittest.cc",
    "threading/sequence_local_storage_map_unittest.cc",
    "threading/sequence_local_storage_slot_unittest.cc",
    "threading/simple_thread_unittest.cc",
    "threading/thread_checker_unittest.cc",
    "threading/thread_collision_warner_unittest.cc",
    "threading/thread_id_name_manager_unittest.cc",
    "threading/thread_local_storage_unittest.cc",
    "threading/thread_local_unittest.cc",
    "threading/thread_restrictions_unittest.cc",
    "threading/thread_unittest.cc",
    "threading/watchdog_unittest.cc",
    "time/pr_time_unittest.cc",
    "time/time_delta_from_string_unittest.cc",
    "time/time_unittest.cc",
    "timer/elapsed_timer_unittest.cc",
    "timer/hi_res_timer_manager_unittest.cc",
    "timer/lap_timer_unittest.cc",
    "timer/mock_timer_unittest.cc",
    "timer/timer_unittest.cc",
    "timer/wall_clock_timer_unittest.cc",
    "token_unittest.cc",
    "tools_sanity_unittest.cc",
    "traits_bag_unittest.cc",
    "tuple_unittest.cc",
    "types/cxx23_is_scoped_enum_unittest.cc",
    "types/cxx23_to_underlying_unittest.cc",
    "types/expected_macros_unittest.cc",
    "types/expected_unittest.cc",
    "types/fixed_array_unittest.cc",
    "types/id_type_unittest.cc",
    "types/is_complete_unittest.cc",
    "types/is_instantiation_unittest.cc",
    "types/optional_ref_unittest.cc",
    "types/optional_unittest.cc",
    "types/optional_util_unittest.cc",
    "types/pass_key_unittest.cc",
    "types/strong_alias_unittest.cc",
    "types/supports_ostream_operator_unittest.cc",
    "types/to_address_unittest.cc",
    "types/token_type_unittest.cc",
    "types/variant_util_unittest.cc",
    "unguessable_token_unittest.cc",
    "unsafe_buffers_unittest.cc",
    "uuid_unittest.cc",
    "value_iterators_unittest.cc",
    "values_unittest.cc",
    "version_unittest.cc",
    "vlog_unittest.cc",

    # TODO(crbug.com/40158212): Move partition_alloc tests into its repository.
    "allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_test_support.h",
    "allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_unittest.cc",
    "allocator/partition_allocator/src/partition_alloc/pointers/raw_ref_unittest.cc",
  ]

  if (!is_cronet_build) {
    # location_unittest.cc fails gn check for tracing-shimmed Cronet builds.
    # Cronet buildbot do not run base_unittests, so exclusing this test
    # instead of adding a nogncheck is preferred (crbug.com/1400235).
    sources += [ "location_unittest.cc" ]
  }

  if (build_rust_base_conversions) {
    sources += [
      "containers/span_rust_unittest.cc",
      "strings/string_piece_rust_unittest.cc",
    ]
  }

  if (use_safe_libcxx || use_safe_libstdcxx) {
    sources += [ "libcpp_hardening_test.cc" ]
  }

  defines = []

  deps = [
    ":base",
    ":base_stack_sampling_profiler_test_util",
    ":check_version_internal",
    ":feature_list_buildflags",
    ":i18n",
    ":path_service_unittest",
    ":sanitizer_buildflags",
    "//base/allocator:buildflags",
    "//base/numerics:unittests",
    "//base/test:native_library_test_utils",
    "//base/test:proto_test_support",
    "//base/test:run_all_unittests",
    "//base/test:test_proto",
    "//base/test:test_support",
    "//build:blink_buildflags",
    "//build:branding_buildflags",
    "//build:chromecast_buildflags",
    "//build:chromeos_buildflags",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/abseil-cpp:absl",
    "//third_party/icu",
    "//third_party/modp_b64",

    # TODO(crbug.com/40158212): Move partition_alloc tests into its repository.
    "allocator/partition_allocator/src/partition_alloc:test_support",
  ]

  # TODO(crbug.com/40158212): Move partition_alloc tests into its repository.
  #
  # Note: This requires checking `build_with_chromium` because partition_alloc
  # do not provide ":unittests" when built outside of chromium.
  # "//base" is a dependency of WebRTC where `build_with_chromium` is false.
  # TODO(42223878): Remove standalone WebRTC dependency on //base.
  if (build_with_chromium) {
    deps += [ "allocator/partition_allocator/src/partition_alloc:unittests" ]
  }

  data_deps = [
    "//base/test:immediate_crash_test_helper",
    "//base/test:test_child_process",
    "//base/test:test_shared_library",
    "//testing/buildbot/filters:base_unittests_filters",
  ]

  if (is_android && enable_chrome_android_internal) {
    data_deps += [ "//clank/build/bot/filters:base_unittests_filters" ]
  }

  # Since cpu_unittest depends on __ARM_FEATURE_MEMORY_TAGGING, needs to
  # enable clang's MTE feature.
  configs += [
    "//base/allocator/partition_allocator/src/partition_alloc:memory_tagging",
  ]

  if (build_rust_base_conversions) {
    deps += [ "//build/rust:cxx_cppdeps" ]
  }

  if (is_apple) {
    public_deps = [
      ":base_unittests_bundle_data",
      ":base_unittests_noarc",
    ]
  }

  data = [
    "test/data/",
    "//tools/metrics/actions/actions.xml",
    "//tools/metrics/histograms/enums.xml",
    "//tools/metrics/histograms/test_data/histograms.xml",
  ]

  if (use_blink) {
    sources += [
      "metrics/histogram_shared_memory_unittest.cc",

      # TODO(crbug.com/40158212): Move partition_alloc tests into its repository.
      "allocator/partition_allocator/src/partition_alloc/tagging_unittest.cc",
    ]

    if (!is_ios) {
      sources += [ "memory/shared_memory_switch_unittest.cc" ]
    }

    data_deps += [ "//base/test:test_proto_descriptor" ]
    data += [ "$root_gen_dir/base/test/test_proto.descriptor" ]
  }

  if (is_win) {
    deps += [ "//base/win:base_win_buildflags" ]

    sources += [
      "debug/gdi_debug_util_win_unittest.cc",
      "file_version_info_win_unittest.cc",
      "process/launch_unittest_win.cc",
      "test/fake_iasync_operation_win_unittest.cc",
      "test/test_file_util_win_unittest.cc",
      "test/test_reg_util_win_unittest.cc",
      "threading/platform_thread_win_unittest.cc",
      "time/time_win_unittest.cc",
      "win/access_control_list_unittest.cc",
      "win/access_token_unittest.cc",
      "win/async_operation_unittest.cc",
      "win/com_init_balancer_unittest.cc",
      "win/com_init_check_hook_unittest.cc",
      "win/com_init_util_unittest.cc",
      "win/dark_mode_support_unittest.cc",
      "win/dispatch_stub.cc",
      "win/dispatch_stub.h",
      "win/dllmain.cc",
      "win/embedded_i18n/language_selector_unittest.cc",
      "win/enum_variant_unittest.cc",
      "win/event_trace_consumer_unittest.cc",
      "win/event_trace_controller_unittest.cc",
      "win/event_trace_provider_unittest.cc",
      "win/hstring_reference_unittest.cc",
      "win/i18n_unittest.cc",
      "win/map_unittest.cc",
      "win/message_window_unittest.cc",
      "win/object_watcher_unittest.cc",
      "win/pe_image_reader_unittest.cc",
      "win/pe_image_unittest.cc",
      "win/post_async_results_unittest.cc",
      "win/reference_unittest.cc",
      "win/registry_unittest.cc",
      "win/scoped_bstr_unittest.cc",
      "win/scoped_handle_unittest.cc",
      "win/scoped_hstring_unittest.cc",
      "win/scoped_localalloc_unittest.cc",
      "win/scoped_process_information_unittest.cc",
      "win/scoped_safearray_unittest.cc",
      "win/scoped_variant_unittest.cc",
      "win/scoped_winrt_initializer_unittest.cc",
      "win/security_descriptor_unittest.cc",
      "win/security_util_unittest.cc",
      "win/shortcut_unittest.cc",
      "win/sid_unittest.cc",
      "win/startup_information_unittest.cc",
      "win/variant_conversions_unittest.cc",
      "win/variant_vector_unittest.cc",
      "win/vector_unittest.cc",
      "win/win_includes_unittest.cc",
      "win/win_util_unittest.cc",
      "win/window_enumerator_unittest.cc",
      "win/windows_version_unittest.cc",
      "win/winrt_storage_util_unittest.cc",
      "win/wmi_unittest.cc",
      "win/wrapped_window_proc_unittest.cc",
    ]

    if (enable_cet_shadow_stack) {
      sources += [ "win/cet_shadow_stack_unittest.cc" ]
    }

    libs = [
      "ntdll.lib",
      "onecore.lib",
    ]
  }

  if (is_linux || is_chromeos) {
    sources += [
      "debug/proc_maps_linux_unittest.cc",
      "files/scoped_file_linux_unittest.cc",
      "nix/mime_util_xdg_unittest.cc",
      "process/set_process_title_linux_unittest.cc",
    ]

    if (!is_nacl) {
      deps += [ ":stack_canary_linux_unittests" ]
    }
  }

  if (enable_base_tracing) {
    sources += [ "test/test_trace_processor_example_unittest.cc" ]
  }

  if (is_posix) {
    sources += [
      "files/dir_reader_posix_unittest.cc",
      "files/file_descriptor_watcher_posix_unittest.cc",
      "memory/madv_free_discardable_memory_allocator_posix_unittest.cc",
      "memory/madv_free_discardable_memory_posix_unittest.cc",
      "message_loop/fd_watch_controller_posix_unittest.cc",
      "posix/file_descriptor_shuffle_unittest.cc",
      "posix/unix_domain_socket_unittest.cc",
    ]
    if (!is_nacl && !is_apple) {
      sources += [
        "profiler/stack_base_address_posix_unittest.cc",
        "profiler/stack_copier_signal_unittest.cc",
        "profiler/thread_delegate_posix_unittest.cc",
      ]
    }
  }

  # Allow more direct string conversions on platforms with native utf8
  # strings
  if (is_apple || is_chromeos || is_castos || is_cast_android || is_fuchsia) {
    defines += [ "SYSTEM_NATIVE_UTF8" ]
  }

  if (is_android) {
    # Add unwind tables in base_unittests_apk test apk. The unwind tables are
    # generated from debug info in the binary. Removing "default_symbols" and
    # adding symbols config removes the "strip_debug" config that strips the
    # debug info, on base unittests apk.
    if (can_unwind_with_cfi_table || enable_arm_cfi_table) {
      configs -= [ "//build/config/compiler:default_symbols" ]
      if (symbol_level == 2) {
        configs += [ "//build/config/compiler:symbols" ]
      } else {
        configs += [ "//build/config/compiler:minimal_symbols" ]
      }
      add_unwind_tables_in_apk = true
    }
    if (can_unwind_with_cfi_table) {
      sources += [ "trace_event/cfi_backtrace_android_unittest.cc" ]
    }
    if (current_cpu == "arm") {
      sources += [
        "profiler/chrome_unwind_info_android_unittest.cc",
        "profiler/chrome_unwinder_android_unittest.cc",
      ]
    }
    if (current_cpu == "arm64") {
      sources += [ "profiler/frame_pointer_unwinder_unittest.cc" ]
    }
    if (!exclude_unwind_tables &&
        (current_cpu == "arm" || current_cpu == "arm64")) {
      sources += [
        "profiler/libunwindstack_unwinder_android_unittest.cc",
        "profiler/native_unwinder_android_unittest.cc",
      ]
      deps += [
        ":base_profiler_reparsing_test_support_library",
        ":base_profiler_test_support_java",
        ":base_profiler_test_support_jni",
        ":base_profiler_test_support_library",
        ":native_unwinder_android",
      ]
    }

    sources += [
      "android/application_status_listener_unittest.cc",
      "android/binder_unittest.cc",
      "android/child_process_unittest.cc",
      "android/content_uri_utils_unittest.cc",
      "android/jank_metric_uma_recorder_unittest.cc",
      "android/java_handler_thread_unittest.cc",
      "android/jni_android_unittest.cc",
      "android/jni_array_unittest.cc",
      "android/jni_bytebuffer_unittest.cc",
      "android/jni_string_unittest.cc",
      "android/library_loader/library_prefetcher_unittest.cc",
      "android/linker/linker_jni.cc",
      "android/linker/linker_jni.h",
      "android/linker/linker_unittest.cc",
      "android/meminfo_dump_provider_unittest.cc",
      "android/path_utils_unittest.cc",
      "android/pmf_utils_unittest.cc",
      "android/pre_freeze_background_memory_trimmer_unittest.cc",
      "android/radio_utils_unittest.cc",
      "android/scoped_java_ref_unittest.cc",
      "android/sys_utils_unittest.cc",
      "android/token_android_unittest.cc",
      "android/unguessable_token_android_unittest.cc",
    ]

    # Android does not use test_launcher to run gtests.
    sources -= [
      "process/process_unittest.cc",
      "process/process_util_unittest.cc",
      "test/gtest_links_unittest.cc",
      "test/gtest_tags_unittest.cc",
      "test/gtest_xml_unittest_result_printer_unittest.cc",
      "test/launcher/test_launcher_unittest.cc",
      "test/launcher/test_results_tracker_unittest.cc",
    ]
    deps += [
      ":base_unittest_support_java",
      ":base_unittest_support_jni",
      "//base/test:test_support_java",
      "//third_party/jni_zero",
    ]
  }

  if (build_allocation_stack_trace_recorder) {
    sources += [ "debug/allocation_trace_unittest.cc" ]
  }

  if (is_apple || current_os == "freebsd" || current_os == "openbsd") {
    sources += [ "posix/sysctl_unittest.cc" ]
  }
  if (is_apple) {
    sources += [
      "apple/backup_util_unittest.mm",
      "apple/bind_objc_block_unittest.mm",
      "apple/dispatch_source_mach_unittest.cc",
      "apple/foundation_util_unittest.mm",
      "strings/sys_string_conversions_apple_unittest.mm",
    ]
  }

  if (is_apple) {
    sources += [ "time/time_apple_unittest.mm" ]
  }

  if (is_mac) {
    sources += [
      "apple/call_with_eh_frame_unittest.mm",
      "apple/scoped_cftyperef_unittest.cc",
      "apple/scoped_mach_vm_unittest.cc",
      "apple/scoped_nsautorelease_pool_unittest.mm",
      "apple/scoped_objc_class_swizzler_unittest.mm",
      "enterprise_util_mac_unittest.mm",
      "mac/launch_application_unittest.mm",
      "mac/mac_util_unittest.mm",
      "mac/mach_port_rendezvous_unittest.cc",
      "mac/scoped_sending_event_unittest.mm",
      "message_loop/message_pump_apple_unittest.mm",
      "power_monitor/thermal_state_observer_mac_unittest.mm",
      "process/memory_unittest_mac.h",
      "process/memory_unittest_mac.mm",
      "system/sys_info_mac_unittest.mm",
    ]
    data_deps += [ "//base/mac:launch_application_test_helper" ]
  }

  if (is_ios) {
    sources += [
      "ios/crb_protocol_observers_unittest.mm",
      "ios/device_util_unittest.mm",
      "ios/scoped_critical_action_unittest.mm",
    ]

    bundle_deps = [ ":base_test_proto_bundle_data" ]
    if (use_blink) {
      bundle_deps +=
          [ "//testing/buildbot/filters:base_unittests_filters_bundle_data" ]
    }
    if (is_cronet_build) {
      sources += [ "message_loop/message_pump_io_ios_unittest.cc" ]
    } else {
      sources += [ "message_loop/message_pump_kqueue_unittest.cc" ]
    }

    # ios does not use test_launcher to run gtests.
    sources -= [
      "files/file_path_watcher_unittest.cc",
      "memory/discardable_shared_memory_unittest.cc",
      "process/memory_unittest.cc",
      "process/process_unittest.cc",
      "process/process_util_unittest.cc",
      "sync_socket_unittest.cc",
      "synchronization/waitable_event_watcher_unittest.cc",
      "test/gtest_links_unittest.cc",
      "test/gtest_tags_unittest.cc",
      "test/gtest_xml_unittest_result_printer_unittest.cc",
      "test/launcher/test_launcher_unittest.cc",
      "test/launcher/test_results_tracker_unittest.cc",
    ]

    sources -= [
      # The immediate crash tests require shared libraries, which we don't
      # support loading on iOS.
      "immediate_crash_unittest.cc",
    ]

    if (use_blink) {
      sources += [ "files/file_path_watcher_unittest.cc" ]
    }
  }

  if (is_mac) {
    sources += [ "message_loop/message_pump_kqueue_unittest.cc" ]
    frameworks = [
      "CoreFoundation.framework",
      "Foundation.framework",
    ]
    deps += [ ":base_profiler_test_support_library" ]
  }

  if (is_fuchsia || is_linux || is_chromeos) {
    sources += [
      "debug/elf_reader_unittest.cc",
      "debug/test_elf_image_builder.cc",
      "debug/test_elf_image_builder.h",
    ]

    deps += [ "//base/test:malloc_wrapper" ]
    defines += [
      # This library is used by ElfReaderTest to test reading elf files.
      "MALLOC_WRAPPER_LIB=\"${shlib_prefix}malloc_wrapper${shlib_extension}\"",
    ]

    if (!is_component_build) {
      # Set rpath to find libmalloc_wrapper.so even in a non-component build.
      configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
    }
  }

  if (is_linux || is_chromeos_lacros) {
    sources += [
      "linux_util_unittest.cc",
      "nix/xdg_util_unittest.cc",
    ]
  }

  if (!use_glib) {
    sources -= [ "message_loop/message_pump_glib_unittest.cc" ]
  }

  if (use_epoll) {
    sources += [ "message_loop/message_pump_epoll_unittest.cc" ]
  }

  if (is_fuchsia) {
    sources += [
      "files/dir_reader_posix_unittest.cc",
      "files/file_descriptor_watcher_posix_unittest.cc",
      "fuchsia/fidl_event_handler_unittest.cc",
      "fuchsia/file_utils_unittest.cc",
      "fuchsia/filtered_service_directory_unittest.cc",
      "fuchsia/fuchsia_logging_unittest.cc",
      "fuchsia/intl_profile_watcher_unittest.cc",
      "fuchsia/mem_buffer_util_unittest.cc",
      "fuchsia/scoped_natural_service_binding_unittest.cc",
      "fuchsia/scoped_natural_service_publisher_unittest.cc",
      "fuchsia/scoped_service_binding_unittest.cc",
      "fuchsia/scoped_service_publisher_unittest.cc",
      "fuchsia/system_build_info_unittest.cc",
      "fuchsia/system_product_info_unittest.cc",
      "fuchsia/test_component_context_for_process_unittest.cc",
      "fuchsia/time_zone_data_unittest.cc",
      "message_loop/fd_watch_controller_posix_unittest.cc",
      "posix/file_descriptor_shuffle_unittest.cc",
    ]

    deps += [
      ":test_interface_impl",
      ":test_interface_natural_impl",
      ":test_log_listener_safe",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.buildinfo:fuchsia.buildinfo_cpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.buildinfo:fuchsia.buildinfo_hlcpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.hwinfo:fuchsia.hwinfo_cpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.intl:fuchsia.intl_hlcpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.logger:fuchsia.logger_cpp",
      "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.mem:fuchsia.mem_hlcpp",
      "//third_party/fuchsia-sdk/sdk/pkg/async",
      "//third_party/fuchsia-sdk/sdk/pkg/async-default",
      "//third_party/fuchsia-sdk/sdk/pkg/component_incoming_cpp",
      "//third_party/fuchsia-sdk/sdk/pkg/fdio",
      "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
    ]

    additional_manifest_fragments = [
      "//build/config/fuchsia/test/logger.shard.test-cml",

      # Required by PartitionAllocPageAllocatorTest tests with exec capability.
      "//build/config/fuchsia/test/mark_vmo_executable.shard.test-cml",
    ]
  }

  if (!is_fuchsia && !is_ios) {
    sources += [ "files/file_locking_unittest.cc" ]
  }

  if (is_android) {
    deps += [ "//testing/android/native_test:native_test_native_code" ]
    sources += [
      "debug/elf_reader_unittest.cc",
      "debug/proc_maps_linux_unittest.cc",
      "debug/test_elf_image_builder.cc",
      "debug/test_elf_image_builder.h",
    ]
  }

  if (is_win) {
    deps += [ "//base:scoped_handle_test_dll" ]
    if (current_cpu == "x64" || current_cpu == "arm64") {
      sources += [ "profiler/win32_stack_frame_unwinder_unittest.cc" ]
      deps += [ ":base_profiler_test_support_library" ]
    }

    # These tests are not built by default because they make heavy use of
    # parameterized tests. Even when disabled, they incur a startup penalty on
    # base_unittests. See comments in the file as for why they are disabled by
    # default, and https://crbug.com/1475518 for one consequence of the process
    # startup penalty.
    # sources += [ "files/os_validation_win_unittest.cc" ]

    if (toolchain_has_rust && win_enable_cfg_guards) {
      deps += [ ":rust_cfg_win_test" ]
    }
  }
  if (is_apple) {
    sources += [ "profiler/frame_pointer_unwinder_unittest.cc" ]
  }
  if (is_chromeos && (current_cpu == "x64" || current_cpu == "arm64")) {
    sources += [ "profiler/frame_pointer_unwinder_unittest.cc" ]
    deps += [ ":base_profiler_test_support_library" ]
  }

  if (use_allocator_shim) {
    sources += [
      "sampling_heap_profiler/poisson_allocation_sampler_unittest.cc",
      "sampling_heap_profiler/sampling_heap_profiler_unittest.cc",

      # TODO(crbug.com/40158212): Move partition_alloc tests into its repository.
      "allocator/partition_alloc_support_unittest.cc",
      "allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_unittest.cc",
    ]
  }

  if (enable_base_tracing) {
    sources += [
      "test/trace_event_analyzer_unittest.cc",
      "trace_event/memory_allocator_dump_unittest.cc",
      "trace_event/memory_dump_manager_unittest.cc",
      "trace_event/memory_dump_scheduler_unittest.cc",
      "trace_event/memory_infra_background_allowlist_unittest.cc",
      "trace_event/memory_usage_estimator_unittest.cc",
      "trace_event/process_memory_dump_unittest.cc",
      "trace_event/trace_arguments_unittest.cc",
      "trace_event/trace_category_unittest.cc",
      "trace_event/trace_config_unittest.cc",
      "trace_event/trace_event_unittest.cc",
      "trace_event/traced_value_support_unittest.cc",
      "trace_event/traced_value_unittest.cc",
      "trace_event/typed_macros_unittest.cc",
      "tracing/perfetto_task_runner_unittest.cc",
    ]

    if (is_android) {
      sources += [
        "trace_event/cpufreq_monitor_android_unittest.cc",
        "trace_event/java_heap_dump_provider_android_unittest.cc",
      ]
    }

    if (is_win) {
      sources += [ "trace_event/trace_logging_minimal_win_unittest.cc" ]
    }

    deps += [
      "//third_party/perfetto/include/perfetto/trace_processor:storage",
      "//third_party/perfetto/protos/perfetto/trace:lite",
      "//third_party/perfetto/protos/perfetto/trace/interned_data:lite",
      "//third_party/perfetto/protos/perfetto/trace/track_event:lite",
    ]
  }

  if (enable_nocompile_tests) {
    deps += [ ":base_nocompile_tests" ]
  }
}

# Test that CFG is enabled in Rust code.
if (is_win && toolchain_has_rust) {
  source_set("rust_cfg_win_test") {
    testonly = true
    deps = [
      ":base",
      "//testing/gtest",
    ]
    data_deps = [ "//build/rust/tests/test_control_flow_guard" ]
    sources = [ "memory/rust_cfg_win_unittest.cc" ]
  }
}

action("build_date") {
  script = "write_build_date_header.py"

  outputs = [ "$target_gen_dir/generated_build_date.h" ]

  args = [
    rebase_path("$target_gen_dir/generated_build_date.h", root_build_dir),
    build_timestamp,
  ]
}

if (enable_nocompile_tests) {
  nocompile_source_set("base_nocompile_tests") {
    sources = [
      "allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations_pa_nocompile.nc",
      "allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_nocompile.nc",
      "allocator/partition_allocator/src/partition_alloc/pointers/raw_ref_nocompile.nc",
      "callback_list_nocompile.nc",
      "containers/buffer_iterator_nocompile.nc",
      "containers/checked_iterators_nocompile.nc",
      "containers/contains_nocompile.nc",
      "containers/enum_set_nocompile.nc",
      "containers/fixed_flat_map_nocompile.nc",
      "containers/fixed_flat_set_nocompile.nc",
      "containers/heap_array_nocompile.nc",
      "containers/span_nocompile.nc",
      "containers/to_value_list_nocompile.nc",
      "containers/to_vector_nocompile.nc",
      "debug/crash_logging_nocompile.nc",
      "functional/bind_nocompile.nc",
      "functional/callback_nocompile.nc",
      "functional/function_ref_nocompile.nc",
      "functional/overloaded_nocompile.nc",
      "logging_nocompile.nc",
      "memory/protected_memory_nocompile.nc",
      "memory/ref_counted_nocompile.nc",
      "memory/shared_memory_mapping_nocompile.nc",
      "memory/structured_shared_memory_nocompile.nc",
      "memory/weak_ptr_nocompile.nc",
      "metrics/field_trial_params_nocompile.nc",
      "metrics/histogram_nocompile.nc",
      "no_destructor_nocompile.nc",
      "observer_list_nocompile.nc",
      "sequence_checker_nocompile.nc",
      "strings/cstring_view_nocompile.nc",
      "strings/stringprintf_nocompile.nc",
      "synchronization/lock_nocompile.nc",
      "task/bind_post_task_nocompile.nc",
      "task/task_traits_nocompile.nc",
      "test/bind_test_nocompile.nc",
      "thread_annotations_nocompile.nc",
      "traits_bag_nocompile.nc",
      "types/expected_macros_nocompile.nc",
      "types/pass_key_nocompile.nc",
      "types/variant_util_nocompile.nc",
      "unsafe_buffers_nocompile.nc",
      "values_nocompile.nc",
    ]
    deps = [ ":base" ]
  }
}

if (is_android || is_robolectric) {
  # This is a subset of the main "base_jni", used in the robolectric toolchain.
  # While it would be nice to just make 2 unique generate_jnis, we can't because
  # we will have 2 GEN_JNI classes in one compilation unit. This is fixable, see
  # crbug.com/330173100.
  generate_jni("base_robolectric_jni") {
    sources = [
      "android/java/src/org/chromium/base/Callback.java",
      "android/java/src/org/chromium/base/CommandLine.java",
      "android/java/src/org/chromium/base/JNIUtils.java",
      "android/java/src/org/chromium/base/JavaExceptionReporter.java",
      "android/java/src/org/chromium/base/JniAndroid.java",
      "android/java/src/org/chromium/base/Token.java",
      "android/java/src/org/chromium/base/TokenBase.java",
      "android/java/src/org/chromium/base/TraceEvent.java",
      "android/java/src/org/chromium/base/UnguessableToken.java",
      "android/java/src/org/chromium/base/library_loader/LibraryLoader.java",
      "android/java/src/org/chromium/base/metrics/NativeUmaRecorder.java",
    ]
    public_deps = [ ":android_runtime_jni_headers" ]
  }

  generate_jni("base_jni") {
    sources = [
      "android/java/src/org/chromium/base/ApkAssets.java",
      "android/java/src/org/chromium/base/BaseFeatureMap.java",
      "android/java/src/org/chromium/base/BuildInfo.java",
      "android/java/src/org/chromium/base/BundleUtils.java",
      "android/java/src/org/chromium/base/CpuFeatures.java",
      "android/java/src/org/chromium/base/EventLog.java",
      "android/java/src/org/chromium/base/FeatureList.java",
      "android/java/src/org/chromium/base/FeatureMap.java",
      "android/java/src/org/chromium/base/Features.java",
      "android/java/src/org/chromium/base/FieldTrialList.java",
      "android/java/src/org/chromium/base/FileUtils.java",
      "android/java/src/org/chromium/base/ImportantFileWriterAndroid.java",
      "android/java/src/org/chromium/base/InputHintChecker.java",
      "android/java/src/org/chromium/base/IntStringCallback.java",
      "android/java/src/org/chromium/base/JNIUtils.java",
      "android/java/src/org/chromium/base/JavaExceptionReporter.java",
      "android/java/src/org/chromium/base/JavaHandlerThread.java",
      "android/java/src/org/chromium/base/JniAndroid.java",
      "android/java/src/org/chromium/base/LocaleUtils.java",
      "android/java/src/org/chromium/base/PathService.java",
      "android/java/src/org/chromium/base/PathUtils.java",
      "android/java/src/org/chromium/base/PowerMonitor.java",
      "android/java/src/org/chromium/base/RadioUtils.java",
      "android/java/src/org/chromium/base/TimezoneUtils.java",
      "android/java/src/org/chromium/base/Token.java",
      "android/java/src/org/chromium/base/TokenBase.java",
      "android/java/src/org/chromium/base/UnguessableToken.java",
    ]

    if (use_clang_profiling) {
      sources += [
        "test/android/javatests/src/org/chromium/base/test/ClangProfiler.java",
      ]
    }

    public_deps = [ ":android_runtime_jni_headers" ]
  }

  generate_jar_jni("android_runtime_jni_headers") {
    classes = [
      "java/lang/Runnable.class",
      "java/lang/Runtime.class",
      "java/lang/Throwable.class",
    ]
  }

  generate_jni("process_launcher_jni") {
    sources = [ "android/java/src/org/chromium/base/process_launcher/ChildProcessService.java" ]
  }

  generate_jni("base_shared_preferences_jni") {
    sources = [ "android/java/src/org/chromium/base/shared_preferences/SharedPreferencesManager.java" ]
  }

  shared_library_with_jni("libbase_junit_tests") {
    testonly = true
    enable_target = is_robolectric
    sources = [ "android/robolectric_jni_onload.cc" ]
    deps = [ ":base($robolectric_toolchain)" ]
    java_targets = [ ":base_junit_tests" ]
    visibility = [ ":*" ]

    # Make jni.h available.
    configs += [ "//third_party/jdk" ]
  }
}  # is_android || is_robolectric

if (is_android) {
  java_cpp_features("java_features_srcjar") {
    # External code should depend on ":base_java" instead.
    visibility = [ ":*" ]
    sources = [
      "allocator/partition_alloc_features.cc",
      "features.cc",
      "task/task_features.cc",
    ]
    template = "android/java/src/org/chromium/base/BaseFeatures.java.tmpl"
  }

  android_library("base_switches_java") {
    srcjar_deps = [ ":java_switches_srcjar" ]
  }

  java_cpp_strings("java_switches_srcjar") {
    # External code should depend on ":base_java" instead.
    visibility = [ ":*" ]
    sources = [ "base_switches.cc" ]
    template = "android/java/src/org/chromium/base/BaseSwitches.java.tmpl"
  }

  android_library("process_launcher_java") {
    srcjar_deps = [
      ":process_launcher_aidl",
      ":process_launcher_jni",
    ]
    deps = [
      ":base_java",
      "//build/android:build_java",
      "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
      "//third_party/androidx:androidx_annotation_annotation_experimental_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/androidx:androidx_collection_collection_java",
      "//third_party/androidx:androidx_core_core_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
    sources = [
      "android/java/src/org/chromium/base/process_launcher/BindService.java",
      "android/java/src/org/chromium/base/process_launcher/ChildConnectionAllocator.java",
      "android/java/src/org/chromium/base/process_launcher/ChildProcessConnection.java",
      "android/java/src/org/chromium/base/process_launcher/ChildProcessConstants.java",
      "android/java/src/org/chromium/base/process_launcher/ChildProcessLauncher.java",
      "android/java/src/org/chromium/base/process_launcher/ChildProcessService.java",
      "android/java/src/org/chromium/base/process_launcher/ChildProcessServiceDelegate.java",
      "android/java/src/org/chromium/base/process_launcher/ChildServiceConnection.java",
      "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionDelegate.java",
      "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionFactory.java",
      "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionImpl.java",
      "android/java/src/org/chromium/base/process_launcher/FileDescriptorInfo.java",
    ]
  }

  android_library("base_java") {
    srcjar_deps = [
      ":base_android_java_enums_srcjar",
      ":base_jni",
      ":java_features_srcjar",
    ]

    deps = [
      "//build/android:build_java",
      "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
      "//third_party/android_deps:com_google_errorprone_error_prone_annotations_java",
      "//third_party/androidx:androidx_annotation_annotation_experimental_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]

    sources = [
      "android/java/src/org/chromium/base/ApkAssets.java",
      "android/java/src/org/chromium/base/BaseFeatureMap.java",
      "android/java/src/org/chromium/base/BinderCallsListener.java",
      "android/java/src/org/chromium/base/BuildInfo.java",
      "android/java/src/org/chromium/base/BundleUtils.java",
      "android/java/src/org/chromium/base/CallbackController.java",
      "android/java/src/org/chromium/base/CollectionUtil.java",
      "android/java/src/org/chromium/base/CommandLineInitUtil.java",
      "android/java/src/org/chromium/base/CpuFeatures.java",
      "android/java/src/org/chromium/base/DiscardableReferencePool.java",
      "android/java/src/org/chromium/base/EventLog.java",
      "android/java/src/org/chromium/base/FeatureList.java",
      "android/java/src/org/chromium/base/FeatureMap.java",
      "android/java/src/org/chromium/base/FeatureParam.java",
      "android/java/src/org/chromium/base/Features.java",
      "android/java/src/org/chromium/base/FieldTrialList.java",
      "android/java/src/org/chromium/base/FileProviderUtils.java",
      "android/java/src/org/chromium/base/FileUtils.java",
      "android/java/src/org/chromium/base/Flag.java",
      "android/java/src/org/chromium/base/ImportantFileWriterAndroid.java",
      "android/java/src/org/chromium/base/InputHintChecker.java",
      "android/java/src/org/chromium/base/IntStringCallback.java",
      "android/java/src/org/chromium/base/IntentUtils.java",
      "android/java/src/org/chromium/base/JNIUtils.java",
      "android/java/src/org/chromium/base/JavaExceptionReporter.java",
      "android/java/src/org/chromium/base/JavaHandlerThread.java",
      "android/java/src/org/chromium/base/JniAndroid.java",
      "android/java/src/org/chromium/base/LocaleUtils.java",
      "android/java/src/org/chromium/base/MathUtils.java",
      "android/java/src/org/chromium/base/MutableBooleanParamWithSafeDefault.java",
      "android/java/src/org/chromium/base/MutableFlagWithSafeDefault.java",
      "android/java/src/org/chromium/base/MutableIntParamWithSafeDefault.java",
      "android/java/src/org/chromium/base/MutableParamWithSafeDefault.java",
      "android/java/src/org/chromium/base/PackageManagerUtils.java",
      "android/java/src/org/chromium/base/PackageUtils.java",
      "android/java/src/org/chromium/base/PathService.java",
      "android/java/src/org/chromium/base/PathUtils.java",
      "android/java/src/org/chromium/base/PiiElider.java",
      "android/java/src/org/chromium/base/PowerMonitor.java",
      "android/java/src/org/chromium/base/PowerMonitorForQ.java",
      "android/java/src/org/chromium/base/RadioUtils.java",
      "android/java/src/org/chromium/base/RequiredCallback.java",
      "android/java/src/org/chromium/base/TimezoneUtils.java",
      "android/java/src/org/chromium/base/Token.java",
      "android/java/src/org/chromium/base/TokenBase.java",
      "android/java/src/org/chromium/base/UnguessableToken.java",
      "android/java/src/org/chromium/base/UserData.java",
      "android/java/src/org/chromium/base/UserDataHost.java",
      "android/java/src/org/chromium/base/ValueChangedCallback.java",
      "android/java/src/org/chromium/base/WrappedClassLoader.java",
    ]

    if (use_clang_profiling) {
      sources += [
        "test/android/javatests/src/org/chromium/base/test/ClangProfiler.java",
      ]
    } else {
      sources += [ "test/android/javatests/src/stub/org/chromium/base/test/ClangProfiler.java" ]
    }

    resources_package = "org.chromium.base"

    proguard_configs = [ "android/proguard/shared_with_cronet.flags" ]
    public_deps = [
      ":activity_state_java",
      ":base_switches_java",
      ":callback_java",
      ":command_line_java",
      ":jank_tracker_java",
      ":library_loader_java",
      ":lifetime_java",
      ":log_java",
      ":memory_java",
      ":metrics_java",
      ":promise_java",
      ":resetters_java",
      ":stream_util_java",
      ":supplier_java",
      ":sys_utils_java",
      ":tasks_java",
      ":time_utils_java",
      ":unowned_user_data_java",
    ]
    if (!is_cronet_build) {
      proguard_configs += [
        "android/proguard/chromium_apk.flags",
        "android/proguard/remove_logging.flags",
      ]
    }
  }

  generate_jni("metrics_jni") {
    sources = [
      "android/java/src/org/chromium/base/metrics/NativeUmaRecorder.java",
      "android/java/src/org/chromium/base/metrics/StatisticsRecorderAndroid.java",
    ]
  }

  java_cpp_enum("metrics_enum_srcjar") {
    sources = [ "metrics/histogram_base.h" ]
  }

  android_library("metrics_java") {
    srcjar_deps = [
      ":metrics_enum_srcjar",
      ":metrics_jni",
    ]
    sources = [
      "android/java/src/org/chromium/base/metrics/CachingUmaRecorder.java",
      "android/java/src/org/chromium/base/metrics/HistogramBucket.java",
      "android/java/src/org/chromium/base/metrics/NativeUmaRecorder.java",
      "android/java/src/org/chromium/base/metrics/NoopUmaRecorder.java",
      "android/java/src/org/chromium/base/metrics/RecordHistogram.java",
      "android/java/src/org/chromium/base/metrics/RecordUserAction.java",
      "android/java/src/org/chromium/base/metrics/ScopedSysTraceEvent.java",
      "android/java/src/org/chromium/base/metrics/StatisticsRecorderAndroid.java",
      "android/java/src/org/chromium/base/metrics/TimingMetric.java",
      "android/java/src/org/chromium/base/metrics/UmaRecorder.java",
      "android/java/src/org/chromium/base/metrics/UmaRecorderHolder.java",
    ]
    deps = [
      ":callback_java",
      ":log_java",
      ":time_utils_java",
      "//build/android:build_java",
      "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
      "//third_party/android_deps:com_google_errorprone_error_prone_annotations_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }

  generate_jni("jank_tracker_jni") {
    sources = [ "android/java/src/org/chromium/base/jank_tracker/JankMetricUMARecorder.java" ]
  }

  android_library("jank_tracker_java") {
    srcjar_deps = [ ":jank_tracker_jni" ]
    sources = [
      "android/java/src/org/chromium/base/jank_tracker/FrameMetricsListener.java",
      "android/java/src/org/chromium/base/jank_tracker/FrameMetricsStore.java",
      "android/java/src/org/chromium/base/jank_tracker/JankActivityTracker.java",
      "android/java/src/org/chromium/base/jank_tracker/JankEndScenarioTime.java",
      "android/java/src/org/chromium/base/jank_tracker/JankMetricUMARecorder.java",
      "android/java/src/org/chromium/base/jank_tracker/JankMetrics.java",
      "android/java/src/org/chromium/base/jank_tracker/JankReportingRunnable.java",
      "android/java/src/org/chromium/base/jank_tracker/JankReportingScheduler.java",
      "android/java/src/org/chromium/base/jank_tracker/JankScenario.java",
      "android/java/src/org/chromium/base/jank_tracker/JankTracker.java",
      "android/java/src/org/chromium/base/jank_tracker/JankTrackerImpl.java",
      "android/java/src/org/chromium/base/jank_tracker/JankTrackerStateController.java",
      "android/java/src/org/chromium/base/jank_tracker/PlaceholderJankTracker.java",
    ]
    deps = [
      ":activity_state_java",
      ":lifetime_java",
      ":log_java",
      ":tasks_java",
      ":time_utils_java",
      "//build/android:build_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }

  java_cpp_enum("memory_pressure_level_enum_srcjar") {
    sources = [ "memory/memory_pressure_listener.h" ]
  }

  generate_jni("memory_jni") {
    sources = [
      "android/java/src/org/chromium/base/MemoryPressureListener.java",
      "android/java/src/org/chromium/base/memory/JavaHeapDumpGenerator.java",
      "android/java/src/org/chromium/base/memory/MemoryInfoBridge.java",
      "android/java/src/org/chromium/base/memory/MemoryPurgeManager.java",
    ]
  }

  android_library("memory_java") {
    srcjar_deps = [
      ":memory_jni",
      ":memory_pressure_level_enum_srcjar",
    ]
    sources = [
      "android/java/src/org/chromium/base/MemoryPressureListener.java",
      "android/java/src/org/chromium/base/memory/JavaHeapDumpGenerator.java",
      "android/java/src/org/chromium/base/memory/MemoryInfoBridge.java",
      "android/java/src/org/chromium/base/memory/MemoryPressureCallback.java",
      "android/java/src/org/chromium/base/memory/MemoryPressureMonitor.java",
      "android/java/src/org/chromium/base/memory/MemoryPressureUma.java",
      "android/java/src/org/chromium/base/memory/MemoryPurgeManager.java",
    ]
    deps = [
      ":library_loader_java",
      ":log_java",
      ":metrics_java",
      ":resetters_java",
      ":supplier_java",
      ":tasks_java",
      ":time_utils_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }

  android_library("lifetime_java") {
    sources = [
      "android/java/src/org/chromium/base/LifetimeAssert.java",
      "android/java/src/org/chromium/base/lifetime/DestroyChecker.java",
      "android/java/src/org/chromium/base/lifetime/Destroyable.java",
    ]
    deps = [
      "//base:tasks_java",
      "//build/android:build_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
    ]
  }

  android_library("promise_java") {
    sources = [ "android/java/src/org/chromium/base/Promise.java" ]
    deps = [
      ":callback_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
    ]
  }

  android_library("unowned_user_data_java") {
    sources = [
      "android/java/src/org/chromium/base/UnownedUserData.java",
      "android/java/src/org/chromium/base/UnownedUserDataHost.java",
      "android/java/src/org/chromium/base/UnownedUserDataKey.java",
    ]
    deps = [
      ":lifetime_java",
      ":tasks_java",
      "//build/android:build_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
    ]
  }

  android_library("supplier_java") {
    sources = [
      "android/java/src/org/chromium/base/supplier/DestroyableObservableSupplier.java",
      "android/java/src/org/chromium/base/supplier/LazyOneshotSupplier.java",
      "android/java/src/org/chromium/base/supplier/LazyOneshotSupplierImpl.java",
      "android/java/src/org/chromium/base/supplier/ObservableSupplier.java",
      "android/java/src/org/chromium/base/supplier/ObservableSupplierImpl.java",
      "android/java/src/org/chromium/base/supplier/OneShotCallback.java",
      "android/java/src/org/chromium/base/supplier/OneshotSupplier.java",
      "android/java/src/org/chromium/base/supplier/OneshotSupplierImpl.java",
      "android/java/src/org/chromium/base/supplier/Supplier.java",
      "android/java/src/org/chromium/base/supplier/SupplierUtils.java",
      "android/java/src/org/chromium/base/supplier/SyncOneshotSupplier.java",
      "android/java/src/org/chromium/base/supplier/SyncOneshotSupplierImpl.java",
      "android/java/src/org/chromium/base/supplier/TransitiveObservableSupplier.java",
      "android/java/src/org/chromium/base/supplier/UnownedUserDataSupplier.java",
      "android/java/src/org/chromium/base/supplier/UnwrapObservableSupplier.java",
    ]
    deps = [
      ":callback_java",
      ":lifetime_java",
      ":promise_java",
      ":resetters_java",
      ":tasks_java",
      ":unowned_user_data_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
    ]
  }
  android_library("time_utils_java") {
    sources = [ "android/java/src/org/chromium/base/TimeUtils.java" ]
    deps = [ "//build/android:build_java" ]
  }

  generate_jni("callback_jni") {
    sources = [ "android/java/src/org/chromium/base/Callback.java" ]
  }

  android_library("callback_java") {
    sources = [ "android/java/src/org/chromium/base/Callback.java" ]
    deps = [
      "//build/android:build_java",
      "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
      "//third_party/android_deps:com_google_errorprone_error_prone_annotations_java",
      "//third_party/androidx:androidx_annotation_annotation_experimental_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }

  java_cpp_enum("library_loader_java_enums_srcjar") {
    sources = [ "android/library_loader/library_loader_hooks.h" ]
  }

  generate_jni("library_loader_jni") {
    sources = [
      "android/java/src/org/chromium/base/library_loader/LibraryLoader.java",
      "android/java/src/org/chromium/base/library_loader/LibraryPrefetcher.java",
    ]
  }

  generate_jni("tasks_jni") {
    sources = [
      "android/java/src/org/chromium/base/ApplicationStatus.java",
      "android/java/src/org/chromium/base/EarlyTraceEvent.java",
      "android/java/src/org/chromium/base/ThreadUtils.java",
      "android/java/src/org/chromium/base/TraceEvent.java",
      "android/java/src/org/chromium/base/task/PostTask.java",
      "android/java/src/org/chromium/base/task/TaskRunnerImpl.java",
    ]
  }

  java_cpp_enum("task_trait_enum_srcjar") {
    sources = [
      "android/task_scheduler/task_runner_android.h",
      "android/task_scheduler/task_traits_android.h",
    ]
  }

  android_library("tasks_java") {
    srcjar_deps = [
      ":task_trait_enum_srcjar",
      ":tasks_jni",
    ]
    sources = [
      # Dependencies added after this comment is tech-debt, should be untangled
      # and moved to their own separate android_library.
      "android/java/src/org/chromium/base/ApiCompatibilityUtils.java",
      "android/java/src/org/chromium/base/ApplicationStatus.java",
      "android/java/src/org/chromium/base/ContextUtils.java",
      "android/java/src/org/chromium/base/EarlyTraceEvent.java",
      "android/java/src/org/chromium/base/ObserverList.java",
      "android/java/src/org/chromium/base/StrictModeContext.java",
      "android/java/src/org/chromium/base/ThreadUtils.java",
      "android/java/src/org/chromium/base/TraceEvent.java",

      # End of cyclic dependencies.
      # The root of the problem stems from the fact that tasks/* depends
      # on source code outside of task which created a harsh cycle
      # dependency between AsyncTask -> TraceEvent -> ThreadUtil ->
      # PostTask -> AsyncTask. This should be solved by making everything inside
      # task/* self contained.
      "android/java/src/org/chromium/base/task/AsyncTask.java",
      "android/java/src/org/chromium/base/task/BackgroundOnlyAsyncTask.java",
      "android/java/src/org/chromium/base/task/ChainedTasks.java",
      "android/java/src/org/chromium/base/task/ChromeThreadPoolExecutor.java",
      "android/java/src/org/chromium/base/task/PostTask.java",
      "android/java/src/org/chromium/base/task/SequencedTaskRunner.java",
      "android/java/src/org/chromium/base/task/SequencedTaskRunnerImpl.java",
      "android/java/src/org/chromium/base/task/SerialExecutor.java",
      "android/java/src/org/chromium/base/task/TaskOriginException.java",
      "android/java/src/org/chromium/base/task/TaskRunner.java",
      "android/java/src/org/chromium/base/task/TaskRunnerImpl.java",
      "android/java/src/org/chromium/base/task/UiThreadTaskRunnerImpl.java",
    ]
    deps = [
      ":activity_state_java",
      ":base_switches_java",
      ":command_line_java",
      ":log_java",
      ":metrics_java",
      ":resetters_java",
      ":time_utils_java",
      "//build/android:build_java",
      "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }
  android_library("log_java") {
    sources = [
      "android/java/src/org/chromium/base/JavaUtils.java",
      "android/java/src/org/chromium/base/Log.java",
    ]
    deps = [ "//build/android:build_java" ]
  }

  generate_jni("command_line_jni") {
    sources = [ "android/java/src/org/chromium/base/CommandLine.java" ]
  }
  android_library("command_line_java") {
    srcjar_deps = [ ":command_line_jni" ]
    sources = [ "android/java/src/org/chromium/base/CommandLine.java" ]
    deps = [
      ":log_java",
      ":resetters_java",
      "//third_party/androidx:androidx_annotation_annotation_experimental_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }

  generate_jni("content_uri_utils_jni") {
    sources = [ "android/java/src/org/chromium/base/ContentUriUtils.java" ]
  }
  android_library("content_uri_utils_java") {
    srcjar_deps = [ ":content_uri_utils_jni" ]
    deps = [
      ":log_java",
      ":stream_util_java",
      ":tasks_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
    sources = [ "android/java/src/org/chromium/base/ContentUriUtils.java" ]
  }

  android_library("activity_state_java") {
    srcjar_deps = [ ":application_status_enum_srcjar" ]
    sources = [
      "android/java/src/org/chromium/base/ActivityLifecycleCallbacksAdapter.java",
      "android/java/src/org/chromium/base/ActivityState.java",
    ]
    deps = [ "//third_party/androidx:androidx_annotation_annotation_java" ]
  }

  java_cpp_enum("application_status_enum_srcjar") {
    sources = [ "android/application_status_listener.h" ]
  }

  android_library("service_loader_java") {
    deps = [
      ":resetters_java",
      "//build/android:build_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
    ]
    sources = [ "android/java/src/org/chromium/base/ServiceLoaderUtil.java" ]
  }

  android_library("resetters_java") {
    deps = [
      "//build/android:build_java",
      "//third_party/androidx:androidx_annotation_annotation_experimental_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
    ]
    sources = [ "android/java/src/org/chromium/base/ResettersForTesting.java" ]
  }

  generate_jni("sys_utils_jni") {
    sources = [ "android/java/src/org/chromium/base/SysUtils.java" ]
  }

  java_cpp_enum("sys_utils_enum_srcjar") {
    sources = [ "android/linker/linker_jni.h" ]
  }

  android_library("sys_utils_java") {
    srcjar_deps = [
      ":sys_utils_enum_srcjar",
      ":sys_utils_jni",
    ]
    sources = [ "android/java/src/org/chromium/base/SysUtils.java" ]
    deps = [
      ":tasks_java",
      "//build/android:build_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }

  android_library("stream_util_java") {
    sources = [ "android/java/src/org/chromium/base/StreamUtil.java" ]
  }

  android_library("library_loader_java") {
    srcjar_deps = [
      ":library_loader_java_enums_srcjar",
      ":library_loader_jni",
    ]
    sources = [
      "android/java/src/org/chromium/base/library_loader/LibraryLoader.java",
      "android/java/src/org/chromium/base/library_loader/LibraryPrefetcher.java",
      "android/java/src/org/chromium/base/library_loader/Linker.java",
      "android/java/src/org/chromium/base/library_loader/LinkerJni.java",
      "android/java/src/org/chromium/base/library_loader/LoaderErrors.java",
      "android/java/src/org/chromium/base/library_loader/NativeLibraryPreloader.java",
      "android/java/src/org/chromium/base/library_loader/ProcessInitException.java",
    ]

    deps = [
      ":base_switches_java",
      ":callback_java",
      ":command_line_java",
      ":log_java",
      ":metrics_java",
      ":resetters_java",
      ":stream_util_java",
      ":sys_utils_java",
      ":tasks_java",
      ":time_utils_java",
      "//build/android:build_java",
      "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
      "//third_party/android_deps:com_google_errorprone_error_prone_annotations_java",
      "//third_party/androidx:androidx_annotation_annotation_experimental_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }

  android_library("base_shared_preferences_java") {
    deps = [
      ":base_java",
      "//build/android:build_java",
      "//third_party/android_deps:guava_android_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]

    sources = [
      "android/java/src/org/chromium/base/shared_preferences/KeyPrefix.java",
      "android/java/src/org/chromium/base/shared_preferences/KnownPreferenceKeyRegistries.java",
      "android/java/src/org/chromium/base/shared_preferences/PreferenceKeyChecker.java",
      "android/java/src/org/chromium/base/shared_preferences/PreferenceKeyRegistry.java",
      "android/java/src/org/chromium/base/shared_preferences/SharedPreferencesManager.java",
      "android/java/src/org/chromium/base/shared_preferences/StrictPreferenceKeyChecker.java",
    ]
  }

  android_library("base_cached_flags_java") {
    deps = [
      ":base_java",
      ":base_shared_preferences_java",
      "//base/version_info/android:version_constants_java",
      "//build/android:build_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
    ]

    sources = [
      "android/java/src/org/chromium/base/cached_flags/AllCachedFieldTrialParameters.java",
      "android/java/src/org/chromium/base/cached_flags/BooleanCachedFieldTrialParameter.java",
      "android/java/src/org/chromium/base/cached_flags/CachedFieldTrialParameter.java",
      "android/java/src/org/chromium/base/cached_flags/CachedFlag.java",
      "android/java/src/org/chromium/base/cached_flags/CachedFlagUtils.java",
      "android/java/src/org/chromium/base/cached_flags/CachedFlagsSafeMode.java",
      "android/java/src/org/chromium/base/cached_flags/CachedFlagsSharedPreferences.java",
      "android/java/src/org/chromium/base/cached_flags/DoubleCachedFieldTrialParameter.java",
      "android/java/src/org/chromium/base/cached_flags/IntCachedFieldTrialParameter.java",
      "android/java/src/org/chromium/base/cached_flags/PostNativeFlag.java",
      "android/java/src/org/chromium/base/cached_flags/StringCachedFieldTrialParameter.java",
      "android/java/src/org/chromium/base/cached_flags/ValuesOverridden.java",
      "android/java/src/org/chromium/base/cached_flags/ValuesReturned.java",
    ]
  }

  android_aidl("process_launcher_aidl") {
    import_include = [ "android/java/src" ]
    sources = [
      "android/java/src/org/chromium/base/process_launcher/IChildProcessService.aidl",
      "android/java/src/org/chromium/base/process_launcher/IParentProcess.aidl",
    ]
  }

  android_library("base_javatests") {
    testonly = true

    deps = [
      ":base_java",
      ":base_java_test_support",
      ":base_java_test_support_uncommon",
      "//base/test:test_support_java",
      "//build/android:build_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/androidx:androidx_test_monitor_java",
      "//third_party/androidx:androidx_test_rules_java",
      "//third_party/androidx:androidx_test_runner_java",
      "//third_party/hamcrest:hamcrest_java",
      "//third_party/jni_zero:jni_zero_java",
      "//third_party/junit:junit",
      "//third_party/mockito:mockito_java",
    ]

    sources = [
      # AssertsTest doesn't really belong in //base but it's preferable to
      # stick it here than create another target for a single test.
      "android/javatests/src/org/chromium/base/AdvancedMockContextTest.java",
      "android/javatests/src/org/chromium/base/AssertsTest.java",
      "android/javatests/src/org/chromium/base/BinderCallsListenerTest.java",
      "android/javatests/src/org/chromium/base/CommandLineFlagsTest.java",
      "android/javatests/src/org/chromium/base/CommandLineTest.java",
      "android/javatests/src/org/chromium/base/EarlyTraceEventTest.java",
      "android/javatests/src/org/chromium/base/IntentUtilsTest.java",
      "android/javatests/src/org/chromium/base/LocaleUtilsTest.java",
      "android/javatests/src/org/chromium/base/ObserverListTest.java",
      "android/javatests/src/org/chromium/base/PackageUtilsTest.java",
      "android/javatests/src/org/chromium/base/StrictModeContextTest.java",
      "android/javatests/src/org/chromium/base/UserDataHostTest.java",
      "android/javatests/src/org/chromium/base/jank_tracker/JankTrackerTest.java",
      "android/javatests/src/org/chromium/base/library_loader/EarlyNativeTest.java",
      "android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java",
      "android/javatests/src/org/chromium/base/task/AsyncTaskTest.java",
      "android/javatests/src/org/chromium/base/task/ChainedTasksTest.java",
      "android/javatests/src/org/chromium/base/task/PostTaskTest.java",
      "android/javatests/src/org/chromium/base/task/SequencedTaskRunnerImplTest.java",
      "android/javatests/src/org/chromium/base/test/metrics/HistogramWatcherTestBase.java",
      "android/javatests/src/org/chromium/base/test/metrics/HistogramWatcherTransitionToNativeTest.java",
      "android/javatests/src/org/chromium/base/test/metrics/HistogramWatcherWithNativeTest.java",
      "android/javatests/src/org/chromium/base/test/metrics/HistogramWatcherWithoutNativeTest.java",
      "android/javatests/src/org/chromium/base/util/GarbageCollectionTestUtilsTest.java",
    ]
    srcjar_deps = [ ":base_javatests_jni" ]
  }

  source_set("base_javatests_lib") {
    testonly = true
    deps = [
      ":base",
      ":base_javatests_jni",
    ]
    sources = [ "test/library_loader/early_native_test_helper.cc" ]
  }

  generate_jni("base_javatests_jni") {
    testonly = true
    sources = [ "android/javatests/src/org/chromium/base/library_loader/EarlyNativeTest.java" ]
  }

  android_library("base_java_url_utils_for_test") {
    testonly = true
    sources = [
      "test/android/javatests/src/org/chromium/base/test/util/UrlUtils.java",
    ]

    deps = [
      ":base_java",
      "//build/android:build_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
      "//third_party/junit:junit",
    ]
  }

  android_library("base_java_test_support") {
    testonly = true

    deps = [
      ":base_cached_flags_java",
      ":base_java",
      "//build/android:build_java",
      "//testing/android/instrumentation:test_runner_java",
      "//third_party/accessibility_test_framework:accessibility_core_java",
      "//third_party/android_deps:com_google_code_findbugs_jsr305_java",
      "//third_party/android_deps:espresso_java",
      "//third_party/android_deps:guava_android_java",
      "//third_party/android_sdk:android_test_mock_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/androidx:androidx_core_core_java",
      "//third_party/androidx:androidx_multidex_multidex_java",
      "//third_party/androidx:androidx_test_monitor_java",
      "//third_party/androidx:androidx_test_runner_java",
      "//third_party/androidx:androidx_test_uiautomator_uiautomator_java",
      "//third_party/hamcrest:hamcrest_java",
      "//third_party/jni_zero:jni_zero_java",
      "//third_party/junit",
    ]

    public_deps = [
      ":base_java_url_utils_for_test",
      ":tasks_java",
    ]

    sources = [
      "test/android/java/src/org/chromium/base/multidex/ChromiumMultiDexInstaller.java",
      "test/android/javatests/src/org/chromium/base/test/ActivityFinisher.java",
      "test/android/javatests/src/org/chromium/base/test/BaseActivityTestRule.java",
      "test/android/javatests/src/org/chromium/base/test/BaseChromiumAndroidJUnitRunner.java",
      "test/android/javatests/src/org/chromium/base/test/BaseJUnit4ClassRunner.java",
      "test/android/javatests/src/org/chromium/base/test/LoadNative.java",
      "test/android/javatests/src/org/chromium/base/test/NativeCoverageInstrumentationRunListener.java",
      "test/android/javatests/src/org/chromium/base/test/ScreenshotOnFailureStatement.java",
      "test/android/javatests/src/org/chromium/base/test/SharedPreferencesTestUtil.java",
      "test/android/javatests/src/org/chromium/base/test/TestTraceEvent.java",
      "test/android/javatests/src/org/chromium/base/test/params/BaseJUnit4RunnerDelegate.java",
      "test/android/javatests/src/org/chromium/base/test/params/BlockJUnit4RunnerDelegate.java",
      "test/android/javatests/src/org/chromium/base/test/params/MethodParamAnnotationRule.java",
      "test/android/javatests/src/org/chromium/base/test/params/MethodParamRule.java",
      "test/android/javatests/src/org/chromium/base/test/params/ParameterAnnotations.java",
      "test/android/javatests/src/org/chromium/base/test/params/ParameterProvider.java",
      "test/android/javatests/src/org/chromium/base/test/params/ParameterSet.java",
      "test/android/javatests/src/org/chromium/base/test/params/ParameterizedCommandLineFlags.java",
      "test/android/javatests/src/org/chromium/base/test/params/ParameterizedFrameworkMethod.java",
      "test/android/javatests/src/org/chromium/base/test/params/ParameterizedRunner.java",
      "test/android/javatests/src/org/chromium/base/test/params/ParameterizedRunnerDelegate.java",
      "test/android/javatests/src/org/chromium/base/test/params/ParameterizedRunnerDelegateCommon.java",
      "test/android/javatests/src/org/chromium/base/test/params/ParameterizedRunnerDelegateFactory.java",
      "test/android/javatests/src/org/chromium/base/test/params/SkipCommandLineParameterization.java",
      "test/android/javatests/src/org/chromium/base/test/util/AdvancedMockContext.java",
      "test/android/javatests/src/org/chromium/base/test/util/AndroidSdkLevelSkipCheck.java",
      "test/android/javatests/src/org/chromium/base/test/util/AnnotationProcessingUtils.java",
      "test/android/javatests/src/org/chromium/base/test/util/AnnotationRule.java",
      "test/android/javatests/src/org/chromium/base/test/util/ApplicationContextWrapper.java",
      "test/android/javatests/src/org/chromium/base/test/util/ApplicationTestUtils.java",
      "test/android/javatests/src/org/chromium/base/test/util/BaseRestrictions.java",
      "test/android/javatests/src/org/chromium/base/test/util/Batch.java",
      "test/android/javatests/src/org/chromium/base/test/util/CallbackHelper.java",
      "test/android/javatests/src/org/chromium/base/test/util/CommandLineFlags.java",
      "test/android/javatests/src/org/chromium/base/test/util/Criteria.java",
      "test/android/javatests/src/org/chromium/base/test/util/CriteriaHelper.java",
      "test/android/javatests/src/org/chromium/base/test/util/CriteriaNotSatisfiedException.java",
      "test/android/javatests/src/org/chromium/base/test/util/DisableIf.java",
      "test/android/javatests/src/org/chromium/base/test/util/DisableIfSkipCheck.java",
      "test/android/javatests/src/org/chromium/base/test/util/DisabledTest.java",
      "test/android/javatests/src/org/chromium/base/test/util/DoNotBatch.java",
      "test/android/javatests/src/org/chromium/base/test/util/DoNotRevive.java",
      "test/android/javatests/src/org/chromium/base/test/util/DumpThreadsOnFailureRule.java",
      "test/android/javatests/src/org/chromium/base/test/util/EnormousTest.java",
      "test/android/javatests/src/org/chromium/base/test/util/Feature.java",
      "test/android/javatests/src/org/chromium/base/test/util/Features.java",
      "test/android/javatests/src/org/chromium/base/test/util/FieldTrials.java",
      "test/android/javatests/src/org/chromium/base/test/util/HistogramWatcher.java",
      "test/android/javatests/src/org/chromium/base/test/util/InMemorySharedPreferences.java",
      "test/android/javatests/src/org/chromium/base/test/util/InMemorySharedPreferencesContext.java",
      "test/android/javatests/src/org/chromium/base/test/util/IntegrationTest.java",
      "test/android/javatests/src/org/chromium/base/test/util/JniMocker.java",
      "test/android/javatests/src/org/chromium/base/test/util/LooperUtils.java",
      "test/android/javatests/src/org/chromium/base/test/util/Manual.java",
      "test/android/javatests/src/org/chromium/base/test/util/MaxAndroidSdkLevel.java",
      "test/android/javatests/src/org/chromium/base/test/util/MinAndroidSdkLevel.java",
      "test/android/javatests/src/org/chromium/base/test/util/PackageManagerWrapper.java",
      "test/android/javatests/src/org/chromium/base/test/util/PayloadCallbackHelper.java",
      "test/android/javatests/src/org/chromium/base/test/util/RawFailureHandler.java",
      "test/android/javatests/src/org/chromium/base/test/util/RequiresRestart.java",
      "test/android/javatests/src/org/chromium/base/test/util/Restriction.java",
      "test/android/javatests/src/org/chromium/base/test/util/RestrictionSkipCheck.java",
      "test/android/javatests/src/org/chromium/base/test/util/ScalableTimeout.java",
      "test/android/javatests/src/org/chromium/base/test/util/SkipCheck.java",
      "test/android/javatests/src/org/chromium/base/test/util/TestAnimations.java",
      "test/android/javatests/src/org/chromium/base/test/util/TestFileUtil.java",
      "test/android/javatests/src/org/chromium/base/test/util/TestThreadUtils.java",
      "test/android/javatests/src/org/chromium/base/test/util/TimeoutTimer.java",
      "test/android/javatests/src/org/chromium/base/test/util/UserActionTester.java",
      "test/android/javatests/src/org/chromium/base/test/util/ViewActionOnDescendant.java",
      "test/android/javatests/src/org/chromium/base/test/util/ViewPrinter.java",
    ]
    if (use_clang_coverage) {
      mergeable_android_manifests = [
        "test/android/javatests/AndroidManifest_NativeCoverageListener.xml",
      ]
    }
  }

  generate_jni("base_java_test_support_uncommon_jni") {
    testonly = true
    sources = [ "test/android/javatests/src/org/chromium/base/test/task/ThreadPoolTestHelpers.java" ]
  }

  android_library("base_java_test_support_uncommon") {
    testonly = true

    deps = [
      "//base:base_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/androidx:androidx_test_monitor_java",
      "//third_party/hamcrest:hamcrest_java",
      "//third_party/jni_zero:jni_zero_java",
      "//third_party/junit:junit",
    ]

    srcjar_deps = [ ":base_java_test_support_uncommon_jni" ]
    sources = [
      "test/android/javatests/src/org/chromium/base/FakeTimeTestRule.java",
      "test/android/javatests/src/org/chromium/base/test/BundleTestRule.java",
      "test/android/javatests/src/org/chromium/base/test/SetUpStatement.java",
      "test/android/javatests/src/org/chromium/base/test/SetUpTestRule.java",
      "test/android/javatests/src/org/chromium/base/test/task/SchedulerTestHelpers.java",
      "test/android/javatests/src/org/chromium/base/test/task/ThreadPoolTestHelpers.java",
      "test/android/javatests/src/org/chromium/base/test/util/CloseableOnMainThread.java",
      "test/android/javatests/src/org/chromium/base/test/util/InstrumentationUtils.java",
      "test/android/javatests/src/org/chromium/base/test/util/Matchers.java",
    ]
  }

  android_library("base_java_process_launcher_test_support") {
    testonly = true

    public_deps = [ ":process_launcher_java" ]

    sources = [ "test/android/javatests/src/org/chromium/base/process_launcher/TestChildProcessConnection.java" ]
  }

  robolectric_library("base_junit_test_support") {
    sources = [
      "//third_party/robolectric/custom_asynctask/java/src/org/chromium/base/task/test/ShadowAsyncTask.java",
      "//third_party/robolectric/custom_asynctask/java/src/org/chromium/base/task/test/ShadowAsyncTaskBridge.java",
      "test/android/junit/src/org/chromium/base/task/test/BackgroundShadowAsyncTask.java",
      "test/android/junit/src/org/chromium/base/task/test/CustomShadowAsyncTask.java",
      "test/android/junit/src/org/chromium/base/task/test/PausedExecutorTestRule.java",
      "test/android/junit/src/org/chromium/base/task/test/ShadowPostTask.java",
      "test/android/junit/src/org/chromium/base/test/BaseRobolectricAndroidConfigurer.java",
      "test/android/junit/src/org/chromium/base/test/BaseRobolectricTestListener.java",
      "test/android/junit/src/org/chromium/base/test/BaseRobolectricTestRule.java",
      "test/android/junit/src/org/chromium/base/test/BaseRobolectricTestRunner.java",
      "test/android/junit/src/org/chromium/base/test/ShadowBuildInfo.java",
      "test/android/junit/src/org/chromium/base/test/util/BaseFlagTestRule.java",
      "test/android/junit/src/org/chromium/base/test/util/TestRunnerTestRule.java",
    ]

    # Make sure robolectric tests have classes filtered out of base_java by
    # jar_excluded_patterns.
    srcjar_deps = [ "//build/android:native_libraries_gen" ]

    annotation_processor_deps =
        [ "//third_party/android_deps:auto_service_processor" ]
    deps = [
      ":base_java",
      ":base_java_test_support",
      "//base:base_cached_flags_java",
      "//testing/android/junit:junit_test_support",
      "//third_party/android_deps:com_google_auto_service_auto_service_annotations_java",
      "//third_party/androidx:androidx_test_core_java",
      "//third_party/androidx:androidx_test_monitor_java",
      "//third_party/hamcrest:hamcrest_java",
      "//third_party/junit:junit",
    ]
  }

  robolectric_binary("base_junit_tests") {
    shared_libraries = [ ":libbase_junit_tests($robolectric_toolchain)" ]
    sources = [
      "android/junit/src/org/chromium/base/ApplicationStatusTest.java",
      "android/junit/src/org/chromium/base/BuildInfoTest.java",
      "android/junit/src/org/chromium/base/CallbackControllerTest.java",
      "android/junit/src/org/chromium/base/CollectionUtilTest.java",
      "android/junit/src/org/chromium/base/CommandLineTest.java",
      "android/junit/src/org/chromium/base/DiscardableReferencePoolTest.java",
      "android/junit/src/org/chromium/base/FeatureListUnitTest.java",
      "android/junit/src/org/chromium/base/FileUtilsTest.java",
      "android/junit/src/org/chromium/base/FlagUnitTest.java",
      "android/junit/src/org/chromium/base/LifetimeAssertTest.java",
      "android/junit/src/org/chromium/base/LogTest.java",
      "android/junit/src/org/chromium/base/MathUtilsTest.java",
      "android/junit/src/org/chromium/base/MutableBooleanParamWithSafeDefaultUnitTest.java",
      "android/junit/src/org/chromium/base/MutableFlagWithSafeDefaultUnitTest.java",
      "android/junit/src/org/chromium/base/MutableIntParamWithSafeDefaultUnitTest.java",
      "android/junit/src/org/chromium/base/PathUtilsTest.java",
      "android/junit/src/org/chromium/base/PiiEliderTest.java",
      "android/junit/src/org/chromium/base/PostNativeFlagUnitTest.java",
      "android/junit/src/org/chromium/base/PromiseTest.java",
      "android/junit/src/org/chromium/base/ResettersForTestingTest.java",
      "android/junit/src/org/chromium/base/ThreadUtilsTest.java",
      "android/junit/src/org/chromium/base/TimeUtilsTest.java",
      "android/junit/src/org/chromium/base/TokenUnitTest.java",
      "android/junit/src/org/chromium/base/TraceEventTest.java",
      "android/junit/src/org/chromium/base/UnownedUserDataHostTest.java",
      "android/junit/src/org/chromium/base/UnownedUserDataKeyTest.java",
      "android/junit/src/org/chromium/base/ValueChangedCallbackTest.java",
      "android/junit/src/org/chromium/base/cached_flags/CachedFeatureFlagsSafeModeUnitTest.java",
      "android/junit/src/org/chromium/base/cached_flags/CachedFieldTrialParameterUnitTest.java",
      "android/junit/src/org/chromium/base/cached_flags/CachedFlagUnitTest.java",
      "android/junit/src/org/chromium/base/jank_tracker/FrameMetricsListenerTest.java",
      "android/junit/src/org/chromium/base/jank_tracker/FrameMetricsStoreTest.java",
      "android/junit/src/org/chromium/base/jank_tracker/JankActivityTrackerTest.java",
      "android/junit/src/org/chromium/base/jank_tracker/JankMetricUMARecorderTest.java",
      "android/junit/src/org/chromium/base/jank_tracker/JankReportingRunnableTest.java",
      "android/junit/src/org/chromium/base/jank_tracker/JankReportingSchedulerTest.java",
      "android/junit/src/org/chromium/base/library_loader/LinkerTest.java",
      "android/junit/src/org/chromium/base/memory/MemoryPressureMonitorTest.java",
      "android/junit/src/org/chromium/base/memory/MemoryPurgeManagerTest.java",
      "android/junit/src/org/chromium/base/metrics/CachingUmaRecorderTest.java",
      "android/junit/src/org/chromium/base/process_launcher/ChildConnectionAllocatorTest.java",
      "android/junit/src/org/chromium/base/process_launcher/ChildProcessConnectionTest.java",
      "android/junit/src/org/chromium/base/shared_preferences/KeyPrefixTest.java",
      "android/junit/src/org/chromium/base/shared_preferences/KnownPreferenceKeyRegistriesTest.java",
      "android/junit/src/org/chromium/base/shared_preferences/SharedPreferencesManagerTest.java",
      "android/junit/src/org/chromium/base/shared_preferences/StrictPreferenceKeyCheckerTest.java",
      "android/junit/src/org/chromium/base/supplier/LazyOneshotSupplierImplTest.java",
      "android/junit/src/org/chromium/base/supplier/LazyOneshotSupplierTest.java",
      "android/junit/src/org/chromium/base/supplier/ObservableSupplierImplTest.java",
      "android/junit/src/org/chromium/base/supplier/OneShotCallbackTest.java",
      "android/junit/src/org/chromium/base/supplier/OneshotSupplierImplTest.java",
      "android/junit/src/org/chromium/base/supplier/SupplierUtilsTest.java",
      "android/junit/src/org/chromium/base/supplier/SyncOneshotSupplierImplTest.java",
      "android/junit/src/org/chromium/base/supplier/TransitiveObservableSupplierTest.java",
      "android/junit/src/org/chromium/base/supplier/UnownedUserDataSupplierTest.java",
      "android/junit/src/org/chromium/base/supplier/UnwrapObservableSupplierTest.java",
      "android/junit/src/org/chromium/base/task/AsyncTaskThreadTest.java",
      "android/junit/src/org/chromium/base/task/SequencedTaskRunnerTaskMigrationTest.java",
      "android/junit/src/org/chromium/base/util/GarbageCollectionTestUtilsUnitTest.java",
      "test/android/junit/src/org/chromium/base/test/SetUpStatementTest.java",
      "test/android/junit/src/org/chromium/base/test/TestListInstrumentationRunListenerTest.java",
      "test/android/junit/src/org/chromium/base/test/params/ExampleParameterizedTest.java",
      "test/android/junit/src/org/chromium/base/test/params/ParameterizedRunnerDelegateCommonTest.java",
      "test/android/junit/src/org/chromium/base/test/params/ParameterizedRunnerDelegateFactoryTest.java",
      "test/android/junit/src/org/chromium/base/test/params/ParameterizedRunnerTest.java",
      "test/android/junit/src/org/chromium/base/test/params/ParameterizedTestNameTest.java",
      "test/android/junit/src/org/chromium/base/test/util/AndroidSdkLevelSkipCheckTest.java",
      "test/android/junit/src/org/chromium/base/test/util/AnnotationProcessingUtilsTest.java",
      "test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsNoClassAnnotationCheckTest.java",
      "test/android/junit/src/org/chromium/base/test/util/CommandLineFlagsWithClassAnnotationCheckTest.java",
      "test/android/junit/src/org/chromium/base/test/util/DisableIfTest.java",
      "test/android/junit/src/org/chromium/base/test/util/DisabledTestForClassRobolectricTest.java",
      "test/android/junit/src/org/chromium/base/test/util/DisabledTestRobolectricTest.java",
      "test/android/junit/src/org/chromium/base/test/util/RestrictionSkipCheckTest.java",
      "test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java",
    ]
    deps = [
      ":base_cached_flags_java",
      ":base_java",
      ":base_java_process_launcher_test_support",
      ":base_java_test_support",
      ":base_java_test_support_uncommon",
      ":base_junit_test_support",
      ":base_shared_preferences_java",
      "//base/test:public_transit_robolectric_tests_java",
      "//base/test:test_support_java",
      "//testing/android/instrumentation:test_runner_java",
      "//third_party/android_deps:guava_android_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/androidx:androidx_test_core_java",
      "//third_party/androidx:androidx_test_runner_java",
      "//third_party/hamcrest:hamcrest_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }

  java_cpp_enum("base_android_java_enums_srcjar") {
    sources = [
      "android/child_process_binding_types.h",
      "power_monitor/power_observer.h",
      "process/kill.h",
      "task/task_traits.h",
    ]
    if (enable_base_tracing) {
      sources += [ "trace_event/trace_config.h" ]
    }
  }

  generate_jni("base_profiler_test_support_jni") {
    testonly = true
    sources =
        [ "android/javatests/src/org/chromium/base/profiler/TestSupport.java" ]
  }

  android_library("base_profiler_test_support_java") {
    testonly = true
    sources =
        [ "android/javatests/src/org/chromium/base/profiler/TestSupport.java" ]
    srcjar_deps = [ ":base_profiler_test_support_jni" ]

    deps = [
      "//build/android:build_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }

  generate_jni("base_unittest_support_jni") {
    testonly = true
    sources =
        [ "test/android/java/src/org/chromium/base/JniAndroidTestUtils.java" ]
  }

  # Used by gtests and not by robolectric / instrumentation tests.
  android_library("base_unittest_support_java") {
    testonly = true

    deps = [
      ":base_java",
      ":content_uri_utils_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
    srcjar_deps = [ ":base_unittest_support_jni" ]

    sources = [
      "test/android/java/src/org/chromium/base/ContentUriTestUtils.java",
      "test/android/java/src/org/chromium/base/JavaHandlerThreadHelpers.java",
      "test/android/java/src/org/chromium/base/JniAndroidTestUtils.java",
    ]
  }
}  # is_android

# Keep the list of fuzzer_tests in alphabetical order.
fuzzer_test("base64_decode_fuzzer") {
  sources = [ "base64_decode_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("base64_encode_fuzzer") {
  sources = [ "base64_encode_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("base64url_fuzzer") {
  sources = [ "base64url_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("base_json_correctness_fuzzer") {
  sources = [ "json/json_correctness_fuzzer.cc" ]
  deps = [ ":base" ]
  dict = "//testing/libfuzzer/fuzzers/dicts/json.dict"
}

fuzzer_test("base_json_reader_fuzzer") {
  sources = [ "json/json_reader_fuzzer.cc" ]
  deps = [ "//base" ]
  dict = "//testing/libfuzzer/fuzzers/dicts/json.dict"
}

fuzzer_test("base_json_string_escape_fuzzer") {
  sources = [ "json/string_escape_fuzzer.cc" ]
  deps = [ "//base" ]
}

if (is_mac) {
  protoc_convert("base_mach_port_rendezvous_convert_corpus") {
    sources = [
      "test/data/mach_port_rendezvous_fuzz/dead_name.textproto",
      "test/data/mach_port_rendezvous_fuzz/send.textproto",
    ]
    inputs = [ "//testing/libfuzzer/fuzzers/mach/mach_message.proto" ]
    output_pattern = "$target_gen_dir/base_mach_port_rendezvous_corpus/{{source_name_part}}.binarypb"
    args = [
      "--encode=mach_fuzzer.MachMessage",
      "-I",
      rebase_path("//"),
      rebase_path(inputs[0]),
    ]
  }
  fuzzer_test("base_mach_port_rendezvous_fuzzer") {
    sources = [ "mac/mach_port_rendezvous_fuzzer.cc" ]
    deps = [
      "//base",
      "//testing/libfuzzer/fuzzers/mach:converter",
      "//third_party/libprotobuf-mutator",
    ]
    seed_corpus = "$target_gen_dir/base_mach_port_rendezvous_corpus"
    seed_corpus_deps = [ ":base_mach_port_rendezvous_convert_corpus" ]
  }
}

fuzzer_test("command_line_fuzzer") {
  sources = [ "command_line_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("escape_fuzzer") {
  sources = [ "strings/escape_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("file_path_fuzzer") {
  sources = [ "files/file_path_fuzzer.cc" ]
  deps = [ "//base" ]
}

if (is_linux || is_chromeos) {
  fuzzer_test("mime_util_xdg_fuzzer") {
    sources = [ "nix/mime_util_xdg_fuzzer.cc" ]
    deps = [ "//base" ]
  }
}

fuzzer_test("base_persistent_histogram_allocator_fuzzer") {
  sources = [ "metrics/persistent_histogram_allocator_fuzzer.cc" ]
  deps = [ "//base" ]
  seed_corpus = "//base/test/data/pma_corpus"
}

fuzzer_test("string_number_conversions_fuzzer") {
  sources = [ "strings/string_number_conversions_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("string_pattern_fuzzer") {
  sources = [ "strings/pattern_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("string_tokenizer_fuzzer") {
  sources = [ "strings/string_tokenizer_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("substring_set_matcher_fuzzer") {
  sources = [ "substring_set_matcher/substring_set_matcher_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("sys_string_conversions_fuzzer") {
  sources = [ "strings/sys_string_conversions_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("time_delta_from_string_fuzzer") {
  sources = [ "time/time_delta_from_string_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("time_fuzzer") {
  sources = [ "time/time_fuzzer.cc" ]
  deps = [
    "//base",
    "//base/test:test_support",
  ]
}

fuzzer_test("utf_string_conversions_fuzzer") {
  sources = [ "strings/utf_string_conversions_fuzzer.cc" ]
  deps = [ "//base" ]
}

fuzzer_test("pickle_fuzzer") {
  sources = [ "pickle_fuzzer.cc" ]
  deps = [
    "//base",
    "//base/test:test_support",
  ]
}

if (enable_base_tracing) {
  # This group makes visible those targets in subdirectories that are not
  # explicitly depended on.
  group("gn_all") {
    testonly = true
    deps = [ "//base/tracing:perfetto_diff_tests" ]
  }
}

process_version("check_version_internal") {
  template_file = "//base/check_version_internal.h.in"
  output = "$target_gen_dir/check_version_internal.h"

  # TODO(pbos): Consider moving chrome/VERSION into base/VERSION now that base
  # depends on it. This dependency currently breaks webrtc which pulls in //base
  # (but not //chrome). crbug.com/webrtc/13662 tracks removing webrtc's
  # dependency on //base. For now we fake the check version far into the future.
  # This breaks check_unittest.cc when built outside of chromium, but webrtc
  # doesn't need to build base_unittests. If this is required in the future, but
  # we haven't moved chrome/VERSION, we should ifdef out those tests.
  if (build_with_chromium) {
    sources = [ "//chrome/VERSION" ]
    extra_args = [
      "-e",
      "VERSION_MAJOR=\"%s\" % (MAJOR)",
      "-e",
      "NEXT_VERSION_MAJOR=\"%d\" % (int(MAJOR) + 1)",
    ]
  } else {
    extra_args = [
      "-e",
      "VERSION_MAJOR=\"9998\"",
      "-e",
      "NEXT_VERSION_MAJOR=\"9999\"",
    ]
  }
}