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

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: add bison and gperf 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
jam 2014/11/03 22:04:49 ditto for all these updates to files in build?
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 shlex
8 import shutil 9 import shutil
9 import subprocess 10 import subprocess
10 import sys 11 import sys
11 12
12 13
13 script_dir = os.path.dirname(os.path.realpath(__file__)) 14 script_dir = os.path.dirname(os.path.realpath(__file__))
14 chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) 15 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__))) 16 SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
16 sys.path.insert(1, os.path.join(chrome_src, 'tools')) 17 sys.path.insert(1, os.path.join(chrome_src, 'tools'))
17 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib')) 18 sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
18 json_data_file = os.path.join(script_dir, 'win_toolchain.json') 19 json_data_file = os.path.join(script_dir, 'win_toolchain.json')
19 20
20 21
21 import gyp 22 def NameValueListToDict(name_value_list):
scottmg 2014/11/03 22:28:34 This was also to avoid pulling gyp. Maybe I should
23 """
24 Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary
25 of the pairs. If a string is simply NAME, then the value in the dictionary
26 is set to True. If VALUE can be converted to an integer, it is.
27 """
28 result = { }
29 for item in name_value_list:
30 tokens = item.split('=', 1)
31 if len(tokens) == 2:
32 # If we can make it an int, use that, otherwise, use the string.
33 try:
34 token_value = int(tokens[1])
35 except ValueError:
36 token_value = tokens[1]
37 # Set the variable to the supplied value.
38 result[tokens[0]] = token_value
39 else:
40 # No value supplied, treat it as a boolean and set it.
41 result[tokens[0]] = True
42 return result
43
44
45 def ShlexEnv(env_name):
46 flags = os.environ.get(env_name, [])
47 if flags:
48 flags = shlex.split(flags)
49 return flags
22 50
23 51
24 def SetEnvironmentAndGetRuntimeDllDirs(): 52 def SetEnvironmentAndGetRuntimeDllDirs():
25 """Sets up os.environ to use the depot_tools VS toolchain with gyp, and 53 """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 54 returns the location of the VS runtime DLLs so they can be copied into
27 the output directory after gyp generation. 55 the output directory after gyp generation.
28 """ 56 """
29 vs2013_runtime_dll_dirs = None 57 vs2013_runtime_dll_dirs = None
30 depot_tools_win_toolchain = \ 58 depot_tools_win_toolchain = \
31 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) 59 bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
(...skipping 12 matching lines...) Expand all
44 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call 72 # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call
45 # below). http://crbug.com/345992 73 # below). http://crbug.com/345992
46 vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs'] 74 vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs']
47 75
48 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain 76 os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
49 os.environ['GYP_MSVS_VERSION'] = version 77 os.environ['GYP_MSVS_VERSION'] = version
50 # We need to make sure windows_sdk_path is set to the automated 78 # 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 79 # toolchain values in GYP_DEFINES, but don't want to override any
52 # otheroptions.express 80 # otheroptions.express
53 # values there. 81 # values there.
54 gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES')) 82 gyp_defines_dict = NameValueListToDict(ShlexEnv('GYP_DEFINES'))
55 gyp_defines_dict['windows_sdk_path'] = win8sdk 83 gyp_defines_dict['windows_sdk_path'] = win8sdk
56 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v))) 84 os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
57 for k, v in gyp_defines_dict.iteritems()) 85 for k, v in gyp_defines_dict.iteritems())
58 os.environ['WINDOWSSDKDIR'] = win8sdk 86 os.environ['WINDOWSSDKDIR'] = win8sdk
59 os.environ['WDK_DIR'] = wdk 87 os.environ['WDK_DIR'] = wdk
60 # Include the VS runtime in the PATH in case it's not machine-installed. 88 # Include the VS runtime in the PATH in case it's not machine-installed.
61 runtime_path = ';'.join(vs2013_runtime_dll_dirs) 89 runtime_path = ';'.join(vs2013_runtime_dll_dirs)
62 os.environ['PATH'] = runtime_path + ';' + os.environ['PATH'] 90 os.environ['PATH'] = runtime_path + ';' + os.environ['PATH']
63 return vs2013_runtime_dll_dirs 91 return vs2013_runtime_dll_dirs
64 92
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 # CopyVsRuntimeDlls via import, currently). 220 # CopyVsRuntimeDlls via import, currently).
193 } 221 }
194 if len(sys.argv) < 2 or sys.argv[1] not in commands: 222 if len(sys.argv) < 2 or sys.argv[1] not in commands:
195 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) 223 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
196 return 1 224 return 1
197 return commands[sys.argv[1]]() 225 return commands[sys.argv[1]]()
198 226
199 227
200 if __name__ == '__main__': 228 if __name__ == '__main__':
201 sys.exit(main()) 229 sys.exit(main())
OLDNEW
« no previous file with comments | « build/toolchain/win/BUILD.gn ('k') | build/win/win_tool.py » ('j') | build/win/win_tool.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698