rust: Also disallow `.` in Rust library target names

pull/11749/head
Sebastian Dröge 2 years ago committed by Nirbheek Chauhan
parent 3c9817fe7f
commit e2c454b86e
  1. 4
      mesonbuild/backend/ninjabackend.py
  2. 8
      mesonbuild/build.py

@ -1892,8 +1892,8 @@ class NinjaBackend(backends.Backend):
args.extend(rustc.get_linker_always_args()) args.extend(rustc.get_linker_always_args())
args += self.generate_basic_compiler_args(target, rustc, False) args += self.generate_basic_compiler_args(target, rustc, False)
# Rustc replaces - with _. spaces are not allowed, so we replace them with underscores # Rustc replaces - with _. spaces or dots are not allowed, so we replace them with underscores
args += ['--crate-name', target.name.replace('-', '_').replace(' ', '_')] args += ['--crate-name', target.name.replace('-', '_').replace(' ', '_').replace('.', '_')]
depfile = os.path.join(target.subdir, target.name + '.d') depfile = os.path.join(target.subdir, target.name + '.d')
args += ['--emit', f'dep-info={depfile}', '--emit', 'link'] args += ['--emit', f'dep-info={depfile}', '--emit', 'link']
args += target.get_extra_args('rust') args += target.get_extra_args('rust')

@ -1988,8 +1988,8 @@ class StaticLibrary(BuildTarget):
elif self.rust_crate_type not in ['rlib', 'staticlib']: elif self.rust_crate_type not in ['rlib', 'staticlib']:
raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for static libraries; must be "rlib" or "staticlib"') raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for static libraries; must be "rlib" or "staticlib"')
# See https://github.com/rust-lang/rust/issues/110460 # See https://github.com/rust-lang/rust/issues/110460
if self.rust_crate_type == 'rlib' and any(c in self.name for c in ['-', ' ']): if self.rust_crate_type == 'rlib' and any(c in self.name for c in ['-', ' ', '.']):
raise InvalidArguments('Rust crate types "dylib" and "proc-macro" do not allow spaces or dashes in the library name ' raise InvalidArguments('Rust crate type "rlib" does not allow spaces, periods or dashes in the library name '
'due to a limitation of rustc. Replace them with underscores, for example') 'due to a limitation of rustc. Replace them with underscores, for example')
# By default a static library is named libfoo.a even on Windows because # By default a static library is named libfoo.a even on Windows because
# MSVC does not have a consistent convention for what static libraries # MSVC does not have a consistent convention for what static libraries
@ -2082,8 +2082,8 @@ class SharedLibrary(BuildTarget):
elif self.rust_crate_type not in ['dylib', 'cdylib', 'proc-macro']: elif self.rust_crate_type not in ['dylib', 'cdylib', 'proc-macro']:
raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for dynamic libraries; must be "dylib", "cdylib", or "proc-macro"') raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for dynamic libraries; must be "dylib", "cdylib", or "proc-macro"')
# See https://github.com/rust-lang/rust/issues/110460 # See https://github.com/rust-lang/rust/issues/110460
if self.rust_crate_type != 'cdylib' and any(c in self.name for c in ['-', ' ']): if self.rust_crate_type != 'cdylib' and any(c in self.name for c in ['-', ' ', '.']):
raise InvalidArguments('Rust crate types "dylib" and "proc-macro" do not allow spaces or dashes in the library name ' raise InvalidArguments('Rust crate types "dylib" and "proc-macro" do not allow spaces, periods or dashes in the library name '
'due to a limitation of rustc. Replace them with underscores, for example') 'due to a limitation of rustc. Replace them with underscores, for example')
if not hasattr(self, 'prefix'): if not hasattr(self, 'prefix'):

Loading…
Cancel
Save