diff options
author | John Ericson <git@JohnEricson.me> | 2019-08-02 14:29:40 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2020-03-23 17:51:36 +0200 |
commit | 3a4388e51dee5e7e58f1e5ad4e60fb73b4aacf08 (patch) | |
tree | 8f0637e630777cc4a5707c16a30c4d980b888371 /mesonbuild/linkers.py | |
parent | f6b0425576640e1613f64503951c7c604b868947 (diff) | |
download | meson-3a4388e51dee5e7e58f1e5ad4e60fb73b4aacf08.zip meson-3a4388e51dee5e7e58f1e5ad4e60fb73b4aacf08.tar.gz meson-3a4388e51dee5e7e58f1e5ad4e60fb73b4aacf08.tar.bz2 |
Fix legacy env var support with cross
Fix #3969
Diffstat (limited to 'mesonbuild/linkers.py')
-rw-r--r-- | mesonbuild/linkers.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py index dc5b144..fa898d0 100644 --- a/mesonbuild/linkers.py +++ b/mesonbuild/linkers.py @@ -17,6 +17,7 @@ import os import typing as T from . import mesonlib +from .envconfig import get_env_var if T.TYPE_CHECKING: from .coredata import OptionDictType @@ -268,7 +269,20 @@ def evaluate_rpath(p: str, build_dir: str, from_dir: str) -> str: return os.path.relpath(os.path.join(build_dir, p), os.path.join(build_dir, from_dir)) -class DynamicLinker(metaclass=abc.ABCMeta): +class LinkerEnvVarsMixin(metaclass=abc.ABCMeta): + + """Mixin reading LDFLAGS from the environment.""" + + @staticmethod + def get_args_from_envvars(for_machine: mesonlib.MachineChoice, + is_cross: bool) -> T.List[str]: + raw_value = get_env_var(for_machine, is_cross, 'LDFLAGS') + if raw_value is not None: + return mesonlib.split_args(raw_value) + else: + return [] + +class DynamicLinker(LinkerEnvVarsMixin, metaclass=abc.ABCMeta): """Base class for dynamic linkers.""" @@ -327,12 +341,6 @@ class DynamicLinker(metaclass=abc.ABCMeta): # XXX: is use_ldflags a compiler or a linker attribute? - def get_args_from_envvars(self) -> T.List[str]: - flags = os.environ.get('LDFLAGS') - if not flags: - return [] - return mesonlib.split_args(flags) - def get_option_args(self, options: 'OptionDictType') -> T.List[str]: return [] |