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

Side by Side Diff: build/toolchain/win/setup_toolchain.py

Issue 1556993002: [gn] Detect location of Visual Studio in the registry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Let setup_toolchain.py use vs_toolchain.py Created 4 years, 11 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 | build/vs_toolchain.py » ('j') | build/vs_toolchain.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 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 # Copies the given "win tool" (which the toolchain uses to wrap compiler 5 # Copies the given "win tool" (which the toolchain uses to wrap compiler
6 # invocations) and the environment blocks for the 32-bit and 64-bit builds on 6 # invocations) and the environment blocks for the 32-bit and 64-bit builds on
7 # Windows to the build directory. 7 # Windows to the build directory.
8 # 8 #
9 # The arguments are the visual studio install location and the location of the 9 # The arguments are the visual studio install location and the location of the
10 # win tool. The script assumes that the root build directory is the current dir 10 # win tool. The script assumes that the root build directory is the current dir
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 setting = os.path.dirname(sys.executable) + os.pathsep + setting 48 setting = os.path.dirname(sys.executable) + os.pathsep + setting
49 env[var.upper()] = setting 49 env[var.upper()] = setting
50 break 50 break
51 for required in ('SYSTEMROOT', 'TEMP', 'TMP'): 51 for required in ('SYSTEMROOT', 'TEMP', 'TMP'):
52 if required not in env: 52 if required not in env:
53 raise Exception('Environment variable "%s" ' 53 raise Exception('Environment variable "%s" '
54 'required to be set to valid path' % required) 54 'required to be set to valid path' % required)
55 return env 55 return env
56 56
57 57
58 def _DetectVisualStudioPath():
59 """Return path to the GYP_MSVS_VERSION of Visual Studio
scottmg 2016/01/05 23:30:32 Trailing . on comments.
Daniel Bratell 2016/01/07 16:10:48 Done.
60 """
61
62 # Use the code in build/vs_toolchain.py to avoid duplicating code.
63 this_dir = os.path.dirname(__file__)
scottmg 2016/01/05 23:30:32 I think there's some rule about getting this befor
Daniel Bratell 2016/01/07 16:10:48 Done.
64 chromium_dir = os.path.abspath(os.path.join(this_dir, '..', '..', '..'))
65 sys.path.append(os.path.join(chromium_dir, 'build'))
66 import vs_toolchain
67 return vs_toolchain.DetectVisualStudioPath()
68
69
58 def _SetupScript(target_cpu, sdk_dir): 70 def _SetupScript(target_cpu, sdk_dir):
59 """Returns a command (with arguments) to be used to set up the 71 """Returns a command (with arguments) to be used to set up the
60 environment.""" 72 environment."""
61 # Check if we are running in the SDK command line environment and use 73 # Check if we are running in the SDK command line environment and use
62 # the setup script from the SDK if so. |target_cpu| should be either 74 # the setup script from the SDK if so. |target_cpu| should be either
63 # 'x86' or 'x64'. 75 # 'x86' or 'x64'.
64 assert target_cpu in ('x86', 'x64') 76 assert target_cpu in ('x86', 'x64')
65 if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', 1))) and sdk_dir: 77 if bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', 1))) and sdk_dir:
66 return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')), 78 return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
67 '/' + target_cpu] 79 '/' + target_cpu]
68 else: 80 else:
81 if not 'GYP_MSVS_OVERRIDE_PATH' in os.environ:
scottmg 2016/01/05 23:30:32 if 'GYP_MSVS_OVERRIDE_PATH' not in os.environ
Daniel Bratell 2016/01/07 16:10:48 Done.
82 os.environ['GYP_MSVS_OVERRIDE_PATH'] = _DetectVisualStudioPath()
69 # We only support x64-hosted tools. 83 # We only support x64-hosted tools.
70 # TODO(scottmg|dpranke): Non-depot_tools toolchain: need to get Visual
71 # Studio install location from registry.
72 return [os.path.normpath(os.path.join(os.environ['GYP_MSVS_OVERRIDE_PATH'], 84 return [os.path.normpath(os.path.join(os.environ['GYP_MSVS_OVERRIDE_PATH'],
73 'VC/vcvarsall.bat')), 85 'VC/vcvarsall.bat')),
74 'amd64_x86' if target_cpu == 'x86' else 'amd64'] 86 'amd64_x86' if target_cpu == 'x86' else 'amd64']
75 87
76 88
77 def _FormatAsEnvironmentBlock(envvar_dict): 89 def _FormatAsEnvironmentBlock(envvar_dict):
78 """Format as an 'environment block' directly suitable for CreateProcess. 90 """Format as an 'environment block' directly suitable for CreateProcess.
79 Briefly this is a list of key=value\0, terminated by an additional \0. See 91 Briefly this is a list of key=value\0, terminated by an additional \0. See
80 CreateProcess documentation for more details.""" 92 CreateProcess documentation for more details."""
81 block = '' 93 block = ''
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 env_block = _FormatAsEnvironmentBlock(env) 172 env_block = _FormatAsEnvironmentBlock(env)
161 with open('environment.winrt_' + cpu, 'wb') as f: 173 with open('environment.winrt_' + cpu, 'wb') as f:
162 f.write(env_block) 174 f.write(env_block)
163 175
164 assert vc_bin_dir 176 assert vc_bin_dir
165 print 'vc_bin_dir = "%s"' % vc_bin_dir 177 print 'vc_bin_dir = "%s"' % vc_bin_dir
166 178
167 179
168 if __name__ == '__main__': 180 if __name__ == '__main__':
169 main() 181 main()
OLDNEW
« no previous file with comments | « no previous file | build/vs_toolchain.py » ('j') | build/vs_toolchain.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698