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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 else: | 106 else: |
107 append.append(element) | 107 append.append(element) |
108 else: | 108 else: |
109 return element | 109 return element |
110 | 110 |
111 | 111 |
112 def _FindDirectXInstallation(): | 112 def _FindDirectXInstallation(): |
113 """Try to find an installation location for the DirectX SDK. Check for the | 113 """Try to find an installation location for the DirectX SDK. Check for the |
114 standard environment variable, and if that doesn't exist, try to find | 114 standard environment variable, and if that doesn't exist, try to find |
115 via the registry. May return None if not found in either location.""" | 115 via the registry. May return None if not found in either location.""" |
116 if sys.platform not in ('win32', 'cygwin'): | |
117 return '' | |
Nico
2012/08/14 21:36:26
Why do you need this?
Sam Clegg
2012/08/14 22:36:57
It allows me to do --format=ninja-win on my linux
Nico
2012/08/14 22:42:26
That sounds unrelated to what this CL is about the
| |
118 | |
116 # Return previously calculated value, if there is one | 119 # Return previously calculated value, if there is one |
117 if hasattr(_FindDirectXInstallation, 'dxsdk_dir'): | 120 if hasattr(_FindDirectXInstallation, 'dxsdk_dir'): |
118 return _FindDirectXInstallation.dxsdk_dir | 121 return _FindDirectXInstallation.dxsdk_dir |
119 | 122 |
120 dxsdk_dir = os.environ.get('DXSDK_DIR') | 123 dxsdk_dir = os.environ.get('DXSDK_DIR') |
121 if not dxsdk_dir: | 124 if not dxsdk_dir: |
122 # Setup params to pass to and attempt to launch reg.exe. | 125 # Setup params to pass to and attempt to launch reg.exe. |
123 cmd = ['reg.exe', 'query', r'HKLM\Software\Microsoft\DirectX', '/s'] | 126 cmd = ['reg.exe', 'query', r'HKLM\Software\Microsoft\DirectX', '/s'] |
124 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 127 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
125 for line in p.communicate()[0].splitlines(): | 128 for line in p.communicate()[0].splitlines(): |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
671 etc. on Windows, as those tools rely on .dlls being in the PATH. We also | 674 etc. on Windows, as those tools rely on .dlls being in the PATH. We also |
672 need to support both x86 and x64 compilers within the same build (to support | 675 need to support both x86 and x64 compilers within the same build (to support |
673 msvs_target_platform hackery). Different architectures require a different | 676 msvs_target_platform hackery). Different architectures require a different |
674 compiler binary, and different supporting environment variables (INCLUDE, | 677 compiler binary, and different supporting environment variables (INCLUDE, |
675 LIB, LIBPATH). So, we extract the environment here, wrap all invocations | 678 LIB, LIBPATH). So, we extract the environment here, wrap all invocations |
676 of compiler tools (cl, link, lib, rc, midl, etc.) via win_tool.py which | 679 of compiler tools (cl, link, lib, rc, midl, etc.) via win_tool.py which |
677 sets up the environment, and then we do not prefix the compiler with | 680 sets up the environment, and then we do not prefix the compiler with |
678 an absolute path, instead preferring something like "cl.exe" in the rule | 681 an absolute path, instead preferring something like "cl.exe" in the rule |
679 which will then run whichever the environment setup has put in the path.""" | 682 which will then run whichever the environment setup has put in the path.""" |
680 vs = GetVSVersion(generator_flags) | 683 vs = GetVSVersion(generator_flags) |
684 if sys.platform not in ('win32', 'cygwin'): | |
685 return | |
681 for arch in ('x86', 'x64'): | 686 for arch in ('x86', 'x64'): |
682 args = vs.SetupScript(arch) | 687 args = vs.SetupScript(arch) |
683 args.extend(('&&', 'set')) | 688 args.extend(('&&', 'set')) |
684 popen = subprocess.Popen( | 689 popen = subprocess.Popen( |
685 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 690 args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
686 variables, _ = popen.communicate() | 691 variables, _ = popen.communicate() |
687 env = _ExtractImportantEnvironment(variables) | 692 env = _ExtractImportantEnvironment(variables) |
688 env_block = _FormatAsEnvironmentBlock(env) | 693 env_block = _FormatAsEnvironmentBlock(env) |
689 f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb') | 694 f = open_out(os.path.join(toplevel_build_dir, 'environment.' + arch), 'wb') |
690 f.write(env_block) | 695 f.write(env_block) |
691 f.close() | 696 f.close() |
OLD | NEW |