Skip to content

Commit

Permalink
modules: get rid of the .*machine variables
Browse files Browse the repository at this point in the history
They're hardly used, and can be gotten directly from the Environment
instead
  • Loading branch information
dcbaker committed Dec 22, 2023
1 parent 7cbaa66 commit 6ccd708
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
4 changes: 0 additions & 4 deletions mesonbuild/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
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
Expand Down Expand Up @@ -52,9 +51,6 @@ def __init__(self, interpreter: 'Interpreter') -> None:
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]:
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def min_driver_version(self, state: 'ModuleState',
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
Expand Down
8 changes: 3 additions & 5 deletions mesonbuild/modules/external_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ def __init__(self,
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
Expand Down Expand Up @@ -126,10 +124,10 @@ def _configure(self, state: 'ModuleState') -> None:
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)

Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/python3.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, *args, **kwargs):
@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'
Expand Down

0 comments on commit 6ccd708

Please sign in to comment.