OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. 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 """ | 5 """ |
6 This module helps emulate Visual Studio 2008 behavior on top of other | 6 This module helps emulate Visual Studio 2008 behavior on top of other |
7 build systems, primarily ninja. | 7 build systems, primarily ninja. |
8 """ | 8 """ |
9 | 9 |
10 import os | 10 import os |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 'include', | 954 'include', |
955 'lib', | 955 'lib', |
956 'libpath', | 956 'libpath', |
957 'path', | 957 'path', |
958 'pathext', | 958 'pathext', |
959 'systemroot', | 959 'systemroot', |
960 'temp', | 960 'temp', |
961 'tmp', | 961 'tmp', |
962 ) | 962 ) |
963 env = {} | 963 env = {} |
| 964 # This occasionally happens and leads to misleading SYSTEMROOT error messages |
| 965 # if not caught here. |
| 966 if output_of_set.count('=') == 0: |
| 967 raise Exception('Invalid output_of_set. Value is:\n%s' % output_of_set) |
964 for line in output_of_set.splitlines(): | 968 for line in output_of_set.splitlines(): |
965 for envvar in envvars_to_save: | 969 for envvar in envvars_to_save: |
966 if re.match(envvar + '=', line.lower()): | 970 if re.match(envvar + '=', line.lower()): |
967 var, setting = line.split('=', 1) | 971 var, setting = line.split('=', 1) |
968 if envvar == 'path': | 972 if envvar == 'path': |
969 # Our own rules (for running gyp-win-tool) and other actions in | 973 # Our own rules (for running gyp-win-tool) and other actions in |
970 # Chromium rely on python being in the path. Add the path to this | 974 # Chromium rely on python being in the path. Add the path to this |
971 # python here so that if it's not in the path when ninja is run | 975 # python here so that if it's not in the path when ninja is run |
972 # later, python will still be found. | 976 # later, python will still be found. |
973 setting = os.path.dirname(sys.executable) + os.pathsep + setting | 977 setting = os.path.dirname(sys.executable) + os.pathsep + setting |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 return cl_paths | 1026 return cl_paths |
1023 vs = GetVSVersion(generator_flags) | 1027 vs = GetVSVersion(generator_flags) |
1024 cl_paths = {} | 1028 cl_paths = {} |
1025 for arch in archs: | 1029 for arch in archs: |
1026 # Extract environment variables for subprocesses. | 1030 # Extract environment variables for subprocesses. |
1027 args = vs.SetupScript(arch) | 1031 args = vs.SetupScript(arch) |
1028 args.extend(('&&', 'set')) | 1032 args.extend(('&&', 'set')) |
1029 popen = subprocess.Popen( | 1033 popen = subprocess.Popen( |
1030 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 1034 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
1031 variables, _ = popen.communicate() | 1035 variables, _ = popen.communicate() |
| 1036 if popen.returncode != 0: |
| 1037 raise Exception('"%s" failed with error %d' % (args, popen.returncode)) |
1032 env = _ExtractImportantEnvironment(variables) | 1038 env = _ExtractImportantEnvironment(variables) |
1033 | 1039 |
1034 # Inject system includes from gyp files into INCLUDE. | 1040 # Inject system includes from gyp files into INCLUDE. |
1035 if system_includes: | 1041 if system_includes: |
1036 system_includes = system_includes | OrderedSet( | 1042 system_includes = system_includes | OrderedSet( |
1037 env.get('INCLUDE', '').split(';')) | 1043 env.get('INCLUDE', '').split(';')) |
1038 env['INCLUDE'] = ';'.join(system_includes) | 1044 env['INCLUDE'] = ';'.join(system_includes) |
1039 | 1045 |
1040 env_block = _FormatAsEnvironmentBlock(env) | 1046 env_block = _FormatAsEnvironmentBlock(env) |
1041 f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb') | 1047 f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb') |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 | 1084 |
1079 # To determine processor word size on Windows, in addition to checking | 1085 # To determine processor word size on Windows, in addition to checking |
1080 # PROCESSOR_ARCHITECTURE (which reflects the word size of the current | 1086 # PROCESSOR_ARCHITECTURE (which reflects the word size of the current |
1081 # process), it is also necessary to check PROCESSOR_ARCHITEW6432 (which | 1087 # process), it is also necessary to check PROCESSOR_ARCHITEW6432 (which |
1082 # contains the actual word size of the system when running thru WOW64). | 1088 # contains the actual word size of the system when running thru WOW64). |
1083 if ('64' in os.environ.get('PROCESSOR_ARCHITECTURE', '') or | 1089 if ('64' in os.environ.get('PROCESSOR_ARCHITECTURE', '') or |
1084 '64' in os.environ.get('PROCESSOR_ARCHITEW6432', '')): | 1090 '64' in os.environ.get('PROCESSOR_ARCHITEW6432', '')): |
1085 default_variables['MSVS_OS_BITS'] = 64 | 1091 default_variables['MSVS_OS_BITS'] = 64 |
1086 else: | 1092 else: |
1087 default_variables['MSVS_OS_BITS'] = 32 | 1093 default_variables['MSVS_OS_BITS'] = 32 |
OLD | NEW |