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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
890 return block | 890 return block |
891 | 891 |
892 def _ExtractCLPath(output_of_where): | 892 def _ExtractCLPath(output_of_where): |
893 """Gets the path to cl.exe based on the output of calling the environment | 893 """Gets the path to cl.exe based on the output of calling the environment |
894 setup batch file, followed by the equivalent of `where`.""" | 894 setup batch file, followed by the equivalent of `where`.""" |
895 # Take the first line, as that's the first found in the PATH. | 895 # Take the first line, as that's the first found in the PATH. |
896 for line in output_of_where.strip().splitlines(): | 896 for line in output_of_where.strip().splitlines(): |
897 if line.startswith('LOC:'): | 897 if line.startswith('LOC:'): |
898 return line[len('LOC:'):].strip() | 898 return line[len('LOC:'):].strip() |
899 | 899 |
900 def GenerateEnvironmentFiles(toplevel_build_dir, generator_flags, open_out): | 900 def GenerateEnvironmentFiles(toplevel_build_dir, generator_flags, |
901 system_includes, open_out): | |
901 """It's not sufficient to have the absolute path to the compiler, linker, | 902 """It's not sufficient to have the absolute path to the compiler, linker, |
902 etc. on Windows, as those tools rely on .dlls being in the PATH. We also | 903 etc. on Windows, as those tools rely on .dlls being in the PATH. We also |
903 need to support both x86 and x64 compilers within the same build (to support | 904 need to support both x86 and x64 compilers within the same build (to support |
904 msvs_target_platform hackery). Different architectures require a different | 905 msvs_target_platform hackery). Different architectures require a different |
905 compiler binary, and different supporting environment variables (INCLUDE, | 906 compiler binary, and different supporting environment variables (INCLUDE, |
906 LIB, LIBPATH). So, we extract the environment here, wrap all invocations | 907 LIB, LIBPATH). So, we extract the environment here, wrap all invocations |
907 of compiler tools (cl, link, lib, rc, midl, etc.) via win_tool.py which | 908 of compiler tools (cl, link, lib, rc, midl, etc.) via win_tool.py which |
908 sets up the environment, and then we do not prefix the compiler with | 909 sets up the environment, and then we do not prefix the compiler with |
909 an absolute path, instead preferring something like "cl.exe" in the rule | 910 an absolute path, instead preferring something like "cl.exe" in the rule |
910 which will then run whichever the environment setup has put in the path. | 911 which will then run whichever the environment setup has put in the path. |
(...skipping 10 matching lines...) Expand all Loading... | |
921 vs = GetVSVersion(generator_flags) | 922 vs = GetVSVersion(generator_flags) |
922 cl_paths = {} | 923 cl_paths = {} |
923 for arch in archs: | 924 for arch in archs: |
924 # Extract environment variables for subprocesses. | 925 # Extract environment variables for subprocesses. |
925 args = vs.SetupScript(arch) | 926 args = vs.SetupScript(arch) |
926 args.extend(('&&', 'set')) | 927 args.extend(('&&', 'set')) |
927 popen = subprocess.Popen( | 928 popen = subprocess.Popen( |
928 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 929 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
929 variables, _ = popen.communicate() | 930 variables, _ = popen.communicate() |
930 env = _ExtractImportantEnvironment(variables) | 931 env = _ExtractImportantEnvironment(variables) |
932 | |
933 # Inject system includes from gyp files into INCLUDE. | |
934 if system_includes: | |
935 system_includes = system_includes | set(env.get('INCLUDE', '').split(';')) | |
scottmg
2014/07/19 18:49:36
i think order should be preserved (though i'm not
Nico
2014/07/19 23:05:35
Changed everything to use OrderedDict
| |
936 env['INCLUDE'] = ';'.join(system_includes) | |
937 | |
931 env_block = _FormatAsEnvironmentBlock(env) | 938 env_block = _FormatAsEnvironmentBlock(env) |
932 f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb') | 939 f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb') |
933 f.write(env_block) | 940 f.write(env_block) |
934 f.close() | 941 f.close() |
935 | 942 |
936 # Find cl.exe location for this architecture. | 943 # Find cl.exe location for this architecture. |
937 args = vs.SetupScript(arch) | 944 args = vs.SetupScript(arch) |
938 args.extend(('&&', | 945 args.extend(('&&', |
939 'for', '%i', 'in', '(cl.exe)', 'do', '@echo', 'LOC:%~$PATH:i')) | 946 'for', '%i', 'in', '(cl.exe)', 'do', '@echo', 'LOC:%~$PATH:i')) |
940 popen = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE) | 947 popen = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE) |
(...skipping 28 matching lines...) Expand all Loading... | |
969 | 976 |
970 # To determine processor word size on Windows, in addition to checking | 977 # To determine processor word size on Windows, in addition to checking |
971 # PROCESSOR_ARCHITECTURE (which reflects the word size of the current | 978 # PROCESSOR_ARCHITECTURE (which reflects the word size of the current |
972 # process), it is also necessary to check PROCESSOR_ARCHITEW6432 (which | 979 # process), it is also necessary to check PROCESSOR_ARCHITEW6432 (which |
973 # contains the actual word size of the system when running thru WOW64). | 980 # contains the actual word size of the system when running thru WOW64). |
974 if ('64' in os.environ.get('PROCESSOR_ARCHITECTURE', '') or | 981 if ('64' in os.environ.get('PROCESSOR_ARCHITECTURE', '') or |
975 '64' in os.environ.get('PROCESSOR_ARCHITEW6432', '')): | 982 '64' in os.environ.get('PROCESSOR_ARCHITEW6432', '')): |
976 default_variables['MSVS_OS_BITS'] = 64 | 983 default_variables['MSVS_OS_BITS'] = 64 |
977 else: | 984 else: |
978 default_variables['MSVS_OS_BITS'] = 32 | 985 default_variables['MSVS_OS_BITS'] = 32 |
OLD | NEW |