Fix get_host_target()'s use of platform.machine() on Python versions
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 28 Nov 2009 06:17:41 +0000 (06:17 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 28 Nov 2009 06:17:41 +0000 (06:17 +0000)
before 2.6, when it always returns a null string.

git-svn-id: http://scons.tigris.org/svn/scons/trunk@4493 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Tool/MSCommon/vc.py

index 7ccb207b57f5aada3860ca2bb9ef72cd32d313e4..ac6e9b3a2f6beab2a41d7d13690fb1a2444588ac 100644 (file)
@@ -88,6 +88,11 @@ def get_host_target(env):
     host_platform = env.get('HOST_ARCH')
     if not host_platform:
         host_platform = platform.machine()
+        # TODO(2.5):  the native Python platform.machine() function returns
+        # '' on all Python versions before 2.6, after which it also uses
+        # PROCESSOR_ARCHITECTURE.
+        if not host_platform:
+            host_platform = os.environ.get('PROCESSOR_ARCHITECTURE', '')
     target_platform = env.get('TARGET_ARCH')
     if not target_platform:
         target_platform = host_platform
@@ -95,7 +100,8 @@ def get_host_target(env):
     try:
         host = _ARCH_TO_CANONICAL[host_platform]
     except KeyError, e:
-        raise ValueError("Unrecognized host architecture %s" % host_platform)
+        msg = "Unrecognized host architecture %s"
+        raise ValueError(msg % repr(host_platform))
 
     try:
         target = _ARCH_TO_CANONICAL[target_platform]