예제 #1
0
def platform_fix_name(fname, compiler, env):
    # canonicalize compiler
    if compiler == 'clang-cl':
        canonical_compiler = 'msvc'
    else:
        canonical_compiler = compiler

    if '?lib' in fname:
        if mesonlib.for_windows(env.is_cross_build(),
                                env) and canonical_compiler == 'msvc':
            fname = re.sub(r'lib/\?lib(.*)\.', r'bin/\1.', fname)
            fname = re.sub(r'/\?lib/', r'/bin/', fname)
        elif mesonlib.for_windows(env.is_cross_build(), env):
            fname = re.sub(r'lib/\?lib(.*)\.', r'bin/lib\1.', fname)
            fname = re.sub(r'\?lib(.*)\.dll$', r'lib\1.dll', fname)
            fname = re.sub(r'/\?lib/', r'/bin/', fname)
        elif mesonlib.for_cygwin(env.is_cross_build(), env):
            fname = re.sub(r'lib/\?lib(.*)\.so$', r'bin/cyg\1.dll', fname)
            fname = re.sub(r'lib/\?lib(.*)\.', r'bin/cyg\1.', fname)
            fname = re.sub(r'\?lib(.*)\.dll$', r'cyg\1.dll', fname)
            fname = re.sub(r'/\?lib/', r'/bin/', fname)
        else:
            fname = re.sub(r'\?lib', 'lib', fname)

    if fname.endswith('?exe'):
        fname = fname[:-4]
        if mesonlib.for_windows(env.is_cross_build(),
                                env) or mesonlib.for_cygwin(
                                    env.is_cross_build(), env):
            return fname + '.exe'

    if fname.startswith('?msvc:'):
        fname = fname[6:]
        if canonical_compiler != 'msvc':
            return None

    if fname.startswith('?gcc:'):
        fname = fname[5:]
        if canonical_compiler == 'msvc':
            return None

    if fname.startswith('?cygwin:'):
        fname = fname[8:]
        if not mesonlib.for_cygwin(env.is_cross_build(), env):
            return None

    if fname.endswith('?so'):
        if mesonlib.for_windows(env.is_cross_build(),
                                env) and canonical_compiler == 'msvc':
            fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname)
            fname = re.sub(r'/(?:lib|)([^/]*?)\?so$', r'/\1.dll', fname)
            return fname
        elif mesonlib.for_windows(env.is_cross_build(), env):
            fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname)
            fname = re.sub(r'/([^/]*?)\?so$', r'/\1.dll', fname)
            return fname
        elif mesonlib.for_cygwin(env.is_cross_build(), env):
            fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname)
            fname = re.sub(r'/lib([^/]*?)\?so$', r'/cyg\1.dll', fname)
            fname = re.sub(r'/([^/]*?)\?so$', r'/\1.dll', fname)
            return fname
        elif mesonlib.for_darwin(env.is_cross_build(), env):
            return fname[:-3] + '.dylib'
        else:
            return fname[:-3] + '.so'

    if fname.endswith('?implib') or fname.endswith('?implibempty'):
        if mesonlib.for_windows(env.is_cross_build(),
                                env) and canonical_compiler == 'msvc':
            # only MSVC doesn't generate empty implibs
            if fname.endswith('?implibempty') and compiler == 'msvc':
                return None
            return re.sub(r'/(?:lib|)([^/]*?)\?implib(?:empty|)$', r'/\1.lib',
                          fname)
        elif mesonlib.for_windows(env.is_cross_build(),
                                  env) or mesonlib.for_cygwin(
                                      env.is_cross_build(), env):
            return re.sub(r'\?implib(?:empty|)$', r'.dll.a', fname)
        else:
            return None

    return fname
예제 #2
0
def platform_fix_name(fname, compiler, env):
    # canonicalize compiler
    if compiler == 'clang-cl':
        canonical_compiler = 'msvc'
    else:
        canonical_compiler = compiler

    if '?lib' in fname:
        if mesonlib.for_windows(env.is_cross_build(), env) and canonical_compiler == 'msvc':
            fname = re.sub(r'lib/\?lib(.*)\.', r'bin/\1.', fname)
            fname = re.sub(r'/\?lib/', r'/bin/', fname)
        elif mesonlib.for_windows(env.is_cross_build(), env):
            fname = re.sub(r'lib/\?lib(.*)\.', r'bin/lib\1.', fname)
            fname = re.sub(r'\?lib(.*)\.dll$', r'lib\1.dll', fname)
            fname = re.sub(r'/\?lib/', r'/bin/', fname)
        elif mesonlib.for_cygwin(env.is_cross_build(), env):
            fname = re.sub(r'lib/\?lib(.*)\.so$', r'bin/cyg\1.dll', fname)
            fname = re.sub(r'lib/\?lib(.*)\.', r'bin/cyg\1.', fname)
            fname = re.sub(r'\?lib(.*)\.dll$', r'cyg\1.dll', fname)
            fname = re.sub(r'/\?lib/', r'/bin/', fname)
        else:
            fname = re.sub(r'\?lib', 'lib', fname)

    if fname.endswith('?exe'):
        fname = fname[:-4]
        if mesonlib.for_windows(env.is_cross_build(), env) or mesonlib.for_cygwin(env.is_cross_build(), env):
            return fname + '.exe'

    if fname.startswith('?msvc:'):
        fname = fname[6:]
        if canonical_compiler != 'msvc':
            return None

    if fname.startswith('?gcc:'):
        fname = fname[5:]
        if canonical_compiler == 'msvc':
            return None

    if fname.startswith('?cygwin:'):
        fname = fname[8:]
        if not mesonlib.for_cygwin(env.is_cross_build(), env):
            return None

    if fname.endswith('?so'):
        if mesonlib.for_windows(env.is_cross_build(), env) and canonical_compiler == 'msvc':
            fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname)
            fname = re.sub(r'/(?:lib|)([^/]*?)\?so$', r'/\1.dll', fname)
            return fname
        elif mesonlib.for_windows(env.is_cross_build(), env):
            fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname)
            fname = re.sub(r'/([^/]*?)\?so$', r'/\1.dll', fname)
            return fname
        elif mesonlib.for_cygwin(env.is_cross_build(), env):
            fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname)
            fname = re.sub(r'/lib([^/]*?)\?so$', r'/cyg\1.dll', fname)
            fname = re.sub(r'/([^/]*?)\?so$', r'/\1.dll', fname)
            return fname
        elif mesonlib.for_darwin(env.is_cross_build(), env):
            return fname[:-3] + '.dylib'
        else:
            return fname[:-3] + '.so'

    if fname.endswith('?implib') or fname.endswith('?implibempty'):
        if mesonlib.for_windows(env.is_cross_build(), env) and canonical_compiler == 'msvc':
            # only MSVC doesn't generate empty implibs
            if fname.endswith('?implibempty') and compiler == 'msvc':
                return None
            return re.sub(r'/(?:lib|)([^/]*?)\?implib(?:empty|)$', r'/\1.lib', fname)
        elif mesonlib.for_windows(env.is_cross_build(), env) or mesonlib.for_cygwin(env.is_cross_build(), env):
            return re.sub(r'\?implib(?:empty|)$', r'.dll.a', fname)
        else:
            return None

    return fname