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

import("//build/config/clang/clang.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/win/manifest.gni")

# Depending on this target will cause the manifests for Chrome's default
# Windows and common control compatibility and elevation for executables.
windows_manifest("default_exe_manifest") {
  sources = [
    as_invoker_manifest,
    common_controls_manifest,
    default_compatibility_manifest,
  ]
}

if (is_win) {
  assert(host_os != "mac" || target_cpu != "x86",
         "Windows cross-builds from Mac must be 64-bit.")

  action("copy_cdb_to_output") {
    script = "//build/win/copy_cdb_to_output.py"
    inputs = [
      script,
      "//build/vs_toolchain.py",
    ]
    outputs = [
      "$root_out_dir/cdb/cdb.exe",
      "$root_out_dir/cdb/dbgeng.dll",
      "$root_out_dir/cdb/dbghelp.dll",
      "$root_out_dir/cdb/dbgmodel.dll",
      "$root_out_dir/cdb/winext/ext.dll",
      "$root_out_dir/cdb/winext/uext.dll",
      "$root_out_dir/cdb/winxp/exts.dll",
      "$root_out_dir/cdb/winxp/ntsdexts.dll",
    ]
    args = [
      rebase_path("$root_out_dir/cdb", root_out_dir),
      current_cpu,
    ]
  }

  group("runtime_libs") {
    # These are needed for any tests that need to decode stacks.
    data = [
      "$root_out_dir/dbghelp.dll",
      "$root_out_dir/dbgcore.dll",
    ]
    if (is_component_build || is_asan) {
      # Copy the VS runtime DLLs into the isolate so that they don't have to be
      # preinstalled on the target machine. The debug runtimes have a "d" at
      # the end.
      if (is_debug) {
        vcrt_suffix = "d"
      } else {
        vcrt_suffix = ""
      }

      # These runtime files are copied to the output directory by the
      # vs_toolchain script that runs as part of toolchain configuration.
      data += [
        "$root_out_dir/msvcp140${vcrt_suffix}.dll",
        "$root_out_dir/vccorlib140${vcrt_suffix}.dll",
        "$root_out_dir/vcruntime140${vcrt_suffix}.dll",
      ]
      if (current_cpu == "x64") {
        data += [ "$root_out_dir/vcruntime140_1${vcrt_suffix}.dll" ]
      }
      if (is_debug) {
        data += [ "$root_out_dir/ucrtbased.dll" ]
      }
      if (is_asan) {
        assert(target_cpu == "x64",
               "ASan is only supported in 64-bit builds on Windows.")
        data += [ "$clang_base_path/lib/clang/$clang_version/lib/windows/clang_rt.asan_dynamic-x86_64.dll" ]
      }
    }
  }
}
