Use `env.machines.*` to avoid some `is_cross`

This is a small example of the `is_cross` removal the that abstraction
enables.
pull/4010/head
John Ericson 7 years ago committed by John Ericson
parent 69005d6b1d
commit 32e827dcdc
  1. 4
      mesonbuild/backend/backends.py
  2. 4
      mesonbuild/backend/ninjabackend.py
  3. 20
      mesonbuild/build.py
  4. 21
      mesonbuild/compilers/clike.py
  5. 16
      mesonbuild/dependencies/boost.py
  6. 19
      mesonbuild/environment.py
  7. 60
      mesonbuild/mesonlib.py
  8. 24
      run_project_tests.py

@ -743,8 +743,8 @@ class Backend:
exe_wrapper = self.environment.get_exe_wrapper() exe_wrapper = self.environment.get_exe_wrapper()
else: else:
exe_wrapper = None exe_wrapper = None
if mesonlib.for_windows(is_cross, self.environment) or \ if mesonlib.for_windows(self.environment) or \
mesonlib.for_cygwin(is_cross, self.environment): mesonlib.for_cygwin(self.environment):
extra_bdeps = [] extra_bdeps = []
if isinstance(exe, build.CustomTarget): if isinstance(exe, build.CustomTarget):
extra_bdeps = exe.get_transitive_build_target_deps() extra_bdeps = exe.get_transitive_build_target_deps()

@ -665,8 +665,8 @@ int dummy;
# CustomTarget command needs extra paths first. # CustomTarget command needs extra paths first.
is_cross = self.environment.is_cross_build() and \ is_cross = self.environment.is_cross_build() and \
self.environment.need_exe_wrapper() self.environment.need_exe_wrapper()
if mesonlib.for_windows(is_cross, self.environment) or \ if mesonlib.for_windows(self.environment) or \
mesonlib.for_cygwin(is_cross, self.environment): mesonlib.for_cygwin(self.environment):
extra_bdeps = target.get_transitive_build_target_deps() extra_bdeps = target.get_transitive_build_target_deps()
extra_paths = self.determine_windows_extra_paths(target.command[0], extra_paths = self.determine_windows_extra_paths(target.command[0],
extra_bdeps, is_cross) extra_bdeps, is_cross)

