#
#  Copyright (C) 2015 Google, Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at:
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

source_set("base_sources") {
  sources = [
    "base/at_exit.cc",
    "base/atomic_ref_count.h",
    "base/atomic_sequence_num.h",
    "base/atomicops.h",
    "base/base64.cc",
    "base/base64.h",
    "base/base_export.h",
    "base/base_switches.cc",
    "base/bind_helpers.cc",
    "base/build_time.cc",
    "base/callback_helpers.cc",
    "base/callback_internal.cc",
    "base/command_line.cc",
    "base/cpu.cc",
    "base/debug/alias.cc",
    "base/debug/debugger.cc",
    "base/debug/debugger_posix.cc",
    "base/debug/stack_trace.cc",
    "base/debug/stack_trace_posix.cc",
    "base/debug/task_annotator.cc",
    "base/environment.cc",
    "base/files/file.cc",
    "base/files/file_enumerator.cc",
    "base/files/file_enumerator_posix.cc",
    "base/files/file_path.cc",
    "base/files/file_path_constants.cc",
    "base/files/file_path_watcher.cc",
    "base/files/file_path_watcher_linux.cc",
    "base/files/file_posix.cc",
    "base/files/file_tracing.cc",
    "base/files/file_util.cc",
    "base/files/file_util_linux.cc",
    "base/files/file_util_posix.cc",
    "base/files/important_file_writer.cc",
    "base/files/scoped_file.cc",
    "base/files/scoped_temp_dir.cc",
    "base/guid.cc",
    "base/guid_posix.cc",
    "base/json/json_parser.cc",
    "base/json/json_reader.cc",
    "base/json/json_string_value_serializer.cc",
    "base/json/json_writer.cc",
    "base/json/string_escape.cc",
    "base/lazy_instance.cc",
    "base/location.cc",
    "base/logging.cc",
    "base/md5.cc",
    "base/memory/ref_counted.cc",
    "base/memory/ref_counted_memory.cc",
    "base/memory/singleton.cc",
    "base/memory/weak_ptr.cc",
    "base/message_loop/incoming_task_queue.cc",
    "base/message_loop/message_loop.cc",
    "base/message_loop/message_loop_task_runner.cc",
    "base/message_loop/message_pump.cc",
    "base/message_loop/message_pump_default.cc",

    # we don't want any glib dependencies.
    #   "base/message_loop/message_pump_glib.cc",
    "base/message_loop/message_pump_libevent.cc",
    "base/metrics/bucket_ranges.cc",
    "base/metrics/field_trial.cc",
    "base/metrics/metrics_hashes.cc",
    "base/metrics/histogram_base.cc",
    "base/metrics/histogram.cc",
    "base/metrics/histogram_samples.cc",
    "base/metrics/histogram_snapshot_manager.cc",
    "base/metrics/sample_map.cc",
    "base/metrics/sample_vector.cc",
    "base/metrics/sparse_histogram.cc",
    "base/metrics/statistics_recorder.cc",
    "base/pending_task.cc",
    "base/pickle.cc",
    "base/posix/file_descriptor_shuffle.cc",
    "base/posix/safe_strerror.cc",
    "base/posix/unix_domain_socket_linux.cc",
    "base/process/internal_linux.cc",
    "base/process/kill.cc",
    "base/process/kill_posix.cc",
    "base/process/launch.cc",
    "base/process/launch_posix.cc",
    "base/process/process_handle_linux.cc",
    "base/process/process_handle_posix.cc",
    "base/process/process_iterator.cc",
    "base/process/process_iterator_linux.cc",
    "base/process/process_metrics.cc",
    "base/process/process_metrics_linux.cc",
    "base/process/process_metrics_posix.cc",
    "base/process/process_posix.cc",
    "base/profiler/alternate_timer.cc",
    "base/profiler/scoped_profile.cc",
    "base/profiler/scoped_tracker.cc",
    "base/profiler/tracked_time.cc",
    "base/rand_util.cc",
    "base/rand_util_posix.cc",
    "base/run_loop.cc",
    "base/sequence_checker_impl.cc",
    "base/sequenced_task_runner.cc",
    "base/sha1_portable.cc",
    "base/strings/pattern.cc",
    "base/strings/safe_sprintf.cc",
    "base/strings/string16.cc",
    "base/strings/string_number_conversions.cc",
    "base/strings/string_piece.cc",
    "base/strings/stringprintf.cc",
    "base/strings/string_split.cc",
    "base/strings/string_util.cc",
    "base/strings/string_util_constants.cc",
    "base/strings/sys_string_conversions_posix.cc",
    "base/strings/utf_string_conversions.cc",
    "base/strings/utf_string_conversion_utils.cc",
    "base/synchronization/cancellation_flag.cc",
    "base/synchronization/condition_variable_posix.cc",
    "base/synchronization/lock.cc",
    "base/synchronization/lock_impl_posix.cc",
    "base/synchronization/waitable_event_posix.cc",
    "base/sync_socket_posix.cc",
    "base/sys_info.cc",

    # TODO(armansito): For our GN builds these platform-specific implementations
    # don't really make that much sense but instead of removing the line I'm
    # commenting it out in case we want to re-add it later (it's included in the
    # libchrome Android.mk).
    #"sys_info_chromeos.cc",
    "base/sys_info_linux.cc",
    "base/sys_info_posix.cc",
    "base/task/cancelable_task_tracker.cc",
    "base/task_runner.cc",
    "base/third_party/icu/icu_utf.cc",
    "base/third_party/nspr/prtime.cc",
    "base/threading/non_thread_safe_impl.cc",
    "base/threading/platform_thread_internal_posix.cc",
    "base/threading/platform_thread_linux.cc",
    "base/threading/platform_thread_posix.cc",
    "base/threading/post_task_and_reply_impl.cc",
    "base/threading/sequenced_worker_pool.cc",
    "base/threading/simple_thread.cc",
    "base/threading/thread.cc",
    "base/threading/thread_checker_impl.cc",
    "base/threading/thread_collision_warner.cc",
    "base/threading/thread_id_name_manager.cc",
    "base/threading/thread_local_posix.cc",
    "base/threading/thread_local_storage.cc",
    "base/threading/thread_local_storage_posix.cc",
    "base/threading/thread_restrictions.cc",
    "base/threading/worker_pool.cc",
    "base/threading/worker_pool_posix.cc",
    "base/thread_task_runner_handle.cc",
    "base/time/clock.cc",
    "base/time/default_clock.cc",
    "base/time/default_tick_clock.cc",
    "base/timer/elapsed_timer.cc",
    "base/timer/timer.cc",
    "base/time/tick_clock.cc",
    "base/time/time.cc",
    "base/time/time_posix.cc",
    "base/trace_event/heap_profiler_allocation_context.cc",
    "base/trace_event/heap_profiler_allocation_context_tracker.cc",
    "base/trace_event/heap_profiler_stack_frame_deduplicator.cc",
    "base/trace_event/heap_profiler_type_name_deduplicator.cc",
    "base/trace_event/malloc_dump_provider.cc",
    "base/trace_event/memory_allocator_dump.cc",
    "base/trace_event/memory_allocator_dump_guid.cc",
    "base/trace_event/memory_dump_manager.cc",
    "base/trace_event/memory_dump_session_state.cc",
    "base/trace_event/process_memory_dump.cc",
    "base/trace_event/process_memory_maps.cc",
    "base/trace_event/process_memory_maps_dump_provider.cc",
    "base/trace_event/process_memory_totals.cc",
    "base/trace_event/process_memory_totals_dump_provider.cc",
    "base/trace_event/trace_buffer.cc",
    "base/trace_event/trace_config.cc",
    "base/trace_event/trace_event_argument.cc",
    "base/trace_event/trace_event_impl.cc",
    "base/trace_event/trace_event_memory_overhead.cc",
    "base/trace_event/trace_event_synthetic_delay.cc",
    "base/trace_event/trace_log.cc",
    "base/trace_event/trace_log_constants.cc",
    "base/trace_event/trace_sampling_thread.cc",
    "base/tracked_objects.cc",
    "base/tracking_info.cc",
    "base/values.cc",
    "base/vlog.cc",
  ]

  defines = [
    "BASE_IMPLEMENTATION",

    # trick libchrome to think we're building host code within an Android checkout
    # thanks to it no glib dependency
    "__ANDROID_HOST__=1",
    "OS_LINUX=1",
  ]

  include_dirs = [
    "//",
    "//third_party/googletest/googletest/include",
    "//third_party/libchrome",
    "//third_party/libevent",
    "//third_party/libevent/include",
    "//third_party/libchrome/base",
    "//third_party/modp_b64",
  ]
}

config("libchrome_config") {
  # libchrome headers need to be able to find themselves.
  include_dirs = [
    "//third_party/googletest/googletest/include",
    "//third_party/libchrome",
 ]
}

static_library("base") {
  deps = [
    ":base_sources",
  ]

  cflags = [
    "-Wno-char-subscripts",
    "-Wno-missing-field-initializers",
    "-Wno-unused-function",
    "-Wno-unused_parameter",
  ]
  cflags_cc = [
    "-Wno-deprecated-register",
    "-Wno-non-virtual-dtor",
    "-Wno-sign-promo",
  ]

  libs = [
    "-levent",
    "-levent_core",
    "-lpthread",
  ]

  public_configs = [ ":libchrome_config" ]
}
