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, [] return self.build.static_cross_linker, []
else: else:
return self.build.static_linker, [] 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 return l, stdlib_args
@staticmethod @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 typeslistify, stringlistify, classify_unity_sources
from .mesonlib import get_filenames_templates_dict, substitute_values from .mesonlib import get_filenames_templates_dict, substitute_values
from .mesonlib import for_windows, for_darwin, for_cygwin, for_android, has_path_sep 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 from .interpreterbase import FeatureNew, FeatureNewKwargs
pch_kwargs = set(['c_pch', 'cpp_pch']) pch_kwargs = set(['c_pch', 'cpp_pch'])
@ -490,16 +490,16 @@ class BuildTarget(Target):
extra = set() extra = set()
for t in itertools.chain(self.link_targets, self.link_whole_targets): for t in itertools.chain(self.link_targets, self.link_whole_targets):
for name, compiler in t.compilers.items(): for name, compiler in t.compilers.items():
if name in clike_langs: if name in clink_langs:
extra.add((name, compiler)) 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 self.compilers[name] = compiler
if not self.compilers: if not self.compilers:
# No source files or parent targets, target consists of only object # 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 # 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: if lang in compilers:
self.compilers[lang] = compilers[lang] self.compilers[lang] = compilers[lang]
break break
@ -556,9 +556,9 @@ class BuildTarget(Target):
if lang not in self.compilers: if lang not in self.compilers:
self.compilers[lang] = compiler self.compilers[lang] = compiler
break break
# Re-sort according to clike_langs # Re-sort according to clink_langs
self.compilers = OrderedDict(sorted(self.compilers.items(), 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 # If all our sources are Vala, our target also needs the C compiler but
# it won't get added above. # 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 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++ 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, 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 See: https://github.com/mesonbuild/meson/issues/1653
''' '''
@ -1014,9 +1014,9 @@ You probably should put it in link_with instead.''')
langs.append(language) langs.append(language)
return langs 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 linker to use in case the target has sources compiled with multiple
compilers. All languages other than those in this list have their own compilers. All languages other than those in this list have their own
linker. linker.
@ -1033,7 +1033,7 @@ You probably should put it in link_with instead.''')
# Languages used by dependencies # Languages used by dependencies
dep_langs = self.get_langs_used_by_deps() dep_langs = self.get_langs_used_by_deps()
# Pick a compiler based on the language priority-order # 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: if l in self.compilers or l in dep_langs:
try: try:
linker = all_compilers[l] 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 2. If the target contains only objects, process_compilers guesses and
picks the first compiler that smells right. 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. # Mixing many languages with MSVC is not supported yet so ignore stdlibs.
if linker and linker.get_id() == 'msvc': if linker and linker.get_id() == 'msvc':
return True return True

@ -28,7 +28,7 @@ __all__ = [
'all_languages', 'all_languages',
'base_options', 'base_options',
'clib_langs', 'clib_langs',
'clike_langs', 'clink_langs',
'c_suffixes', 'c_suffixes',
'cpp_suffixes', 'cpp_suffixes',
'get_macos_dylib_install_name', 'get_macos_dylib_install_name',
@ -42,7 +42,7 @@ __all__ = [
'is_source', 'is_source',
'lang_suffixes', 'lang_suffixes',
'sanitizer_compile_args', 'sanitizer_compile_args',
'sort_clike', 'sort_clink',
'ArmCCompiler', 'ArmCCompiler',
'ArmCPPCompiler', 'ArmCPPCompiler',
@ -105,7 +105,7 @@ from .compilers import (
all_languages, all_languages,
base_options, base_options,
clib_langs, clib_langs,
clike_langs, clink_langs,
c_suffixes, c_suffixes,
cpp_suffixes, cpp_suffixes,
get_macos_dylib_install_name, get_macos_dylib_install_name,
@ -119,7 +119,7 @@ from .compilers import (
is_library, is_library,
lang_suffixes, lang_suffixes,
sanitizer_compile_args, sanitizer_compile_args,
sort_clike, sort_clink,
ClangCompiler, ClangCompiler,
CompilerArgs, CompilerArgs,
GnuCompiler, 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 # 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() # used in build.py:process_compilers() and build.py:get_dynamic_linker()
# XXX: Add Rust to this? # XXX: Add Rust to this?
clike_langs = ('d',) + clib_langs clink_langs = ('d',) + clib_langs
clike_suffixes = () clink_suffixes = ()
for _l in clike_langs + ('vala',): for _l in clink_langs + ('vala',):
clike_suffixes += lang_suffixes[_l] clink_suffixes += lang_suffixes[_l]
clike_suffixes += ('h', 'll', 's') clink_suffixes += ('h', 'll', 's')
soregex = re.compile(r'.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$') soregex = re.compile(r'.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$')
@ -72,18 +72,18 @@ cflags_mapping = {'c': 'CFLAGS',
'vala': 'VALAFLAGS', 'vala': 'VALAFLAGS',
'rust': 'RUSTFLAGS'} '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 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 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. 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 1
return -clike_langs.index(lang) return -clink_langs.index(lang)
def is_header(fname): def is_header(fname):
if hasattr(fname, 'fname'): if hasattr(fname, 'fname'):
@ -95,7 +95,7 @@ def is_source(fname):
if hasattr(fname, 'fname'): if hasattr(fname, 'fname'):
fname = fname.fname fname = fname.fname
suffix = fname.split('.')[-1].lower() suffix = fname.split('.')[-1].lower()
return suffix in clike_suffixes return suffix in clink_suffixes
def is_assembly(fname): def is_assembly(fname):
if hasattr(fname, 'fname'): if hasattr(fname, 'fname'):

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

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

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

Loading…
Cancel
Save