Rename clike_langs to clink_langs for clarity

D is not a 'c-like' language, but it can link to C libraries. The same
might be true of Rust in the future and Go when we add support for it.

This contains no functionality changes.
pull/3528/merge
Nirbheek Chauhan 6 years ago committed by Nirbheek Chauhan
parent d737488150
commit 58ae2c9a8c
  1. 2
      mesonbuild/backend/backends.py
  2. 24
      mesonbuild/build.py
  3. 8
      mesonbuild/compilers/__init__.py
  4. 22
      mesonbuild/compilers/compilers.py
  5. 2
      mesonbuild/dependencies/base.py
  6. 4
      mesonbuild/dependencies/misc.py
  7. 4
      mesonbuild/interpreter.py

@ -338,7 +338,7 @@ class Backend:
return self.build.static_cross_linker, []
else:
return self.build.static_linker, []
l, stdlib_args = target.get_clike_dynamic_linker_and_stdlibs()
l, stdlib_args = target.get_clink_dynamic_linker_and_stdlibs()
return l, stdlib_args
@staticmethod

@ -24,7 +24,7 @@ from .mesonlib import File, MesonException, listify, extract_as_list
from .mesonlib import typeslistify, stringlistify, classify_unity_sources
from .mesonlib import get_filenames_templates_dict, substitute_values
from .mesonlib import for_windows, for_darwin, for_cygwin, for_android, has_path_sep
from .compilers import is_object, clike_langs, sort_clike, lang_suffixes
from .compilers import is_object, clink_langs, sort_clink, lang_suffixes
from .interpreterbase import FeatureNew, FeatureNewKwargs
pch_kwargs = set(['c_pch', 'cpp_pch'])
@ -490,16 +490,16 @@ class BuildTarget(Target):
extra = set()
for t in itertools.chain(self.link_targets, self.link_whole_targets):
for name, compiler in t.compilers.items():
if name in clike_langs:
if name in clink_langs:
extra.add((name, compiler))
for name, compiler in sorted(extra, key=lambda p: sort_clike(p[0])):
for name, compiler in sorted(extra, key=lambda p: sort_clink(p[0])):
self.compilers[name] = compiler
if not self.compilers:
# No source files or parent targets, target consists of only object
# files of unknown origin. Just add the first clike compiler
# files of unknown origin. Just add the first clink compiler
# that we have and hope that it can link these objects
for lang in clike_langs:
for lang in clink_langs:
if lang in compilers:
self.compilers[lang] = compilers[lang]
break
@ -556,9 +556,9 @@ class BuildTarget(Target):
if lang not in self.compilers:
self.compilers[lang] = compiler
break
# Re-sort according to clike_langs
# Re-sort according to clink_langs
self.compilers = OrderedDict(sorted(self.compilers.items(),
key=lambda t: sort_clike(t[0])))
key=lambda t: sort_clink(t[0])))
# If all our sources are Vala, our target also needs the C compiler but
# it won't get added above.
@ -995,7 +995,7 @@ You probably should put it in link_with instead.''')
Sometimes you want to link to a C++ library that exports C API, which
means the linker must link in the C++ stdlib, and we must use a C++
compiler for linking. The same is also applicable for objc/objc++, etc,
so we can keep using clike_langs for the priority order.
so we can keep using clink_langs for the priority order.
See: https://github.com/mesonbuild/meson/issues/1653
'''
@ -1014,9 +1014,9 @@ You probably should put it in link_with instead.''')
langs.append(language)
return langs
def get_clike_dynamic_linker_and_stdlibs(self):
def get_clink_dynamic_linker_and_stdlibs(self):
'''
We use the order of languages in `clike_langs` to determine which
We use the order of languages in `clink_langs` to determine which
linker to use in case the target has sources compiled with multiple
compilers. All languages other than those in this list have their own
linker.
@ -1033,7 +1033,7 @@ You probably should put it in link_with instead.''')
# Languages used by dependencies
dep_langs = self.get_langs_used_by_deps()
# Pick a compiler based on the language priority-order
for l in clike_langs:
for l in clink_langs:
if l in self.compilers or l in dep_langs:
try:
linker = all_compilers[l]
@ -1071,7 +1071,7 @@ You probably should put it in link_with instead.''')
2. If the target contains only objects, process_compilers guesses and
picks the first compiler that smells right.
'''
linker, _ = self.get_clike_dynamic_linker_and_stdlibs()
linker, _ = self.get_clink_dynamic_linker_and_stdlibs()
# Mixing many languages with MSVC is not supported yet so ignore stdlibs.
if linker and linker.get_id() == 'msvc':
return True

@ -28,7 +28,7 @@ __all__ = [
'all_languages',
'base_options',
'clib_langs',
'clike_langs',
'clink_langs',
'c_suffixes',
'cpp_suffixes',
'get_macos_dylib_install_name',
@ -42,7 +42,7 @@ __all__ = [
'is_source',
'lang_suffixes',
'sanitizer_compile_args',
'sort_clike',
'sort_clink',
'ArmCCompiler',
'ArmCPPCompiler',
@ -105,7 +105,7 @@ from .compilers import (
all_languages,
base_options,
clib_langs,
clike_langs,
clink_langs,
c_suffixes,
cpp_suffixes,
get_macos_dylib_install_name,
@ -119,7 +119,7 @@ from .compilers import (
is_library,
lang_suffixes,
sanitizer_compile_args,
sort_clike,
sort_clink,
ClangCompiler,
CompilerArgs,
GnuCompiler,

@ -54,11 +54,11 @@ clib_langs = ('objcpp', 'cpp', 'objc', 'c', 'fortran',)
# List of languages that can be linked with C code directly by the linker
# used in build.py:process_compilers() and build.py:get_dynamic_linker()
# XXX: Add Rust to this?
clike_langs = ('d',) + clib_langs
clike_suffixes = ()
for _l in clike_langs + ('vala',):
clike_suffixes += lang_suffixes[_l]
clike_suffixes += ('h', 'll', 's')
clink_langs = ('d',) + clib_langs
clink_suffixes = ()
for _l in clink_langs + ('vala',):
clink_suffixes += lang_suffixes[_l]
clink_suffixes += ('h', 'll', 's')
soregex = re.compile(r'.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$')
@ -72,18 +72,18 @@ cflags_mapping = {'c': 'CFLAGS',
'vala': 'VALAFLAGS',
'rust': 'RUSTFLAGS'}
# All these are only for C-like languages; see `clike_langs` above.
# All these are only for C-linkable languages; see `clink_langs` above.
def sort_clike(lang):
def sort_clink(lang):
'''
Sorting function to sort the list of languages according to
reversed(compilers.clike_langs) and append the unknown langs in the end.
reversed(compilers.clink_langs) and append the unknown langs in the end.
The purpose is to prefer C over C++ for files that can be compiled by
both such as assembly, C, etc. Also applies to ObjC, ObjC++, etc.
'''
if lang not in clike_langs:
if lang not in clink_langs:
return 1
return -clike_langs.index(lang)
return -clink_langs.index(lang)
def is_header(fname):
if hasattr(fname, 'fname'):
@ -95,7 +95,7 @@ def is_source(fname):
if hasattr(fname, 'fname'):
fname = fname.fname
suffix = fname.split('.')[-1].lower()
return suffix in clike_suffixes
return suffix in clink_suffixes
def is_assembly(fname):
if hasattr(fname, 'fname'):

@ -27,7 +27,7 @@ from pathlib import PurePath
from .. import mlog
from .. import mesonlib
from ..compilers import clib_langs, clike_langs
from ..compilers import clib_langs
from ..mesonlib import MesonException, OrderedSet
from ..mesonlib import Popen_safe, version_compare_many, version_compare, listify

@ -470,8 +470,8 @@ class PcapDependency(ExternalDependency):
@staticmethod
def get_pcap_lib_version(ctdep):
return ctdep.compiler.get_return_value('pcap_lib_version', 'string',
'#include <pcap.h>', ctdep.env, [], [ctdep])
return ctdep.clib_compiler.get_return_value('pcap_lib_version', 'string',
'#include <pcap.h>', ctdep.env, [], [ctdep])
class CupsDependency(ExternalDependency):

@ -2433,7 +2433,7 @@ external dependencies (including libraries) must go to "dependencies".''')
def func_add_languages(self, node, args, kwargs):
disabled, required, feature = extract_required_kwarg(kwargs)
if disabled:
for lang in sorted(args, key=compilers.sort_clike):
for lang in sorted(args, key=compilers.sort_clink):
mlog.log('Compiler for language', mlog.bold(lang), 'skipped: feature', mlog.bold(feature), 'disabled')
return False
return self.add_languages(args, required)
@ -2556,7 +2556,7 @@ external dependencies (including libraries) must go to "dependencies".''')
def add_languages(self, args, required):
success = True
need_cross_compiler = self.environment.is_cross_build() and self.environment.cross_info.need_cross_compiler()
for lang in sorted(args, key=compilers.sort_clike):
for lang in sorted(args, key=compilers.sort_clink):
lang = lang.lower()
if lang in self.coredata.compilers:
comp = self.coredata.compilers[lang]

Loading…
Cancel
Save