diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index c12477fd6..0cfa2797c 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -60,11 +60,9 @@ class UserStringOption(UserOption): def validate(self, value): if not isinstance(value, str): - raise MesonException('Value "%s" for string option "%s" is not a string.' % (str(newvalue), self.name)) - if self.name == 'prefix': - if not os.path.isabs(value): - if len(value) >= 2 and value[1] != ':': - raise MesonException('Prefix option value \'{0}\' must be an absolute path.'.format(value)) + raise MesonException('Value "%s" for string option "%s" is not a string.' % (str(value), self.name)) + if self.name == 'prefix' and not os.path.isabs(value): + raise MesonException('Prefix option value \'{0}\' must be an absolute path.'.format(value)) if self.name in ('libdir', 'bindir', 'includedir', 'datadir', 'mandir', 'localedir') \ and os.path.isabs(value): raise MesonException('Option %s must not be an absolute path.' % self.name) diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 53799555b..774502bdf 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -84,7 +84,12 @@ class MesonApp(): if not os.path.isabs(options.prefix): raise RuntimeError('--prefix value \'{0}\' must be an absolute path: '.format(options.prefix)) if options.prefix.endswith('/') or options.prefix.endswith('\\'): - options.prefix = options.prefix[:-1] + # On Windows we need to preserve the trailing slash if the + # string is of type 'C:\' because 'C:' is not an absolute path. + if len(options.prefix) == 3 and options.prefix[1] == ':': + pass + else: + options.prefix = options.prefix[:-1] self.meson_script_file = script_file self.options = options