@ -928,7 +928,7 @@ This will become a hard error in a future Meson release.''')
# You can't disable PIC on OS X. The compiler ignores -fno-PIC. # You can't disable PIC on OS X. The compiler ignores -fno-PIC.
# PIC is always on for Windows (all code is position-independent # PIC is always on for Windows (all code is position-independent
# since library loading is done differently) # since library loading is done differently)
if for_darwin(self.is_cross, self.environment) or for_windows(self.is_cross, self.environment): if for_darwin(self.environment) or for_windows(self.environment):
self.pic = True self.pic = True
else: else:
self.pic = self._extract_pic_pie(kwargs, 'pic') self.pic = self._extract_pic_pie(kwargs, 'pic')
@ -1253,7 +1253,7 @@ You probably should put it in link_with instead.''')
''' '''
for link_target in self.link_targets: for link_target in self.link_targets:
if isinstance(link_target, SharedModule): if isinstance(link_target, SharedModule):
if for_darwin(self.is_cross, self.environment): if for_darwin(self.environment):
raise MesonException('''target links against shared modules. raise MesonException('''target links against shared modules.
This is not permitted on OSX''') This is not permitted on OSX''')
else: else:
@ -1436,8 +1436,8 @@ class Executable(BuildTarget):
self.prefix = '' self.prefix = ''
if not hasattr(self, 'suffix'): if not hasattr(self, 'suffix'):
# Executable for Windows or C#/Mono # Executable for Windows or C#/Mono
if (for_windows(is_cross, environment) or if (for_windows(environment) or
for_cygwin(is_cross, environment) or 'cs' in self.compilers): for_cygwin(environment) or 'cs' in self.compilers):
self.suffix = 'exe' self.suffix = 'exe'
elif ('c' in self.compilers and self.compilers['c'].get_id().startswith('arm') or elif ('c' in self.compilers and self.compilers['c'].get_id().startswith('arm') or
'cpp' in self.compilers and self.compilers['cpp'].get_id().startswith('arm')): 'cpp' in self.compilers and self.compilers['cpp'].get_id().startswith('arm')):
@ -1475,7 +1475,7 @@ class Executable(BuildTarget):
implib_basename = self.name + '.exe' implib_basename = self.name + '.exe'
if not isinstance(kwargs.get('implib', False), bool): if not isinstance(kwargs.get('implib', False), bool):
implib_basename = kwargs['implib'] implib_basename = kwargs['implib']
if for_windows(is_cross, environment) or for_cygwin(is_cross, environment): if for_windows(environment) or for_cygwin(environment):
self.vs_import_filename = '{0}.lib'.format(implib_basename) self.vs_import_filename = '{0}.lib'.format(implib_basename)
self.gcc_import_filename = 'lib{0}.a'.format(implib_basename) self.gcc_import_filename = 'lib{0}.a'.format(implib_basename)
if self.get_using_msvc(): if self.get_using_msvc():
@ -1652,7 +1652,7 @@ class SharedLibrary(BuildTarget):
# C, C++, Swift, Vala # C, C++, Swift, Vala
# Only Windows uses a separate import library for linking # Only Windows uses a separate import library for linking
# For all other targets/platforms import_filename stays None # For all other targets/platforms import_filename stays None
elif for_windows(is_cross, env): elif for_windows(env):
suffix = 'dll' suffix = 'dll'
self.vs_import_filename = '{0}{1}.lib'.format(self.prefix if self.prefix is not None else '', self.name) self.vs_import_filename = '{0}{1}.lib'.format(self.prefix if self.prefix is not None else '', self.name)
self.gcc_import_filename = '{0}{1}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name) self.gcc_import_filename = '{0}{1}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name)
@ -1677,7 +1677,7 @@ class SharedLibrary(BuildTarget):
self.filename_tpl = '{0.prefix}{0.name}-{0.soversion}.{0.suffix}' self.filename_tpl = '{0.prefix}{0.name}-{0.soversion}.{0.suffix}'
else: else:
self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}' self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
elif for_cygwin(is_cross, env): elif for_cygwin(env):
suffix = 'dll' suffix = 'dll'
self.gcc_import_filename = '{0}{1}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name) self.gcc_import_filename = '{0}{1}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name)
# Shared library is of the form cygfoo.dll # Shared library is of the form cygfoo.dll
@ -1689,7 +1689,7 @@ class SharedLibrary(BuildTarget):
self.filename_tpl = '{0.prefix}{0.name}-{0.soversion}.{0.suffix}' self.filename_tpl = '{0.prefix}{0.name}-{0.soversion}.{0.suffix}'
else: else:
self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}' self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
elif for_darwin(is_cross, env): elif for_darwin(env):
prefix = 'lib' prefix = 'lib'
suffix = 'dylib' suffix = 'dylib'
# On macOS, the filename can only contain the major version # On macOS, the filename can only contain the major version
@ -1699,7 +1699,7 @@ class SharedLibrary(BuildTarget):
else: else:
# libfoo.dylib # libfoo.dylib
self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}' self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
elif for_android(is_cross, env): elif for_android(env):
prefix = 'lib' prefix = 'lib'
suffix = 'so' suffix = 'so'
# Android doesn't support shared_library versioning # Android doesn't support shared_library versioning
@ -1764,7 +1764,7 @@ class SharedLibrary(BuildTarget):
def process_kwargs(self, kwargs, environment): def process_kwargs(self, kwargs, environment):
super().process_kwargs(kwargs, environment) super().process_kwargs(kwargs, environment)
if not for_android(self.is_cross, self.environment): if not for_android(self.environment):
supports_versioning = True supports_versioning = True
else: else:
supports_versioning = False supports_versioning = False

