aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2021-06-12 17:33:15 +0200
committerDaniel Mensinger <daniel@mensinger-ka.de>2021-06-18 23:48:33 +0200
commitd601227cb2e00e8d4279f8dae27184fdbb0895e2 (patch)
tree3f27900f6bcac71fe6eb7d265c0d9eaf958c6ee7 /mesonbuild
parent7be172fe16c1b1c89bf66eff506e6bb007decce3 (diff)
downloadmeson-d601227cb2e00e8d4279f8dae27184fdbb0895e2.zip
meson-d601227cb2e00e8d4279f8dae27184fdbb0895e2.tar.gz
meson-d601227cb2e00e8d4279f8dae27184fdbb0895e2.tar.bz2
interpreter: Add FileHolder and remove specical case for File
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/interpreter/interpreter.py10
-rw-r--r--mesonbuild/interpreter/interpreterobjects.py4
-rw-r--r--mesonbuild/interpreterbase/interpreterbase.py4
3 files changed, 10 insertions, 8 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 726a240..b4cdb57 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -46,7 +46,7 @@ from .interpreterobjects import (SubprojectHolder, MachineHolder, EnvironmentVar
SharedModuleHolder, HeadersHolder, BothLibrariesHolder,
BuildTargetHolder, DataHolder, JarHolder, Test, RunProcess,
ManHolder, GeneratorHolder, InstallDirHolder, extract_required_kwarg,
- extract_search_dirs, MutableModuleObjectHolder)
+ extract_search_dirs, MutableModuleObjectHolder, FileHolder)
from .dependencyfallbacks import DependencyFallbacksHolder
from pathlib import Path
@@ -64,7 +64,7 @@ if T.TYPE_CHECKING:
from . import kwargs
# Input source types passed to Targets
- SourceInputs = T.Union[mesonlib.File, GeneratedListHolder, TargetHolder,
+ SourceInputs = T.Union[FileHolder, GeneratedListHolder, TargetHolder,
CustomTargetIndexHolder, GeneratedObjectsHolder, str]
# Input source types passed to the build.Target5 classes
SourceOutputs = T.Union[mesonlib.File, build.GeneratedList,
@@ -394,7 +394,7 @@ class Interpreter(InterpreterBase):
if isinstance(item, build.CustomTarget):
return CustomTargetHolder(item, self)
- elif isinstance(item, (int, str, bool, InterpreterObject, mesonlib.File)) or item is None:
+ elif isinstance(item, (int, str, bool, InterpreterObject)) or item is None:
return item
elif isinstance(item, build.Executable):
return ExecutableHolder(item, self)
@@ -414,8 +414,8 @@ class Interpreter(InterpreterBase):
return MutableModuleObjectHolder(item, self)
elif isinstance(item, ModuleObject):
return ModuleObjectHolder(item, self)
- elif isinstance(item, InterpreterObject):
- return item
+ elif isinstance(item, mesonlib.File):
+ return FileHolder(item)
else:
raise InterpreterException('Module returned a value of unknown type.')
diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py
index 4ae107d..e27c1f7 100644
--- a/mesonbuild/interpreter/interpreterobjects.py
+++ b/mesonbuild/interpreter/interpreterobjects.py
@@ -662,6 +662,10 @@ class IncludeDirsHolder(ObjectHolder[build.IncludeDirs]):
def __init__(self, idobj: build.IncludeDirs):
super().__init__(idobj)
+class FileHolder(ObjectHolder[mesonlib.File]):
+ def __init__(self, fobj: mesonlib.File):
+ super().__init__(fobj)
+
class HeadersHolder(ObjectHolder[build.Headers]):
def __init__(self, obj: build.Headers):
super().__init__(obj)
diff --git a/mesonbuild/interpreterbase/interpreterbase.py b/mesonbuild/interpreterbase/interpreterbase.py
index 05ea11f..be90049 100644
--- a/mesonbuild/interpreterbase/interpreterbase.py
+++ b/mesonbuild/interpreterbase/interpreterbase.py
@@ -545,8 +545,6 @@ The result of this is undefined and will become a hard error in a future Meson r
return self.array_method_call(obj, method_name, args, kwargs)
if isinstance(obj, dict):
return self.dict_method_call(obj, method_name, args, kwargs)
- if isinstance(obj, mesonlib.File):
- raise InvalidArguments('File object "%s" is not callable.' % obj)
if not isinstance(obj, InterpreterObject):
raise InvalidArguments('Variable "%s" is not callable.' % object_name)
# Special case. This is the only thing you can do with a disabler
@@ -867,7 +865,7 @@ To specify a keyword argument, use : instead of =.''')
def is_assignable(self, value: T.Any) -> bool:
return isinstance(value, (InterpreterObject, dependencies.Dependency,
- str, int, list, dict, mesonlib.File))
+ str, int, list, dict))
def validate_extraction(self, buildtarget: InterpreterObject) -> None:
raise InterpreterException('validate_extraction is not implemented in this context (please file a bug)')