Ticket #68: built-in.conf.diff

File built-in.conf.diff, 2.1 KB (added by Nicolas Pouillon, 14 years ago)

First attempt

  • built-in.conf

     
    2525    Retrieves platform information and make it look-like systemc's
    2626    lib-xxx thing.
    2727    """
    28     import sys
    29     pf = sys.platform
     28    import os
    3029
    31     # Strip numeric suffix from platform name
    32     while pf[-1] in "0123456789":
    33         pf = pf[:-1]
     30    def _guess_directory():
     31        systemc = os.getenv('SYSTEMC')
     32        if systemc:
     33            for d in os.listdir(systemc):
     34                if d.startswith('lib-'):
     35                    return d[4:]
     36        return None
    3437
    35     if pf == 'darwin': pf = 'macosx'
    36     return pf
     38    def _suffix(triple):
     39        '''SystemC lib directory suffix oracle'''
     40        from fnmatch import fnmatch
     41        for pattern, value in (
     42            ("sparc-sun-solaris*",                'gccsparcOS5'),
     43            ("x86_64*linux*",                     'linux64'    ),
     44            ("*linux*",                           'linux'      ),
     45            ("i?86-apple-macosx*",                'macosx'     ),
     46            ("powerpc-apple-macosx*",             'macosx'     ),
     47            ("amd64*freebsd* | x86_64*freebsd*",  'freebsd64'  ),
     48            ("*freebsd*",                         'freebsd'    ),
     49            ("*cygwin*",                          'cygwin'     ),
     50            ("*mingw*",                           'mingw'      ),
     51            ("*hpux11*",                          'gcchpux11'  ),
     52            ):
     53            if fnmatch(triple, pattern):
     54                return value
     55        return None
    3756
     57    def _machine_triple():
     58        '''triple like the one produced by config.guess'''
     59        import subprocess
     60        try:
     61            proc = subprocess.Popen(['gcc', '-dumpmachine'], shell = False, stdout = subprocess.PIPE)
     62            out, err = proc.communicate()
     63        except:
     64            out = ''
     65        return out
     66
     67    return _suffix(_machine_triple()) or _guess_directory() or ''
     68
    3869config.systemc = Library(
    3970    name = 'systemc',
    4071    vendor = 'OSCI',