@ -274,9 +274,10 @@ class CLikeCompiler:
return [] return []
def gen_export_dynamic_link_args(self, env): def gen_export_dynamic_link_args(self, env):
if mesonlib.for_windows(env.is_cross_build(), env) or mesonlib.for_cygwin(env.is_cross_build(), env): m = env.machines[self.for_machine]
if m.is_windows() or m.is_cygwin():
return ['-Wl,--export-all-symbols'] return ['-Wl,--export-all-symbols']
elif mesonlib.for_darwin(env.is_cross_build(), env): elif mesonlib.for_darwin(env):
return [] return []
else: else:
return ['-Wl,-export-dynamic'] return ['-Wl,-export-dynamic']
@ -884,7 +885,7 @@ class CLikeCompiler:
for p in prefixes: for p in prefixes:
for s in suffixes: for s in suffixes:
patterns.append(p + '{}.' + s) patterns.append(p + '{}.' + s)
if shared and mesonlib.for_openbsd(self.is_cross, env): if shared and mesonlib.for_openbsd(env):
# Shared libraries on OpenBSD can be named libfoo.so.X.Y: # Shared libraries on OpenBSD can be named libfoo.so.X.Y:
# https://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs # https://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs
# #
@ -911,9 +912,9 @@ class CLikeCompiler:
else: else:
prefixes = ['lib', ''] prefixes = ['lib', '']
# Library suffixes and prefixes # Library suffixes and prefixes
if mesonlib.for_darwin(env.is_cross_build(), env): if mesonlib.for_darwin(env):
shlibext = ['dylib', 'so'] shlibext = ['dylib', 'so']
elif mesonlib.for_windows(env.is_cross_build(), env): elif mesonlib.for_windows(env):
# FIXME: .lib files can be import or static so we should read the # FIXME: .lib files can be import or static so we should read the
# file, figure out which one it is, and reject the wrong kind. # file, figure out which one it is, and reject the wrong kind.
if isinstance(self, compilers.VisualStudioLikeCompiler): if isinstance(self, compilers.VisualStudioLikeCompiler):
@ -922,7 +923,7 @@ class CLikeCompiler:
shlibext = ['dll.a', 'lib', 'dll'] shlibext = ['dll.a', 'lib', 'dll']
# Yep, static libraries can also be foo.lib # Yep, static libraries can also be foo.lib
stlibext += ['lib'] stlibext += ['lib']
elif mesonlib.for_cygwin(env.is_cross_build(), env): elif mesonlib.for_cygwin(env):
shlibext = ['dll', 'dll.a'] shlibext = ['dll', 'dll.a']
prefixes = ['cyg'] + prefixes prefixes = ['cyg'] + prefixes
else: else:
@ -1126,12 +1127,12 @@ class CLikeCompiler:
return self.find_framework_impl(name, env, extra_dirs, allow_system) return self.find_framework_impl(name, env, extra_dirs, allow_system)
def thread_flags(self, env): def thread_flags(self, env):
if mesonlib.for_haiku(self.is_cross, env) or mesonlib.for_darwin(self.is_cross, env): if mesonlib.for_haiku(env) or mesonlib.for_darwin(env):
return [] return []
return ['-pthread'] return ['-pthread']
def thread_link_flags(self, env): def thread_link_flags(self, env):
if mesonlib.for_haiku(self.is_cross, env) or mesonlib.for_darwin(self.is_cross, env): if mesonlib.for_haiku(env) or mesonlib.for_darwin(env):
return [] return []
return ['-pthread'] return ['-pthread']
@ -1189,8 +1190,8 @@ class CLikeCompiler:
def has_func_attribute(self, name, env): def has_func_attribute(self, name, env):
# Just assume that if we're not on windows that dllimport and dllexport # Just assume that if we're not on windows that dllimport and dllexport
# don't work # don't work
if not (mesonlib.for_windows(env.is_cross_build(), env) or if not (mesonlib.for_windows(env) or
mesonlib.for_cygwin(env.is_cross_build(), env)): mesonlib.for_cygwin(env)):
if name in ['dllimport', 'dllexport']: if name in ['dllimport', 'dllexport']:
return False, False return False, False

