Skip to content

Commit e2c454b

Browse files
sdroegenirbheek
authored andcommitted
rust: Also disallow . in Rust library target names
1 parent 3c9817f commit e2c454b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

mesonbuild/backend/ninjabackend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,8 +1892,8 @@ def generate_rust_target(self, target: build.BuildTarget) -> None:
18921892
args.extend(rustc.get_linker_always_args())
18931893

18941894
args += self.generate_basic_compiler_args(target, rustc, False)
1895-
# Rustc replaces - with _. spaces are not allowed, so we replace them with underscores
1896-
args += ['--crate-name', target.name.replace('-', '_').replace(' ', '_')]
1895+
# Rustc replaces - with _. spaces or dots are not allowed, so we replace them with underscores
1896+
args += ['--crate-name', target.name.replace('-', '_').replace(' ', '_').replace('.', '_')]
18971897
depfile = os.path.join(target.subdir, target.name + '.d')
18981898
args += ['--emit', f'dep-info={depfile}', '--emit', 'link']
18991899
args += target.get_extra_args('rust')

mesonbuild/build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,8 +1988,8 @@ def post_init(self) -> None:
19881988
elif self.rust_crate_type not in ['rlib', 'staticlib']:
19891989
raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for static libraries; must be "rlib" or "staticlib"')
19901990
# See https://github.com/rust-lang/rust/issues/110460
1991-
if self.rust_crate_type == 'rlib' and any(c in self.name for c in ['-', ' ']):
1992-
raise InvalidArguments('Rust crate types "dylib" and "proc-macro" do not allow spaces or dashes in the library name '
1991+
if self.rust_crate_type == 'rlib' and any(c in self.name for c in ['-', ' ', '.']):
1992+
raise InvalidArguments('Rust crate type "rlib" does not allow spaces, periods or dashes in the library name '
19931993
'due to a limitation of rustc. Replace them with underscores, for example')
19941994
# By default a static library is named libfoo.a even on Windows because
19951995
# MSVC does not have a consistent convention for what static libraries
@@ -2082,8 +2082,8 @@ def post_init(self) -> None:
20822082
elif self.rust_crate_type not in ['dylib', 'cdylib', 'proc-macro']:
20832083
raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for dynamic libraries; must be "dylib", "cdylib", or "proc-macro"')
20842084
# See https://github.com/rust-lang/rust/issues/110460
2085-
if self.rust_crate_type != 'cdylib' and any(c in self.name for c in ['-', ' ']):
2086-
raise InvalidArguments('Rust crate types "dylib" and "proc-macro" do not allow spaces or dashes in the library name '
2085+
if self.rust_crate_type != 'cdylib' and any(c in self.name for c in ['-', ' ', '.']):
2086+
raise InvalidArguments('Rust crate types "dylib" and "proc-macro" do not allow spaces, periods or dashes in the library name '
20872087
'due to a limitation of rustc. Replace them with underscores, for example')
20882088

20892089
if not hasattr(self, 'prefix'):

0 commit comments

Comments
 (0)