aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2023-04-17 20:09:27 +0300
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2023-04-20 13:53:26 +0530
commit3c9817fe7f0602df2d86519682e91fa8faf735ef (patch)
treeefefbbe9d2579bad429b327005fa4d315bc2276d /mesonbuild
parent45629466a7959d73576ea9c0b2eb6cce16169735 (diff)
downloadmeson-3c9817fe7f0602df2d86519682e91fa8faf735ef.zip
meson-3c9817fe7f0602df2d86519682e91fa8faf735ef.tar.gz
meson-3c9817fe7f0602df2d86519682e91fa8faf735ef.tar.bz2
rust: Don't allow spaces/dashes in Rust library names
The library names are directly mapped to filenames by meson while the crate name gets spaces/dashes replaced by underscores. This works fine to a certain degree except that rustc expects a certain filename scheme for rlibs that matches the crate name. When using such a library as a dependency of a dependency compilation will fail with a confusing error message. See https://github.com/rust-lang/rust/issues/110460
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/build.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 4182cdc..0a2a617 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1987,6 +1987,10 @@ class StaticLibrary(BuildTarget):
# Don't let configuration proceed with a non-static crate type
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 '
+ '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
# are called. The MSVC CRT uses libfoo.lib syntax but nothing else uses
@@ -2077,6 +2081,11 @@ class SharedLibrary(BuildTarget):
# Don't let configuration proceed with a non-dynamic crate type
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 '
+ 'due to a limitation of rustc. Replace them with underscores, for example')
+
if not hasattr(self, 'prefix'):
self.prefix = None
if not hasattr(self, 'suffix'):