@ -123,13 +123,13 @@ class BoostDependency(ExternalDependency):
self.libdir = os.environ['BOOST_LIBRARYDIR'] self.libdir = os.environ['BOOST_LIBRARYDIR']
if self.boost_root is None: if self.boost_root is None:
if mesonlib.for_windows(self.want_cross, self.env): if mesonlib.for_windows(self.env):
self.boost_roots = self.detect_win_roots() self.boost_roots = self.detect_win_roots()
else: else:
self.boost_roots = self.detect_nix_roots() self.boost_roots = self.detect_nix_roots()
if self.incdir is None: if self.incdir is None:
if mesonlib.for_windows(self.want_cross, self.env): if mesonlib.for_windows(self.env):
self.incdir = self.detect_win_incdir() self.incdir = self.detect_win_incdir()
else: else:
self.incdir = self.detect_nix_incdir() self.incdir = self.detect_nix_incdir()
@ -268,7 +268,7 @@ class BoostDependency(ExternalDependency):
pass pass
# 2. Fall back to the old method # 2. Fall back to the old method
else: else:
if mesonlib.for_windows(self.want_cross, self.env): if mesonlib.for_windows(self.env):
self.detect_lib_modules_win() self.detect_lib_modules_win()
else: else:
self.detect_lib_modules_nix() self.detect_lib_modules_nix()
@ -290,7 +290,7 @@ class BoostDependency(ExternalDependency):
def compiler_tag(self): def compiler_tag(self):
tag = None tag = None
compiler = self.env.detect_cpp_compiler(self.want_cross) compiler = self.env.detect_cpp_compiler(self.want_cross)
if mesonlib.for_windows(self.want_cross, self.env): if mesonlib.for_windows(self.env):
if compiler.get_id() in ['msvc', 'clang-cl']: if compiler.get_id() in ['msvc', 'clang-cl']:
comp_ts_version = compiler.get_toolset_version() comp_ts_version = compiler.get_toolset_version()
compiler_ts = comp_ts_version.split('.') compiler_ts = comp_ts_version.split('.')
@ -304,10 +304,10 @@ class BoostDependency(ExternalDependency):
if not self.is_multithreading: if not self.is_multithreading:
return '' return ''
if mesonlib.for_darwin(self.want_cross, self.env): if mesonlib.for_darwin(self.env):
# - Mac: requires -mt for multithreading, so should not fall back to non-mt libraries. # - Mac: requires -mt for multithreading, so should not fall back to non-mt libraries.
return '-mt' return '-mt'
elif mesonlib.for_windows(self.want_cross, self.env): elif mesonlib.for_windows(self.env):
# - Windows: requires -mt for multithreading, so should not fall back to non-mt libraries. # - Windows: requires -mt for multithreading, so should not fall back to non-mt libraries.
return '-mt' return '-mt'
else: else:
@ -340,7 +340,7 @@ class BoostDependency(ExternalDependency):
# FIXME - how to handle different distributions, e.g. for Mac? Currently we handle homebrew and macports, but not fink. # FIXME - how to handle different distributions, e.g. for Mac? Currently we handle homebrew and macports, but not fink.
def abi_tags(self): def abi_tags(self):
if mesonlib.for_windows(self.want_cross, self.env): if mesonlib.for_windows(self.env):
return [self.versioned_abi_tag(), self.threading_tag()] return [self.versioned_abi_tag(), self.threading_tag()]
else: else:
return [self.threading_tag()] return [self.threading_tag()]
@ -437,7 +437,7 @@ class BoostDependency(ExternalDependency):
def detect_lib_modules_nix(self): def detect_lib_modules_nix(self):
if self.static: if self.static:
libsuffix = 'a' libsuffix = 'a'
elif mesonlib.for_darwin(self.want_cross, self.env): elif mesonlib.for_darwin(self.env):
libsuffix = 'dylib' libsuffix = 'dylib'
else: else:
libsuffix = 'so' libsuffix = 'so'

