summaryrefslogtreecommitdiff
path: root/engine/SCons/Tool/MSCommon/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'engine/SCons/Tool/MSCommon/common.py')
-rw-r--r--engine/SCons/Tool/MSCommon/common.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/engine/SCons/Tool/MSCommon/common.py b/engine/SCons/Tool/MSCommon/common.py
index 219e680..d7d3b79 100644
--- a/engine/SCons/Tool/MSCommon/common.py
+++ b/engine/SCons/Tool/MSCommon/common.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/MSCommon/common.py 4577 2009/12/27 19:43:56 scons"
+__revision__ = "src/engine/SCons/Tool/MSCommon/common.py 4629 2010/01/17 22:23:21 scons"
__doc__ = """
Common helper functions for working with the Microsoft tool chain.
@@ -60,12 +60,27 @@ def is_win64():
# Unfortunately, python does not provide a useful way to determine
# if the underlying Windows OS is 32-bit or 64-bit. Worse, whether
# the Python itself is 32-bit or 64-bit affects what it returns,
- # so nothing in sys.* or os.* help. So we go to the registry to
- # look directly for a clue from Windows, caching the result to
- # avoid repeated registry calls.
+ # so nothing in sys.* or os.* help.
+
+ # Apparently the best solution is to use env vars that Windows
+ # sets. If PROCESSOR_ARCHITECTURE is not x86, then the python
+ # process is running in 64 bit mode (on a 64-bit OS, 64-bit
+ # hardware, obviously).
+ # If this python is 32-bit but the OS is 64, Windows will set
+ # ProgramW6432 and PROCESSOR_ARCHITEW6432 to non-null.
+ # (Checking for HKLM\Software\Wow6432Node in the registry doesn't
+ # work, because some 32-bit installers create it.)
global _is_win64
if _is_win64 is None:
- _is_win64 = has_reg(r"Software\Wow6432Node")
+ # I structured these tests to make it easy to add new ones or
+ # add exceptions in the future, because this is a bit fragile.
+ _is_win64 = False
+ if os.environ.get('PROCESSOR_ARCHITECTURE','x86') != 'x86':
+ _is_win64 = True
+ if os.environ.get('PROCESSOR_ARCHITEW6432'):
+ _is_win64 = True
+ if os.environ.get('ProgramW6432'):
+ _is_win64 = True
return _is_win64