Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(652)

Unified Diff: build/vs_toolchain.py

Issue 722723004: Rework win_toolchains a bit and copy the vs runtime DLLs as needed. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« build/toolchain/win/BUILD.gn ('K') | « build/toolchain/win/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/vs_toolchain.py
diff --git a/build/vs_toolchain.py b/build/vs_toolchain.py
index bdedd6fa8822f121da2687d338cbdf3f58140575..34c98427af7b42bd1a095220e42e70a03b2964b6 100644
--- a/build/vs_toolchain.py
+++ b/build/vs_toolchain.py
@@ -73,27 +73,6 @@ def CopyVsRuntimeDlls(output_dir, runtime_dirs):
"""
assert sys.platform.startswith(('win32', 'cygwin'))
- def copy_runtime_impl(target, source):
- """Copy |source| to |target| if it doesn't already exist or if it need to be
- updated.
- """
- if (os.path.isdir(os.path.dirname(target)) and
- (not os.path.isfile(target) or
- os.stat(target).st_mtime != os.stat(source).st_mtime)):
- print 'Copying %s to %s...' % (source, target)
- if os.path.exists(target):
- os.unlink(target)
- shutil.copy2(source, target)
-
- 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)
- copy_runtime_impl(target, source)
-
x86, x64 = runtime_dirs
out_debug = os.path.join(output_dir, 'Debug')
out_debug_nacl64 = os.path.join(output_dir, 'Debug', 'x64')
@@ -106,12 +85,12 @@ def CopyVsRuntimeDlls(output_dir, runtime_dirs):
os.makedirs(out_debug_nacl64)
if os.path.exists(out_release) and not os.path.exists(out_release_nacl64):
os.makedirs(out_release_nacl64)
- 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')
- copy_runtime(out_debug_nacl64, x64, 'msvc%s120d.dll')
- copy_runtime(out_release_nacl64, x64, 'msvc%s120.dll')
+ _CopyRuntime(out_debug, x86, 'msvc%s120d.dll')
+ _CopyRuntime(out_release, x86, 'msvc%s120.dll')
+ _CopyRuntime(out_debug_x64, x64, 'msvc%s120d.dll')
+ _CopyRuntime(out_release_x64, x64, 'msvc%s120.dll')
+ _CopyRuntime(out_debug_nacl64, x64, 'msvc%s120d.dll')
+ _CopyRuntime(out_release_nacl64, x64, 'msvc%s120.dll')
# Copy the PGO runtime library to the release directories.
if os.environ.get('GYP_MSVS_OVERRIDE_PATH'):
@@ -128,6 +107,26 @@ def CopyVsRuntimeDlls(output_dir, runtime_dirs):
source_x64)
+def CopyDlls(target_dir, configuration, cpu_arch):
+ """Copy the VS runtime DLLs into the requested directory as needed.
+
+ configuration is one of 'Debug' or 'Release'.
+ cpu_arch is one of 'x86' or 'x64'.
+
+ The debug configuration gets both the debug and release DLLs; the
+ release config only the latter.
scottmg 2014/11/13 03:49:59 add a note to see the gyp version above, and note
Dirk Pranke 2014/11/13 05:49:36 Will do.
+ """
scottmg 2014/11/13 03:49:59 add a note that this will mean nacl tests will fai
Dirk Pranke 2014/11/13 05:49:36 I'm not sure what you're referring to here. Which
Nick Bray (chromium) 2014/11/13 20:10:53 Reading between the lines: NaCl will need x64 dlls
+ vs2013_runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
+ if not vs2013_runtime_dll_dirs:
+ return
+
+ x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
+ runtime_dir = x64_runtime if cpu_arch == 'x64' else x86_runtime
+ _CopyRuntime(target_dir, runtime_dir, 'msvc%s120.dll')
+ if configuration == 'Debug':
+ _CopyRuntime(target_dir, runtime_dir, 'msvc%s120d.dll')
+
+
def _GetDesiredVsToolchainHashes():
"""Load a list of SHA1s corresponding to the toolchains that we want installed
to build with."""
@@ -188,13 +187,34 @@ def main():
commands = {
'update': Update,
'get_toolchain_dir': GetToolchainDir,
- # TODO(scottmg): Add copy_dlls for GN builds (gyp_chromium calls
- # CopyVsRuntimeDlls via import, currently).
+ 'copy_dlls': CopyDlls,
}
if len(sys.argv) < 2 or sys.argv[1] not in commands:
print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
return 1
- return commands[sys.argv[1]]()
+ return commands[sys.argv[1]](*sys.argv[2:])
+
+
+def _CopyRuntime(target_dir, source_dir, dll_pattern):
scottmg 2014/11/13 03:49:59 nit; move this up to before where it's used
Dirk Pranke 2014/11/13 05:49:36 Will do.
Dirk Pranke 2014/11/14 23:03:22 Done.
+ """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't
+ exist, but the target directory does exist."""
+ def copy_runtime_impl(target, source):
+ """Copy |source| to |target| if it doesn't already exist or if it
+ needs to be updated.
+ """
+ if (os.path.isdir(os.path.dirname(target)) and
+ (not os.path.isfile(target) or
+ os.stat(target).st_mtime != os.stat(source).st_mtime)):
+ print 'Copying %s to %s...' % (source, target)
+ if os.path.exists(target):
+ os.unlink(target)
+ shutil.copy2(source, target)
+
+ for which in ('p', 'r'):
+ dll = dll_pattern % which
+ target = os.path.join(target_dir, dll)
+ source = os.path.join(source_dir, dll)
+ copy_runtime_impl(target, source)
if __name__ == '__main__':
« build/toolchain/win/BUILD.gn ('K') | « build/toolchain/win/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698