@ -513,12 +513,11 @@ class Environment:
# Various prefixes and suffixes for import libraries, shared libraries, # Various prefixes and suffixes for import libraries, shared libraries,
# static libraries, and executables. # static libraries, and executables.
# Versioning is added to these names in the backends as-needed. # Versioning is added to these names in the backends as-needed.
cross = self.is_cross_build() if mesonlib.for_windows(self):
if mesonlib.for_windows(cross, self):
self.exe_suffix = 'exe' self.exe_suffix = 'exe'
self.object_suffix = 'obj' self.object_suffix = 'obj'
self.win_libdir_layout = True self.win_libdir_layout = True
elif mesonlib.for_cygwin(cross, self): elif mesonlib.for_cygwin(self):
self.exe_suffix = 'exe' self.exe_suffix = 'exe'
self.object_suffix = 'o' self.object_suffix = 'o'
self.win_libdir_layout = True self.win_libdir_layout = True
@ -774,9 +773,9 @@ class Environment:
cls = ClangClCCompiler if lang == 'c' else ClangClCPPCompiler cls = ClangClCCompiler if lang == 'c' else ClangClCPPCompiler
return cls(compiler, version, is_cross, exe_wrap, target) return cls(compiler, version, is_cross, exe_wrap, target)
if 'clang' in out: if 'clang' in out:
if 'Apple' in out or mesonlib.for_darwin(want_cross, self): if 'Apple' in out or mesonlib.for_darwin(self):
compiler_type = CompilerType.CLANG_OSX compiler_type = CompilerType.CLANG_OSX
elif 'windows' in out or mesonlib.for_windows(want_cross, self): elif 'windows' in out or mesonlib.for_windows(self):
compiler_type = CompilerType.CLANG_MINGW compiler_type = CompilerType.CLANG_MINGW
else: else:
compiler_type = CompilerType.CLANG_STANDARD compiler_type = CompilerType.CLANG_STANDARD
@ -808,16 +807,16 @@ class Environment:
return cls(compiler, version, is_cross, exe_wrap, target) return cls(compiler, version, is_cross, exe_wrap, target)
if 'PGI Compilers' in out: if 'PGI Compilers' in out:
if mesonlib.for_darwin(want_cross, self): if self.machines[for_machine].is_darwin():
compiler_type = CompilerType.PGI_OSX compiler_type = CompilerType.PGI_OSX
elif mesonlib.for_windows(want_cross, self): elif self.machines[for_machine].is_windows():
compiler_type = CompilerType.PGI_WIN compiler_type = CompilerType.PGI_WIN
else: else:
compiler_type = CompilerType.PGI_STANDARD compiler_type = CompilerType.PGI_STANDARD
cls = PGICCompiler if lang == 'c' else PGICPPCompiler cls = PGICCompiler if lang == 'c' else PGICPPCompiler
return cls(ccache + compiler, version, compiler_type, is_cross, exe_wrap) return cls(ccache + compiler, version, compiler_type, is_cross, exe_wrap)
if '(ICC)' in out: if '(ICC)' in out:
if mesonlib.for_darwin(want_cross, self): if self.machine[for_macine].is_darwin():
compiler_type = CompilerType.ICC_OSX compiler_type = CompilerType.ICC_OSX
elif mesonlib.for_windows(want_cross, self): elif mesonlib.for_windows(want_cross, self):
# TODO: fix ICC on Windows # TODO: fix ICC on Windows
@ -932,9 +931,9 @@ class Environment:
return PathScaleFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version) return PathScaleFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version)
if 'PGI Compilers' in out: if 'PGI Compilers' in out:
if mesonlib.for_darwin(want_cross, self): if self.machine[for_macine].is_darwin():
compiler_type = CompilerType.PGI_OSX compiler_type = CompilerType.PGI_OSX
elif mesonlib.for_windows(want_cross, self): elif self.machines[for_machine].is_windows():
compiler_type = CompilerType.PGI_WIN compiler_type = CompilerType.PGI_WIN
else: else:
compiler_type = CompilerType.PGI_STANDARD compiler_type = CompilerType.PGI_STANDARD

