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

Side by Side Diff: build/vs_toolchain.py

Issue 405983003: Copy the PGO runtime library to the release directory (take 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cut&paste error. Created 6 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import os 6 import os
7 import pipes 7 import pipes
8 import shutil 8 import shutil
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 def CopyVsRuntimeDlls(output_dir, runtime_dirs): 64 def CopyVsRuntimeDlls(output_dir, runtime_dirs):
65 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output 65 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output
66 directory so that even if not system-installed, built binaries are likely to 66 directory so that even if not system-installed, built binaries are likely to
67 be able to run. 67 be able to run.
68 68
69 This needs to be run after gyp has been run so that the expected target 69 This needs to be run after gyp has been run so that the expected target
70 output directories are already created. 70 output directories are already created.
71 """ 71 """
72 assert sys.platform.startswith(('win32', 'cygwin')) 72 assert sys.platform.startswith(('win32', 'cygwin'))
73 73
74 def copy_runtime_impl(target, source):
75 """Copy |source| to |target| if it doesn't already exist or if it need to be
76 updated.
77 """
78 if (os.path.isdir(os.path.dirname(target)) and
79 (not os.path.isfile(target) or
80 os.stat(target).st_mtime != os.stat(source).st_mtime)):
81 print 'Copying %s to %s...' % (source, target)
82 if os.path.exists(target):
83 os.unlink(target)
84 shutil.copy2(source, target)
85
74 def copy_runtime(target_dir, source_dir, dll_pattern): 86 def copy_runtime(target_dir, source_dir, dll_pattern):
75 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't 87 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't
76 exist, but the target directory does exist.""" 88 exist, but the target directory does exist."""
77 for which in ('p', 'r'): 89 for which in ('p', 'r'):
78 dll = dll_pattern % which 90 dll = dll_pattern % which
79 target = os.path.join(target_dir, dll) 91 target = os.path.join(target_dir, dll)
80 source = os.path.join(source_dir, dll) 92 source = os.path.join(source_dir, dll)
81 # If gyp generated to that output dir, and the runtime isn't already 93 copy_runtime_impl(target, source)
82 # there, then copy it over.
83 if (os.path.isdir(target_dir) and
84 (not os.path.isfile(target) or
85 os.stat(target).st_mtime != os.stat(source).st_mtime)):
86 print 'Copying %s to %s...' % (source, target)
87 if os.path.exists(target):
88 os.unlink(target)
89 shutil.copy2(source, target)
90 94
91 x86, x64 = runtime_dirs 95 x86, x64 = runtime_dirs
92 out_debug = os.path.join(output_dir, 'Debug') 96 out_debug = os.path.join(output_dir, 'Debug')
93 out_debug_nacl64 = os.path.join(output_dir, 'Debug', 'x64') 97 out_debug_nacl64 = os.path.join(output_dir, 'Debug', 'x64')
94 out_release = os.path.join(output_dir, 'Release') 98 out_release = os.path.join(output_dir, 'Release')
95 out_release_nacl64 = os.path.join(output_dir, 'Release', 'x64') 99 out_release_nacl64 = os.path.join(output_dir, 'Release', 'x64')
96 out_debug_x64 = os.path.join(output_dir, 'Debug_x64') 100 out_debug_x64 = os.path.join(output_dir, 'Debug_x64')
97 out_release_x64 = os.path.join(output_dir, 'Release_x64') 101 out_release_x64 = os.path.join(output_dir, 'Release_x64')
98 102
99 if os.path.exists(out_debug) and not os.path.exists(out_debug_nacl64): 103 if os.path.exists(out_debug) and not os.path.exists(out_debug_nacl64):
100 os.makedirs(out_debug_nacl64) 104 os.makedirs(out_debug_nacl64)
101 if os.path.exists(out_release) and not os.path.exists(out_release_nacl64): 105 if os.path.exists(out_release) and not os.path.exists(out_release_nacl64):
102 os.makedirs(out_release_nacl64) 106 os.makedirs(out_release_nacl64)
103 copy_runtime(out_debug, x86, 'msvc%s120d.dll') 107 copy_runtime(out_debug, x86, 'msvc%s120d.dll')
104 copy_runtime(out_release, x86, 'msvc%s120.dll') 108 copy_runtime(out_release, x86, 'msvc%s120.dll')
105 copy_runtime(out_debug_x64, x64, 'msvc%s120d.dll') 109 copy_runtime(out_debug_x64, x64, 'msvc%s120d.dll')
106 copy_runtime(out_release_x64, x64, 'msvc%s120.dll') 110 copy_runtime(out_release_x64, x64, 'msvc%s120.dll')
107 copy_runtime(out_debug_nacl64, x64, 'msvc%s120d.dll') 111 copy_runtime(out_debug_nacl64, x64, 'msvc%s120d.dll')
108 copy_runtime(out_release_nacl64, x64, 'msvc%s120.dll') 112 copy_runtime(out_release_nacl64, x64, 'msvc%s120.dll')
109 113
114 # Copy the PGO runtime library to the release directories.
115 if os.environ.get('GYP_MSVS_OVERRIDE_PATH'):
116 pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'),
117 'VC', 'bin')
118 pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64')
119 pgo_runtime_dll = 'pgort120.dll'
120 source_x86 = os.path.join(pgo_x86_runtime_dir, pgo_runtime_dll)
121 if os.path.exists(source_x86):
122 copy_runtime_impl(os.path.join(out_release, pgo_runtime_dll), source_x86)
123 source_x64 = os.path.join(pgo_x64_runtime_dir, pgo_runtime_dll)
124 if os.path.exists(source_x64):
125 copy_runtime_impl(os.path.join(out_release_x64, pgo_runtime_dll),
126 source_x64)
127
110 128
111 def _GetDesiredVsToolchainHashes(): 129 def _GetDesiredVsToolchainHashes():
112 """Load a list of SHA1s corresponding to the toolchains that we want installed 130 """Load a list of SHA1s corresponding to the toolchains that we want installed
113 to build with.""" 131 to build with."""
114 sha1path = os.path.join(script_dir, 'toolchain_vs2013.hash') 132 sha1path = os.path.join(script_dir, 'toolchain_vs2013.hash')
115 with open(sha1path, 'rb') as f: 133 with open(sha1path, 'rb') as f:
116 return f.read().strip().splitlines() 134 return f.read().strip().splitlines()
117 135
118 136
119 def Update(): 137 def Update():
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 # CopyVsRuntimeDlls via import, currently). 182 # CopyVsRuntimeDlls via import, currently).
165 } 183 }
166 if len(sys.argv) < 2 or sys.argv[1] not in commands: 184 if len(sys.argv) < 2 or sys.argv[1] not in commands:
167 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) 185 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
168 return 1 186 return 1
169 return commands[sys.argv[1]]() 187 return commands[sys.argv[1]]()
170 188
171 189
172 if __name__ == '__main__': 190 if __name__ == '__main__':
173 sys.exit(main()) 191 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698