modules: get rid of the .*machine variables

They're hardly used, and can be gotten directly from the Environment
instead
pull/12617/merge
Dylan Baker 1 year ago
parent 7cbaa6613a
commit 6ccd708f30
  1. 4
      mesonbuild/modules/__init__.py
  2. 2
      mesonbuild/modules/cuda.py
  3. 8
      mesonbuild/modules/external_project.py
  4. 2
      mesonbuild/modules/python3.py

@ -16,7 +16,6 @@ from ..programs import ExternalProgram
if T.TYPE_CHECKING:
from ..interpreter import Interpreter
from ..interpreter.interpreter import ProgramVersionFunc
from ..interpreter.interpreterobjects import MachineHolder
from ..interpreterbase import TYPE_var, TYPE_kwargs
from ..programs import OverrideProgram
from ..wrap import WrapMode
@ -52,9 +51,6 @@ class ModuleState:
self.man = interpreter.build.get_man()
self.global_args = interpreter.build.global_args.host
self.project_args = interpreter.build.projects_args.host.get(interpreter.subproject, {})
self.build_machine = T.cast('MachineHolder', interpreter.builtin['build_machine']).held_object
self.host_machine = T.cast('MachineHolder', interpreter.builtin['host_machine']).held_object
self.target_machine = T.cast('MachineHolder', interpreter.builtin['target_machine']).held_object
self.current_node = interpreter.current_node
def get_include_args(self, include_dirs: T.Iterable[T.Union[str, build.IncludeDirs]], prefix: str = '-I') -> T.List[str]:

@ -82,7 +82,7 @@ class CudaModule(NewExtensionModule):
driver_version = 'unknown'
for d in driver_version_table:
if version_compare(cuda_version, d['cuda_version']):
driver_version = d.get(state.host_machine.system, d['linux'])
driver_version = d.get(state.environment.machines.host.system, d['linux'])
break
return driver_version

@ -65,8 +65,6 @@ class ExternalProject(NewExtensionModule):
self.project_version = state.project_version
self.subproject = state.subproject
self.env = state.environment
self.build_machine = state.build_machine
self.host_machine = state.host_machine
self.configure_command = configure_command
self.configure_options = configure_options
self.cross_configure_options = cross_configure_options
@ -126,10 +124,10 @@ class ExternalProject(NewExtensionModule):
configure_cmd += self._format_options(self.configure_options, d)
if self.env.is_cross_build():
host = '{}-{}-{}'.format(self.host_machine.cpu,
'pc' if self.host_machine.cpu_family in {"x86", "x86_64"}
host = '{}-{}-{}'.format(state.environment.machines.host.cpu,
'pc' if state.environment.machines.host.cpu_family in {"x86", "x86_64"}
else 'unknown',
self.host_machine.system)
state.environment.machines.host.system)
d = [('HOST', None, host)]
configure_cmd += self._format_options(self.cross_configure_options, d)

@ -41,7 +41,7 @@ class Python3Module(ExtensionModule):
@typed_pos_args('python3.extension_module', str, varargs=(str, mesonlib.File, CustomTarget, CustomTargetIndex, GeneratedList, StructuredSources, ExtractedObjects, BuildTarget))
@typed_kwargs('python3.extension_module', *_MOD_KWARGS, allow_unknown=True)
def extension_module(self, state: ModuleState, args: T.Tuple[str, T.List[BuildTargetSource]], kwargs: SharedModuleKW):
host_system = state.host_machine.system
host_system = state.environment.machines.host.system
if host_system == 'darwin':
# Default suffix is 'dylib' but Python does not use it for extensions.
suffix = 'so'

Loading…
Cancel
Save