Index: build/gyp_chromium |
diff --git a/build/gyp_chromium b/build/gyp_chromium |
index 80681dcb1a2283efbee253903ad55d1d5520f39e..30f1711c3764d6857a37001b7a3005d2998da772 100755 |
--- a/build/gyp_chromium |
+++ b/build/gyp_chromium |
@@ -12,6 +12,7 @@ import gyp_helper |
import os |
import pipes |
import shlex |
+import shutil |
import subprocess |
import string |
import sys |
@@ -326,6 +327,39 @@ def RunGN(supplemental_includes): |
return subprocess.call(args) == 0 |
+def CopyVsRuntimeDlls(output_dir, runtime_dirs): |
+ """Copies the VS runtime DLLs from the given |runtime_dirs| to the output |
+ directory so that even if not system-installed, built binaries are likely to |
+ be able to run. |
+ |
+ This needs to be run after gyp has been run so that the expected target |
+ output directories are already created. |
+ """ |
+ assert sys.platform.startswith(('win32', 'cygwin')) |
+ |
+ def copy_runtime(target_dir, source_dir, dll_pattern): |
+ """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't |
+ exist, but the target directory does exist.""" |
+ for which in ('p', 'r'): |
+ dll = dll_pattern % which |
+ target = os.path.join(target_dir, dll) |
+ source = os.path.join(source_dir, dll) |
+ # If gyp generated to that output dir, and the runtime isn't already |
+ # there, then copy it over. |
+ if os.path.isdir(target_dir) and not os.path.isfile(target): |
+ shutil.copyfile(source, target) |
+ |
+ x86, x64 = runtime_dirs |
+ out_debug = os.path.join(output_dir, 'Debug') |
+ out_release = os.path.join(output_dir, 'Release') |
+ out_debug_x64 = os.path.join(output_dir, 'Debug_x64') |
+ out_release_x64 = os.path.join(output_dir, 'Release_x64') |
+ copy_runtime(out_debug, x86, 'msvc%s120d.dll') |
+ copy_runtime(out_release, x86, 'msvc%s120.dll') |
+ copy_runtime(out_debug_x64, x64, 'msvc%s120d.dll') |
+ copy_runtime(out_release_x64, x64, 'msvc%s120.dll') |
+ |
+ |
if __name__ == '__main__': |
args = sys.argv[1:] |
@@ -402,6 +436,7 @@ if __name__ == '__main__': |
# If using ninja on windows, and the automatic toolchain has been installed |
# by depot_tools, then use it. |
+ vs2013_runtime_dll_dirs = None |
if (sys.platform in ('win32', 'cygwin') and |
os.environ.get('GYP_GENERATORS') == 'ninja'): |
depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
@@ -412,6 +447,8 @@ if __name__ == '__main__': |
os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain |
with open(version_file, 'r') as f: |
version_is_pro = f.read().strip() == 'pro' |
+ vs2013_runtime_dll_dirs = (os.path.join(toolchain, 'sys32'), |
+ os.path.join(toolchain, 'sys64')) |
os.environ['GYP_MSVS_VERSION'] = '2013' if version_is_pro else '2013e' |
# We need to make sure windows_sdk_path is set to the automated |
# toolchain values in GYP_DEFINES, but don't want to override any other |
@@ -449,4 +486,9 @@ if __name__ == '__main__': |
sys.stdout.flush() |
# Off we go... |
- sys.exit(gyp.main(args)) |
+ gyp_rc = gyp.main(args) |
+ |
+ if vs2013_runtime_dll_dirs: |
+ CopyVsRuntimeDlls(GetOutputDirectory(), vs2013_runtime_dll_dirs) |
+ |
+ sys.exit(gyp_rc) |