summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2023-04-18 15:56:35 +0300
committerNirbheek Chauhan <nirbheek@centricular.com>2023-04-21 13:29:15 +0530
commit34f9d61ba5e897fe454da3deb08a92d914207bed (patch)
tree02525bf700ccd434392d179ddcbe304ea277844f
parentd72a8e87c80ffb942dbaaa1e7192ade832a8ba86 (diff)
downloadmeson-34f9d61ba5e897fe454da3deb08a92d914207bed.tar.gz
rust: Also disallow `.` in Rust library target names
-rw-r--r--mesonbuild/backend/ninjabackend.py4
-rw-r--r--mesonbuild/build.py8
2 files changed, 6 insertions, 6 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index b64fc2062..e8aff72c6 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1892,8 +1892,8 @@ class NinjaBackend(backends.Backend):
args.extend(rustc.get_linker_always_args())
args += self.generate_basic_compiler_args(target, rustc, False)
- # Rustc replaces - with _. spaces are not allowed, so we replace them with underscores
- args += ['--crate-name', target.name.replace('-', '_').replace(' ', '_')]
+ # Rustc replaces - with _. spaces or dots are not allowed, so we replace them with underscores
+ args += ['--crate-name', target.name.replace('-', '_').replace(' ', '_').replace('.', '_')]
depfile = os.path.join(target.subdir, target.name + '.d')
args += ['--emit', f'dep-info={depfile}', '--emit', 'link']
args += target.get_extra_args('rust')
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 7134c9f34..b54817001 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1938,8 +1938,8 @@ class StaticLibrary(BuildTarget):
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"')
# See https://github.com/rust-lang/rust/issues/110460
- 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 '
+ if self.rust_crate_type == 'rlib' and any(c in self.name for c in ['-', ' ', '.']):
+ 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')
# By default a static library is named libfoo.a even on Windows because
# MSVC does not have a consistent convention for what static libraries
@@ -2024,8 +2024,8 @@ class SharedLibrary(BuildTarget):
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"')
# See https://github.com/rust-lang/rust/issues/110460
- 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 '
+ 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, periods or dashes in the library name '
'due to a limitation of rustc. Replace them with underscores, for example')
if not hasattr(self, 'prefix'):