aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-03-05 09:50:30 -0800
committerDylan Baker <dylan@pnwbakers.com>2020-03-05 09:58:52 -0800
commit06b1a317d26cbe2a1bd7a232dd9726590d0c0a48 (patch)
treea2adf1f707779f18e226bf39c34447d229e71758 /mesonbuild/backend
parent4d6ac91f950380d8262c13ce529ac0d6d8f6f4ba (diff)
downloadmeson-06b1a317d26cbe2a1bd7a232dd9726590d0c0a48.zip
meson-06b1a317d26cbe2a1bd7a232dd9726590d0c0a48.tar.gz
meson-06b1a317d26cbe2a1bd7a232dd9726590d0c0a48.tar.bz2
Make use of unholder
We have a lot of cases of code like: ```python if hasattr(var, 'held_object'): var = var.held_object` ``` replace that with the unholder function.
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r--mesonbuild/backend/backends.py18
-rw-r--r--mesonbuild/backend/ninjabackend.py7
2 files changed, 8 insertions, 17 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index a8f4789..e9ab9f4 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -21,7 +21,7 @@ from .. import mlog
import json
import subprocess
from ..mesonlib import MachineChoice, MesonException, OrderedSet, OptionOverrideProxy
-from ..mesonlib import classify_unity_sources
+from ..mesonlib import classify_unity_sources, unholder
from ..mesonlib import File
from ..compilers import CompilerArgs, VisualStudioLikeCompiler
from ..interpreter import Interpreter
@@ -748,9 +748,7 @@ class Backend:
else:
extra_paths = []
cmd_args = []
- for a in t.cmd_args:
- if hasattr(a, 'held_object'):
- a = a.held_object
+ for a in unholder(t.cmd_args):
if isinstance(a, build.BuildTarget):
extra_paths += self.determine_windows_extra_paths(a, [])
if isinstance(a, mesonlib.File):
@@ -868,14 +866,10 @@ class Backend:
# also be built by default. XXX: Sometime in the future these should be
# built only before running tests.
for t in self.build.get_tests():
- exe = t.exe
- if hasattr(exe, 'held_object'):
- exe = exe.held_object
+ exe = unholder(t.exe)
if isinstance(exe, (build.CustomTarget, build.BuildTarget)):
result[exe.get_id()] = exe
- for arg in t.cmd_args:
- if hasattr(arg, 'held_object'):
- arg = arg.held_object
+ for arg in unholder(t.cmd_args):
if not isinstance(arg, (build.CustomTarget, build.BuildTarget)):
continue
result[arg.get_id()] = arg
@@ -915,9 +909,7 @@ class Backend:
Returns the path to them relative to the build root directory.
'''
srcs = []
- for i in target.get_sources():
- if hasattr(i, 'held_object'):
- i = i.held_object
+ for i in unholder(target.get_sources()):
if isinstance(i, str):
fname = [os.path.join(self.build_to_src, target.subdir, i)]
elif isinstance(i, build.BuildTarget):
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 24c91f3..c80d832 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -32,7 +32,8 @@ from ..compilers import (Compiler, CompilerArgs, CCompiler, FortranCompiler,
PGICCompiler, VisualStudioLikeCompiler)
from ..linkers import ArLinker
from ..mesonlib import (
- File, LibType, MachineChoice, MesonException, OrderedSet, PerMachine, ProgressBar, quote_arg
+ File, LibType, MachineChoice, MesonException, OrderedSet, PerMachine,
+ ProgressBar, quote_arg, unholder,
)
from ..mesonlib import get_compiler_for_source, has_path_sep
from .backends import CleanTrees
@@ -648,9 +649,7 @@ int dummy;
self.generate_target(t)
def custom_target_generator_inputs(self, target):
- for s in target.sources:
- if hasattr(s, 'held_object'):
- s = s.held_object
+ for s in unholder(target.sources):
if isinstance(s, build.GeneratedList):
self.generate_genlist_for_target(s, target)