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

import("//chrome/process_version_rc_template.gni")
import("//testing/test.gni")

source_set("client") {
  sources = [
    "chrome_watcher_main_api.cc",
    "chrome_watcher_main_api.h",
  ]
  deps = [
    "//base",
  ]
}

source_set("hang_util") {
  sources = [
    "system_load_estimator.cc",
    "system_load_estimator.h",
  ]
  deps = [
    "//base",
    "//components/memory_pressure",
  ]
  libs = [ "pdh.lib" ]  # Used by system_load_estimator.h.
  ldflags = [ "/DELAYLOAD:pdh.dll" ]  # Only used on report capture.
}

test("system_load_estimator_unittests") {
  sources = [
    "system_load_estimator_unittest.cc",
  ]
  deps = [
    ":client",
    ":hang_util",
    "//base/test:run_all_unittests",
    "//base/test:test_support",
    "//testing/gtest",
  ]
}

group("kasko_util") {
  public_deps = [
    "//third_party/kasko:kasko_features",
  ]
}

process_version_rc_template("chrome_watcher_resources") {
  sources = [
    "chrome_watcher.ver",
  ]
  output = "$target_gen_dir/chrome_watcher_version.rc"
}

shared_library("chrome_watcher") {
  sources = [
    "chrome_watcher_main.cc",
  ]
  inputs = [
    "chrome_watcher.def",
  ]
  deps = [
    ":chrome_watcher_resources",
    ":client",
    ":kasko_util",
    "//base",
    "//base:base_static",
    "//build/config/sanitizers:deps",
    "//chrome/common:metrics_constants_util_win",
    "//chrome/install_static:secondary_module",
    "//chrome_elf",
    "//components/browser_watcher",
  ]
  ldflags = [ "/DEF:" + rebase_path("chrome_watcher.def", root_build_dir) ]
  configs -= [ "//build/config/win:console" ]
  configs += [ "//build/config/win:windowed" ]
}
