dependencies/hdf5: Use the correct compilers for the machine
Instead of the default ones, this is especially important when cross compiling or when using compilers that aren't compatible with the default ones. squash! dependencies/hdf5: Use the actual system compilers
This commit is contained in:
parent
b7cb30e175
commit
54329eeed7
|
@ -4,3 +4,6 @@ HDF5 has been improved so that the internal representations have been split.
|
|||
This allows selecting pkg-config and config-tool dependencies separately.
|
||||
Both work as proper dependencies of their type, so `get_variable` and similar
|
||||
now work correctly.
|
||||
|
||||
It has also been fixed to use the selected compiler for the build instead of
|
||||
the default compiler.
|
||||
|
|
|
@ -390,7 +390,7 @@ class CoreData:
|
|||
) # type: PerMachine[T.defaultdict[str, OptionDictType]]
|
||||
self.base_options = {} # type: OptionDictType
|
||||
self.cross_files = self.__load_config_files(options, scratch_dir, 'cross')
|
||||
self.compilers = PerMachine(OrderedDict(), OrderedDict())
|
||||
self.compilers = PerMachine(OrderedDict(), OrderedDict()) # type: PerMachine[T.Dict[str, Compiler]]
|
||||
|
||||
build_cache = DependencyCache(self.builtins_per_machine, MachineChoice.BUILD)
|
||||
host_cache = DependencyCache(self.builtins_per_machine, MachineChoice.BUILD)
|
||||
|
|
|
@ -15,12 +15,13 @@
|
|||
# This file contains the detection logic for miscellaneous external dependencies.
|
||||
|
||||
import functools
|
||||
import subprocess
|
||||
import shutil
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from ..mesonlib import OrderedSet
|
||||
from ..mesonlib import OrderedSet, join_args
|
||||
from .base import (
|
||||
DependencyException, DependencyMethods, ConfigToolDependency,
|
||||
PkgConfigDependency, factory_methods
|
||||
|
@ -94,10 +95,13 @@ class HDF5ConfigToolDependency(ConfigToolDependency):
|
|||
raise DependencyException('Language {} is not supported with HDF5.'.format(language))
|
||||
|
||||
if language == 'c':
|
||||
cenv = 'CC'
|
||||
tools = ['h5cc']
|
||||
elif language == 'cpp':
|
||||
cenv = 'CXX'
|
||||
tools = ['h5c++']
|
||||
elif language == 'fortran':
|
||||
cenv = 'FC'
|
||||
tools = ['h5fc']
|
||||
else:
|
||||
raise DependencyException('How did you get here?')
|
||||
|
@ -108,7 +112,17 @@ class HDF5ConfigToolDependency(ConfigToolDependency):
|
|||
nkwargs = kwargs.copy()
|
||||
nkwargs['tools'] = tools
|
||||
|
||||
super().__init__(name, environment, nkwargs, language)
|
||||
# Override the compiler that the config tools are going to use by
|
||||
# setting the environment variables that they use for the compiler and
|
||||
# linkers.
|
||||
compiler = environment.coredata.compilers[for_machine][language]
|
||||
try:
|
||||
os.environ['HDF5_{}'.format(cenv)] = join_args(compiler.get_exelist())
|
||||
os.environ['HDF5_{}LINKER'.format(cenv)] = join_args(compiler.get_linker_exelist())
|
||||
super().__init__(name, environment, nkwargs, language)
|
||||
finally:
|
||||
del os.environ['HDF5_{}'.format(cenv)]
|
||||
del os.environ['HDF5_{}LINKER'.format(cenv)]
|
||||
if not self.is_found:
|
||||
return
|
||||
|
||||
|
@ -126,7 +140,7 @@ class HDF5ConfigToolDependency(ConfigToolDependency):
|
|||
nkwargs = kwargs.copy()
|
||||
nkwargs['language'] = 'c'
|
||||
# I'm being too clever for mypy and pylint
|
||||
self.is_found = self._add_sub_dependency(hdf5_factory(environment, self.for_machine, nkwargs)) # type: ignore # pylint: disable=no-value-for-parameter
|
||||
self.is_found = self._add_sub_dependency(hdf5_factory(environment, for_machine, nkwargs)) # type: ignore # pylint: disable=no-value-for-parameter
|
||||
|
||||
def _sanitize_version(self, ver: str) -> str:
|
||||
v = re.search(r'\s*HDF5 Version: (\d+\.\d+\.\d+)', ver)
|
||||
|
|
Loading…
Reference in New Issue