Skip to content

Commit d9aa019

Browse files
committed
Rust: Add "clib" crate type
1 parent 68ff347 commit d9aa019

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## New `clib` value for `rust_crate_type`
2+
3+
Similar to `lib` value but for building a C ABI static or shared library
4+
depending on the value of `default_library` when using `library()`.

docs/yaml/functions/_build_target_base.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,16 +292,17 @@ kwargs:
292292
If the target is an [[executable]] this defaults to "bin", the only
293293
allowed value.
294294
295-
If it is a [[static_library]] it defaults to "lib", and may be "lib",
296-
"staticlib", or "rlib". If "lib" then Rustc will pick a default, "staticlib"
297-
means a C ABI library, "rlib" means a Rust ABI.
295+
If it is a [[static_library]] it defaults to "lib", and may be "lib", "clib"
296+
"staticlib", or "rlib". "clib" and "staticlib" means a C ABI library,
297+
"lib" and "rlib" means a Rust ABI.
298298
299-
If it is a [[shared_library]] it defaults to "lib", and may be "lib",
300-
"dylib", "cdylib", or "proc-macro". If "lib" then Rustc will pick a
301-
default, "cdylib" means a C ABI library, "dylib" means a Rust ABI, and
302-
"proc-macro" is a special rust procedural macro crate.
299+
If it is a [[shared_library]] it defaults to "lib", and may be "lib", "clib",
300+
"dylib", "cdylib", or "proc-macro". "clib" and "cdylib" means a C ABI library,
301+
"lib" and "dylib" means a Rust ABI, and "proc-macro" is a special rust
302+
procedural macro crate.
303303
304304
"proc-macro" is new in 0.62.0.
305+
"clib" is new in 1.2.0.
305306
306307
rust_dependency_map:
307308
type: dict[str]

mesonbuild/build.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,8 @@ def process_kwargs(self, kwargs):
12441244
raise InvalidArguments(f'Invalid rust_crate_type "{rust_crate_type}": must be a string.')
12451245
if self.rust_crate_type == 'proc-macro':
12461246
FeatureNew.single_use('Rust crate type "proc-macro"', '0.62.0', self.subproject)
1247+
if self.rust_crate_type == 'clib':
1248+
FeatureNew.single_use('Rust crate type "clib"', '1.2.0', self.subproject)
12471249

12481250
rust_dependency_map = kwargs.get('rust_dependency_map', {})
12491251
if not isinstance(rust_dependency_map, dict):
@@ -2001,6 +2003,8 @@ def post_init(self) -> None:
20012003
if self.rust_crate_type == 'lib':
20022004
mlog.debug('Defaulting Rust static library target crate type to rlib')
20032005
self.rust_crate_type = 'rlib'
2006+
elif self.rust_crate_type == 'clib':
2007+
self.rust_crate_type = 'staticlib'
20042008
# Don't let configuration proceed with a non-static crate type
20052009
elif self.rust_crate_type not in {'rlib', 'staticlib'}:
20062010
raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for static libraries; must be "rlib" or "staticlib"')
@@ -2086,6 +2090,8 @@ def post_init(self) -> None:
20862090
if self.rust_crate_type == 'lib':
20872091
mlog.debug('Defaulting Rust dynamic library target crate type to "dylib"')
20882092
self.rust_crate_type = 'dylib'
2093+
elif self.rust_crate_type == 'clib':
2094+
self.rust_crate_type = 'cdylib'
20892095
# Don't let configuration proceed with a non-dynamic crate type
20902096
elif self.rust_crate_type not in {'dylib', 'cdylib', 'proc-macro'}:
20912097
raise InvalidArguments(f'Crate type "{self.rust_crate_type}" invalid for dynamic libraries; must be "dylib", "cdylib", or "proc-macro"')

0 commit comments

Comments
 (0)