@ -463,93 +463,75 @@ def is_dragonflybsd() -> bool:
def is_freebsd() -> bool: def is_freebsd() -> bool:
return platform.system().lower() == 'freebsd' return platform.system().lower() == 'freebsd'
def _get_machine_is_cross(env, is_cross): def for_windows(env):
"""
This is not morally correct, but works for now. For cross builds the build
and host machines differ. `is_cross == true` means the host machine, while
`is_cross == false` means the build machine. Both are used in practice,
even though the documentation refers to the host machine implying we should
hard-code it. For non-cross builds `is_cross == false` is passed but the
host and build machines are identical so it doesn't matter.
Users for `for_*` should instead specify up front which machine they want
and query that like:
env.machines[MachineChoice.HOST].is_haiku()
"""
for_machine = MachineChoice.HOST if is_cross else MachineChoice.BUILD
return env.machines[for_machine]
def for_windows(is_cross, env):
""" """
Host machine is windows? Host machine is windows?
Deprecated: Please use `env.machines[for_machine].is_windows()`. Deprecated: Please use `env.machines.host.is_windows()`.
Note: 'host' is the machine on which compiled binaries will run Note: 'host' is the machine on which compiled binaries will run
""" """
return _get_machine_is_cross(env, is_cross).is_windows() return env.machines.host.is_windows()
def for_cygwin(is_cross, env): def for_cygwin(env):
""" """
Host machine is cygwin? Host machine is cygwin?
Deprecated: Please use `env.machines[for_machine].is_cygwin()`. Deprecated: Please use `env.machines.host.is_cygwin()`.
Note: 'host' is the machine on which compiled binaries will run Note: 'host' is the machine on which compiled binaries will run
""" """
return _get_machine_is_cross(env, is_cross).is_cygwin() return env.machines.host.is_cygwin()
def for_linux(is_cross, env): def for_linux(env):
""" """
Host machine is linux? Host machine is linux?
Deprecated: Please use `env.machines[for_machine].is_linux()`. Deprecated: Please use `env.machines.host.is_linux()`.
Note: 'host' is the machine on which compiled binaries will run Note: 'host' is the machine on which compiled binaries will run
""" """
return _get_machine_is_cross(env, is_cross).is_linux() return env.machines.host.is_linux()
def for_darwin(is_cross, env): def for_darwin(env):
""" """
Host machine is Darwin (iOS/OS X)? Host machine is Darwin (iOS/OS X)?
Deprecated: Please use `env.machines[for_machine].is_darwin()`. Deprecated: Please use `env.machines.host.is_darwin()`.
Note: 'host' is the machine on which compiled binaries will run Note: 'host' is the machine on which compiled binaries will run
""" """
return _get_machine_is_cross(env, is_cross).is_darwin() return env.machines.host.is_darwin()
def for_android(is_cross, env): def for_android(env):
""" """
Host machine is Android? Host machine is Android?
Deprecated: Please use `env.machines[for_machine].is_android()`. Deprecated: Please use `env.machines.host.is_android()`.
Note: 'host' is the machine on which compiled binaries will run Note: 'host' is the machine on which compiled binaries will run
""" """
return _get_machine_is_cross(env, is_cross).is_android() return env.machines.host.is_android()
def for_haiku(is_cross, env): def for_haiku(env):
""" """
Host machine is Haiku? Host machine is Haiku?
Deprecated: Please use `env.machines[for_machine].is_haiku()`. Deprecated: Please use `env.machines.host.is_haiku()`.
Note: 'host' is the machine on which compiled binaries will run Note: 'host' is the machine on which compiled binaries will run
""" """
return _get_machine_is_cross(env, is_cross).is_haiku() return env.machines.host.is_haiku()
def for_openbsd(is_cross, env): def for_openbsd(env):
""" """
Host machine is OpenBSD? Host machine is OpenBSD?
Deprecated: Please use `env.machines[for_machine].is_openbsd()`. Deprecated: Please use `env.machines.host.is_openbsd()`.
Note: 'host' is the machine on which compiled binaries will run Note: 'host' is the machine on which compiled binaries will run
""" """
return _get_machine_is_cross(env, is_cross).is_openbsd() return env.machines.host.is_openbsd()
def exe_exists(arglist: List[str]) -> bool: def exe_exists(arglist: List[str]) -> bool:
try: try:

