diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2020-02-12 18:47:51 +0000 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2020-04-30 20:11:32 +0100 |
commit | 6a5c6fb439c9351d513c63ff7eb028dde4c3f1c0 (patch) | |
tree | 0495f3e74405d402fa3fbad32173b1f9699841b2 /mesonbuild/build.py | |
parent | d1920886a1e3f0e50969399a836a76ecf01d703e (diff) | |
download | meson-6a5c6fb439c9351d513c63ff7eb028dde4c3f1c0.zip meson-6a5c6fb439c9351d513c63ff7eb028dde4c3f1c0.tar.gz meson-6a5c6fb439c9351d513c63ff7eb028dde4c3f1c0.tar.bz2 |
Be more careful about the use of repr() in error messages
Generally, we'd want to use str() rather than repr() in error messages
anyhow, as that explicitly gives something designed to be read by
humans.
Sometimes {!r} is being used as a shortcut to avoid writing the quotes
in '{!s}'.
Unfortunately, these things aren't quite the same, as the repr of a
string containing '\' (the path separator on Windows) will have those
escaped.
We don't have a good string representation to use for the arbitrary
internal object used as an argument for install_data() when it's neither
a string nor file (which doesn't lead to a good error message), so drop
that for the moment.
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r-- | mesonbuild/build.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index c200261..98930b3 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -531,6 +531,9 @@ class BuildTarget(Target): repr_str = "<{0} {1}: {2}>" return repr_str.format(self.__class__.__name__, self.get_id(), self.filename) + def __str__(self): + return "{}".format(self.name) + def validate_install(self, environment): if self.for_machine is MachineChoice.BUILD and self.need_install: if environment.is_cross_build(): @@ -1104,7 +1107,7 @@ You probably should put it in link_with instead.''') if not isinstance(t, (Target, CustomTargetIndex)): raise InvalidArguments('{!r} is not a target.'.format(t)) if not t.is_linkable_target(): - raise InvalidArguments('Link target {!r} is not linkable.'.format(t)) + raise InvalidArguments("Link target '{!s}' is not linkable.".format(t)) if isinstance(self, SharedLibrary) and isinstance(t, StaticLibrary) and not t.pic: msg = "Can't link non-PIC static library {!r} into shared library {!r}. ".format(t.name, self.name) msg += "Use the 'pic' option to static_library to build with PIC." |