aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2022-02-28 15:46:45 -0800
committerDylan Baker <dylan@pnwbakers.com>2022-03-03 10:29:14 -0800
commit5787f816159a96d4654cef276866dfbcae7619d8 (patch)
treea28c51064bacb1d4ea3ba6261c02e047f1de626f /mesonbuild
parent4a2058cb836242a6423870e671b6b76fa48167f3 (diff)
downloadmeson-5787f816159a96d4654cef276866dfbcae7619d8.zip
meson-5787f816159a96d4654cef276866dfbcae7619d8.tar.gz
meson-5787f816159a96d4654cef276866dfbcae7619d8.tar.bz2
interpreter: add cm_interpreter to SubprojectHolder
This is used in the cmake module, as an extra attribute we just tack on. Instead, let's actually define and type it.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/interpreter/interpreterobjects.py5
-rw-r--r--mesonbuild/modules/cmake.py7
2 files changed, 8 insertions, 4 deletions
diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py
index c7ddb38..eed750e 100644
--- a/mesonbuild/interpreter/interpreterobjects.py
+++ b/mesonbuild/interpreter/interpreterobjects.py
@@ -1,3 +1,4 @@
+from __future__ import annotations
import os
import shlex
import subprocess
@@ -29,9 +30,10 @@ import typing as T
if T.TYPE_CHECKING:
from . import kwargs
- from .interpreter import Interpreter
+ from ..cmake.interpreter import CMakeInterpreter
from ..envconfig import MachineInfo
from ..interpreterbase import SubProject
+ from .interpreter import Interpreter
from typing_extensions import TypedDict
@@ -678,6 +680,7 @@ class SubprojectHolder(MesonInterpreterObject):
self.disabled_feature = disabled_feature
self.exception = exception
self.subdir = PurePath(subdir).as_posix()
+ self.cm_interpreter: T.Optional[CMakeInterpreter] = None
self.methods.update({'get_variable': self.get_variable_method,
'found': self.found_method,
})
diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py
index a58ad54..0f54d30 100644
--- a/mesonbuild/modules/cmake.py
+++ b/mesonbuild/modules/cmake.py
@@ -104,9 +104,10 @@ endmacro()
class CMakeSubproject(ModuleObject):
def __init__(self, subp: SubprojectHolder):
assert isinstance(subp, SubprojectHolder)
- assert hasattr(subp, 'cm_interpreter')
+ assert subp.cm_interpreter is not None
super().__init__()
self.subp = subp
+ self.cm_interpreter = subp.cm_interpreter
self.methods.update({'get_variable': self.get_variable,
'dependency': self.dependency,
'include_directories': self.include_directories,
@@ -121,7 +122,7 @@ class CMakeSubproject(ModuleObject):
raise InterpreterException('Exactly one argument is required.')
tgt = args[0]
- res = self.subp.cm_interpreter.target_info(tgt)
+ res = self.cm_interpreter.target_info(tgt)
if res is None:
raise InterpreterException(f'The CMake target {tgt} does not exist\n' +
' Use the following command in your meson.build to list all available targets:\n\n' +
@@ -172,7 +173,7 @@ class CMakeSubproject(ModuleObject):
@noPosargs
@noKwargs
def target_list(self, state, args, kwargs):
- return self.subp.cm_interpreter.target_list()
+ return self.cm_interpreter.target_list()
@noPosargs
@noKwargs