Commits

Anonymous committed 13d60fe

Added experimental Clang and ICC compiler support.

Comments (0)

Files changed (5)

config/__init__.py

+import config.distutilsext
+
 __all__ = [ "config_modules", "config_darwin", "config_msys", "config_unix",
-            "config_win", "dll", "helpers", "mingw32ccompiler",
-            "mingw32distutils", "mingwcfg", "msys", "msysio", "libconfig" ]
+            "config_win", "dll", "helpers", "intelccompiler", "llvmccompiler",
+            "mingw32ccompiler", "distutilsext", "mingwcfg", "msys", "msysio",
+            "libconfig" ]

config/clangccompiler.py

+"""A simple Intel C compiler class for Unix-based systems."""
+
+from distutils.unixccompiler import UnixCCompiler
+import distutils.sysconfig  as sysconfig
+
+class ClangCCompiler(UnixCCompiler):
+    """ClangCCompiler (verbose=0, dry_run=0, force=0) -> LLVMCCompiler
+    
+    A simple compiler class for the clang frontent of the LLVM Compiler
+    infrastructure.
+    """
+    compiler_type = 'clang'
+
+    def __init__ (self, verbose=0, dry_run=0, force=0):
+        UnixCCompiler.__init__ (self, verbose, dry_run, force)
+        cc = 'clang'
+
+        cflags = sysconfig.get_config_var ('CFLAGS')
+        cshared = sysconfig.get_config_var ('CCSHARED')
+        ldflags = sysconfig.get_config_var ('LDFLAGS')
+
+        self.set_executables(compiler=cc + ' ' + cflags,
+                             compiler_so=cc + ' ' + cflags + ' ' + cshared,
+                             compiler_cxx=cc,
+                             linker_exe=cc + ' ' + ldflags,
+                             linker_so=cc + ' -shared')

config/distutilsext.py

+"""Enhance distutils by various compilers."""
+
+from distutils import ccompiler
+from distutils.errors import DistutilsModuleError
+
+# Add the compiler classes to the ccompiler table. Unfortunate hacks
+# follow.
+compiler_class = ccompiler.compiler_class
+value = compiler_class['mingw32']
+assert len(value) == 3, "distutils.ccompiler.compiler_class has changed"
+
+compiler_class['mingw32'] = ("mingw32ccompiler", "MinGW32CCompiler",
+                             value[2] + ", Win32 GUI shared libraries defaullt")
+compiler_class['mingw32-console'] = ("mingw32ccompiler", "MinGW32CCompiler",
+                                     value[2] + ", console shared libraries")
+compiler_class['icc'] = ("intelccompiler", "IntelCCompiler", "Intel C Compiler")
+compiler_class['clang'] = ("clangccompiler", "ClangCCompiler",
+                           "Clang LLVM C Compiler")
+
+original_new_compiler = ccompiler.new_compiler
+def new_compiler (plat=None,
+                  compiler=None,
+                  verbose=0,
+                  dry_run=0,
+                  force=0):
+    """Recognizes replacement mingw32 compiler classes"""
+
+    if compiler == 'mingw32':
+        from config.mingw32ccompiler import Mingw32DefaultCCompiler
+        return Mingw32DefaultCCompiler (None, dry_run, force)
+    if compiler == 'mingw32-console':
+        from config.mingw32ccompiler import Mingw32ConsoleCCompiler
+        return Mingw32ConsoleCCompiler (None, dry_run, force)
+    if compiler == 'icc':
+        from config.intelccompiler import IntelCCompiler
+        return IntelCCompiler (None, dry_run, force)
+    if compiler == 'clang':
+        from config.clangccompiler import ClangCCompiler
+        return ClangCCompiler (None, dry_run, force)
+    return original_new_compiler (plat, compiler, verbose, dry_run, force)
+
+ccompiler.new_compiler = new_compiler

config/intelccompiler.py

+"""A simple Intel C compiler class for Unix-based systems."""
+
+from distutils.unixccompiler import UnixCCompiler
+
+class IntelCCompiler(UnixCCompiler):
+    """IntelCCompiler (verbose=0, dry_run=0, force=0) -> IntelCCompiler
+    
+    A simple compiler class for Intel's C compiler.
+    """
+    compiler_type = 'intel'
+
+    def __init__ (self, verbose=0, dry_run=0, force=0):
+        UnixCCompiler.__init__ (self, verbose, dry_run, force)
+        cc = 'icc'
+        self.set_executables(compiler=cc,
+                             compiler_so=cc,
+                             compiler_cxx=cc,
+                             linker_exe=cc,
+                             linker_so=cc + ' -shared')

config/mingw32distutils.py

-# module mingw32distutils.py
-# Requires Python 2.1 or better.
-
-"""Enhance distutils mingw32 compilation by adding Win32 GUI/console support."""
-
-from distutils import ccompiler
-from distutils.errors import DistutilsModuleError
-
-compilers = ['mingw32', 'mingw32-console']
-
-# Add the compiler classes to the ccompiler table. Unfortunate hacks follow.
-
-compiler_class = ccompiler.compiler_class
-value = compiler_class['mingw32']
-assert len(value) == 3, "distutils.ccompiler.compiler_class has changed"
-compiler_class['mingw32'] = ('', '',
-                             value[2] + ", Win32 GUI shared libraries defaullt")
-compiler_class['mingw32-console'] = ('', '',
-                                     value[2] + ", console shared libraries")
-
-original_new_compiler = ccompiler.new_compiler
-def new_compiler (plat=None,
-                  compiler=None,
-                  verbose=0,
-                  dry_run=0,
-                  force=0):
-    """Recognizes replacement mingw32 compiler classes"""
-
-    if compiler == 'mingw32':
-        from config.mingw32ccompiler import Mingw32DefaultCCompiler
-        return Mingw32DefaultCCompiler (None, dry_run, force)
-    if compiler == 'mingw32-console':
-        from config.mingw32ccompiler import Mingw32ConsoleCCompiler
-        return Mingw32ConsoleCCompiler (None, dry_run, force)
-    return original_new_compiler (plat, compiler, verbose, dry_run, force)
-
-ccompiler.new_compiler = new_compiler