Dynamically check for the existence of utilities. (sam th)
[scons.git] / src / engine / SCons / Platform / __init__.py
index a519142460ba9e3f6ee0bb36a69112eea60745d0..2b35a2ea57ee607c4793691a83cec3e29e31dfbf 100644 (file)
@@ -52,24 +52,22 @@ import SCons.Errors
 
 def platform_default():
     """Return the platform string for our execution environment.
+
+    The returned value should map to one of the SCons/Platform/*.py
+    files.  Since we're architecture independent, though, we don't
+    care about the machine architecture.
     """
-    if sys.platform == 'win32':
-        return 'win32'
-    if os.name == 'cygwin':
-        return 'cygwin'
     if os.name == 'posix':
+        if sys.platform == 'cygwin':
+            return 'cygwin'
         return 'posix'
-    return None
-
-class PlatformSpec:
-    def __init__(self, name):
-        self.name = name
+    elif os.name == 'os2':
+        return 'os2'
+    else:
+        return sys.platform
 
-    def __str__(self):
-        return self.name
-    
-def Platform(name = platform_default()):
-    """Select a canned Platform specification.
+def platform_module(name = platform_default()):
+    """Return the imported module for the platform.
 
     This looks for a module name that matches the specified argument.
     If the name is unspecified, we fetch the appropriate default for
@@ -85,6 +83,25 @@ def Platform(name = platform_default()):
             raise SCons.Errors.UserError, "No platform named '%s'" % name
         if file:
             file.close()
+    return sys.modules[full_name]
+
+def DefaultToolList(name = platform_default()):
+    """Select a default tool list for the specified platform.
+    """
+    module = platform_module(name)
+    return SCons.Tool.tool_list()
+
+class PlatformSpec:
+    def __init__(self, name):
+        self.name = name
+
+    def __str__(self):
+        return self.name
+    
+def Platform(name = platform_default()):
+    """Select a canned Platform specification.
+    """
+    module = platform_module(name)
     spec = PlatformSpec(name)
-    spec.__call__ = sys.modules[full_name].generate
+    spec.__call__ = module.generate
     return spec