11cb0ef41Sopenharmony_ci#!/usr/bin/env python
21cb0ef41Sopenharmony_ci# Copyright 2020 the V8 project authors. All rights reserved.
31cb0ef41Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be
41cb0ef41Sopenharmony_ci# found in the LICENSE file.
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci"""This program copies dbgeng.dll from the Windows SDK to the output directory,
71cb0ef41Sopenharmony_ciso that we can test v8windbg. (The version of dbgeng.dll in system32, which
81cb0ef41Sopenharmony_ciwould be loaded otherwise, is insufficient.)
91cb0ef41Sopenharmony_ciArguments:
101cb0ef41Sopenharmony_ci1. The directory that contains vs_toolchain.py
111cb0ef41Sopenharmony_ci2. The directory to copy to
121cb0ef41Sopenharmony_ci3. The cpu type for this build
131cb0ef41Sopenharmony_ci"""
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciimport sys
161cb0ef41Sopenharmony_ciimport os
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_civs_toolchain_dir, target_dir, target_cpu = sys.argv[1:]
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_cisys.path.insert(0, vs_toolchain_dir)
211cb0ef41Sopenharmony_ciimport vs_toolchain
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_cidef CopyDebuggerFile(debug_file):
241cb0ef41Sopenharmony_ci  win_sdk_dir = vs_toolchain.SetEnvironmentAndGetSDKDir()
251cb0ef41Sopenharmony_ci  if not win_sdk_dir:
261cb0ef41Sopenharmony_ci    return
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci  full_path = os.path.join(win_sdk_dir, 'Debuggers', target_cpu, debug_file)
291cb0ef41Sopenharmony_ci  if not os.path.exists(full_path):
301cb0ef41Sopenharmony_ci    return
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci  target_path = os.path.join(target_dir, debug_file)
331cb0ef41Sopenharmony_ci  vs_toolchain._CopyRuntimeImpl(target_path, full_path, verbose=False)
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci  # Ninja expects the file's timestamp to be newer than this script.
361cb0ef41Sopenharmony_ci  os.utime(target_path, None)
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ciCopyDebuggerFile('dbgeng.dll')
39