@ -126,14 +126,14 @@ def platform_fix_name(fname, compiler, env):
canonical_compiler = compiler canonical_compiler = compiler
if '?lib' in fname: if '?lib' in fname:
if mesonlib.for_windows(env.is_cross_build(), env) and canonical_compiler == 'msvc': if env.machines.host.is_windows() and canonical_compiler == 'msvc':
fname = re.sub(r'lib/\?lib(.*)\.', r'bin/\1.', fname) fname = re.sub(r'lib/\?lib(.*)\.', r'bin/\1.', fname)
fname = re.sub(r'/\?lib/', r'/bin/', fname) fname = re.sub(r'/\?lib/', r'/bin/', fname)
elif mesonlib.for_windows(env.is_cross_build(), env): elif env.machines.host.is_windows():
fname = re.sub(r'lib/\?lib(.*)\.', r'bin/lib\1.', fname) 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(.*)\.dll$', r'lib\1.dll', fname)
fname = re.sub(r'/\?lib/', r'/bin/', fname) fname = re.sub(r'/\?lib/', r'/bin/', fname)
elif mesonlib.for_cygwin(env.is_cross_build(), env): elif env.machines.host.is_cygwin():
fname = re.sub(r'lib/\?lib(.*)\.so$', r'bin/cyg\1.dll', fname) 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/\?lib(.*)\.', r'bin/cyg\1.', fname)
fname = re.sub(r'\?lib(.*)\.dll$', r'cyg\1.dll', fname) fname = re.sub(r'\?lib(.*)\.dll$', r'cyg\1.dll', fname)
@ -143,7 +143,7 @@ def platform_fix_name(fname, compiler, env):
if fname.endswith('?exe'): if fname.endswith('?exe'):
fname = fname[:-4] fname = fname[:-4]
if mesonlib.for_windows(env.is_cross_build(), env) or mesonlib.for_cygwin(env.is_cross_build(), env): if env.machines.host.is_windows() or env.machines.host.is_cygwin():
return fname + '.exe' return fname + '.exe'
if fname.startswith('?msvc:'): if fname.startswith('?msvc:'):
@ -158,40 +158,40 @@ def platform_fix_name(fname, compiler, env):
if fname.startswith('?cygwin:'): if fname.startswith('?cygwin:'):
fname = fname[8:] fname = fname[8:]
if not mesonlib.for_cygwin(env.is_cross_build(), env): if not env.machines.host.is_cygwin():
return None return None
if fname.startswith('?!cygwin:'): if fname.startswith('?!cygwin:'):
fname = fname[9:] fname = fname[9:]
if mesonlib.for_cygwin(env.is_cross_build(), env): if env.machines.host.is_cygwin():
return None return None
if fname.endswith('?so'): if fname.endswith('?so'):
if mesonlib.for_windows(env.is_cross_build(), env) and canonical_compiler == 'msvc': if env.machines.host.is_windows() and canonical_compiler == 'msvc':
fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname) fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname)
fname = re.sub(r'/(?:lib|)([^/]*?)\?so$', r'/\1.dll', fname) fname = re.sub(r'/(?:lib|)([^/]*?)\?so$', r'/\1.dll', fname)
return fname return fname
elif mesonlib.for_windows(env.is_cross_build(), env): elif env.machines.host.is_windows():
fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname) fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname)
fname = re.sub(r'/([^/]*?)\?so$', r'/\1.dll', fname) fname = re.sub(r'/([^/]*?)\?so$', r'/\1.dll', fname)
return fname return fname
elif mesonlib.for_cygwin(env.is_cross_build(), env): elif env.machines.host.is_cygwin():
fname = re.sub(r'lib/([^/]*)\?so$', r'bin/\1.dll', fname) 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'/lib([^/]*?)\?so$', r'/cyg\1.dll', fname)
fname = re.sub(r'/([^/]*?)\?so$', r'/\1.dll', fname) fname = re.sub(r'/([^/]*?)\?so$', r'/\1.dll', fname)
return fname return fname
elif mesonlib.for_darwin(env.is_cross_build(), env): elif env.machines.host.is_darwin():
return fname[:-3] + '.dylib' return fname[:-3] + '.dylib'
else: else:
return fname[:-3] + '.so' return fname[:-3] + '.so'
if fname.endswith('?implib') or fname.endswith('?implibempty'): if fname.endswith('?implib') or fname.endswith('?implibempty'):
if mesonlib.for_windows(env.is_cross_build(), env) and canonical_compiler == 'msvc': if env.machines.host.is_windows() and canonical_compiler == 'msvc':
# only MSVC doesn't generate empty implibs # only MSVC doesn't generate empty implibs
if fname.endswith('?implibempty') and compiler == 'msvc': if fname.endswith('?implibempty') and compiler == 'msvc':
return None return None
return re.sub(r'/(?:lib|)([^/]*?)\?implib(?:empty|)$', r'/\1.lib', fname) 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): elif env.machines.host.is_windows() or env.machines.host.is_cygwin():
return re.sub(r'\?implib(?:empty|)$', r'.dll.a', fname) return re.sub(r'\?implib(?:empty|)$', r'.dll.a', fname)
else: else:
return None return None

Loading…
Cancel
Save