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

Side by Side Diff: build/vs_toolchain.py

Issue 694353003: Get `gn gen` to succeed on Windows (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: remove GYP_DEFINES code 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 unified diff | Download patch
« no previous file with comments | « build/toolchain/win/BUILD.gn ('k') | build/win/win_tool.py » ('j') | 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
11 11
12 12
13 script_dir = os.path.dirname(os.path.realpath(__file__)) 13 script_dir = os.path.dirname(os.path.realpath(__file__))
14 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) 14 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir))
15 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 15 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
16 sys.path.insert(1, os.path.join(chrome_src, 'tools')) 16 sys.path.insert(1, os.path.join(chrome_src, 'tools'))
17 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) 17 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
18 json_data_file = os.path.join(script_dir, 'win_toolchain.json') 18 json_data_file = os.path.join(script_dir, 'win_toolchain.json')
19 19
20 20
21 import gyp
22
23
24 def SetEnvironmentAndGetRuntimeDllDirs(): 21 def SetEnvironmentAndGetRuntimeDllDirs():
25 """Sets up os.environ to use the depot_tools VS toolchain with gyp, and 22 """Sets up os.environ to use the depot_tools VS toolchain with gyp, and
26 returns the location of the VS runtime DLLs so they can be copied into 23 returns the location of the VS runtime DLLs so they can be copied into
27 the output directory after gyp generation. 24 the output directory after gyp generation.
28 """ 25 """
29 vs2013_runtime_dll_dirs = None 26 vs2013_runtime_dll_dirs = None
30 depot_tools_win_toolchain = \ 27 depot_tools_win_toolchain = \
31 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) 28 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
32 if sys.platform in ('win32', 'cygwin') and depot_tools_win_toolchain: 29 if sys.platform in ('win32', 'cygwin') and depot_tools_win_toolchain:
33 if not os.path.exists(json_data_file): 30 if not os.path.exists(json_data_file):
34 Update() 31 Update()
35 with open(json_data_file, 'r') as tempf: 32 with open(json_data_file, 'r') as tempf:
36 toolchain_data = json.load(tempf) 33 toolchain_data = json.load(tempf)
37 34
38 toolchain = toolchain_data['path'] 35 toolchain = toolchain_data['path']
39 version = toolchain_data['version'] 36 version = toolchain_data['version']
40 version_is_pro = version[-1] != 'e' 37 version_is_pro = version[-1] != 'e'
41 win8sdk = toolchain_data['win8sdk'] 38 win8sdk = toolchain_data['win8sdk']
42 wdk = toolchain_data['wdk'] 39 wdk = toolchain_data['wdk']
43 # TODO(scottmg): The order unfortunately matters in these. They should be 40 # TODO(scottmg): The order unfortunately matters in these. They should be
44 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call 41 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call
45 # below). http://crbug.com/345992 42 # below). http://crbug.com/345992
46 vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs'] 43 vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs']
47 44
48 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain 45 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
49 os.environ['GYP_MSVS_VERSION'] = version 46 os.environ['GYP_MSVS_VERSION'] = version
50 # We need to make sure windows_sdk_path is set to the automated
51 # toolchain values in GYP_DEFINES, but don't want to override any
52 # otheroptions.express
53 # values there.
54 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
55 gyp_defines_dict['windows_sdk_path'] = win8sdk
56 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
57 for k, v in gyp_defines_dict.iteritems())
58 os.environ['WINDOWSSDKDIR'] = win8sdk 47 os.environ['WINDOWSSDKDIR'] = win8sdk
59 os.environ['WDK_DIR'] = wdk 48 os.environ['WDK_DIR'] = wdk
60 # Include the VS runtime in the PATH in case it's not machine-installed. 49 # Include the VS runtime in the PATH in case it's not machine-installed.
61 runtime_path = ';'.join(vs2013_runtime_dll_dirs) 50 runtime_path = ';'.join(vs2013_runtime_dll_dirs)
62 os.environ['PATH'] = runtime_path + ';' + os.environ['PATH'] 51 os.environ['PATH'] = runtime_path + ';' + os.environ['PATH']
63 return vs2013_runtime_dll_dirs 52 return vs2013_runtime_dll_dirs
64 53
65 54
66 def CopyVsRuntimeDlls(output_dir, runtime_dirs): 55 def CopyVsRuntimeDlls(output_dir, runtime_dirs):
67 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output 56 """Copies the VS runtime DLLs from the given |runtime_dirs| to the output
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 # CopyVsRuntimeDlls via import, currently). 181 # CopyVsRuntimeDlls via import, currently).
193 } 182 }
194 if len(sys.argv) < 2 or sys.argv[1] not in commands: 183 if len(sys.argv) < 2 or sys.argv[1] not in commands:
195 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) 184 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
196 return 1 185 return 1
197 return commands[sys.argv[1]]() 186 return commands[sys.argv[1]]()
198 187
199 188
200 if __name__ == '__main__': 189 if __name__ == '__main__':
201 sys.exit(main()) 190 sys.exit(main())
OLDNEW
« no previous file with comments | « build/toolchain/win/BUILD.gn ('k') | build/win/win_tool.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698