diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2025-03-25 02:23:42 +0100 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2025-04-30 00:14:44 +0300 |
commit | 8e564f16aea388834b69e784a82b248bae825c66 (patch) | |
tree | 3da6f759e928e5265ba9bb563359c144b686572c /mesonbuild/compilers/compilers.py | |
parent | 8909a09d2a8713c4fc0c31c2df6c9b022b840213 (diff) | |
download | meson-8e564f16aea388834b69e784a82b248bae825c66.zip meson-8e564f16aea388834b69e784a82b248bae825c66.tar.gz meson-8e564f16aea388834b69e784a82b248bae825c66.tar.bz2 |
compilers: introduce common helper for sanity checks
Avoid reinventing the wheel and instead use a single helper, taking care
of logging and cross compilation.
Fixes: #14373
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r-- | mesonbuild/compilers/compilers.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 3c1d58b..ad252a1 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1200,6 +1200,23 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): is good enough here. """ + def run_sanity_check(self, environment: Environment, cmdlist: T.List[str], work_dir: str, use_exe_wrapper_for_cross: bool = True) -> T.Tuple[str, str]: + # Run sanity check + if self.is_cross and use_exe_wrapper_for_cross: + if not environment.has_exe_wrapper(): + # Can't check if the binaries run so we have to assume they do + return ('', '') + cmdlist = environment.exe_wrapper.get_command() + cmdlist + mlog.debug('Running test binary command: ', mesonlib.join_args(cmdlist)) + try: + pe, stdo, stde = Popen_safe_logged(cmdlist, 'Sanity check', cwd=work_dir) + except Exception as e: + raise mesonlib.EnvironmentException(f'Could not invoke sanity check executable: {e!s}.') + + if pe.returncode != 0: + raise mesonlib.EnvironmentException(f'Executables created by {self.language} compiler {self.name_string()} are not runnable.') + return stdo, stde + def split_shlib_to_parts(self, fname: str) -> T.Tuple[T.Optional[str], str]: return None, fname |