Skip to content

Commit 1e4cddc

Browse files
author
Adam C. Foltzer
committed
add crate-name to Rust target args
This is required for downstream Rust dependencies to properly import libraries using `extern crate`.
1 parent 138a8b2 commit 1e4cddc

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

mesonbuild/backend/ninjabackend.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ def generate_rust_target(self, target, outfile):
11731173
else:
11741174
raise InvalidArguments('Unknown target type for rustc.')
11751175
args.append(cratetype)
1176+
args += ['--crate-name', target.name]
11761177
args += rustc.get_buildtype_args(self.get_option_for_target('buildtype', target))
11771178
depfile = os.path.join(target.subdir, target.name + '.d')
11781179
args += ['--emit', 'dep-info={}'.format(depfile), '--emit', 'link']
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
usr/bin/prog?exe
2+
usr/lib/libnamed_stuff.rlib
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
project('rust static library', 'rust')
2+
3+
l = static_library('named_stuff', 'stuff.rs', install : true)
4+
e = executable('prog', 'prog.rs', link_with : l, install : true)
5+
test('linktest', e)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extern crate named_stuff;
2+
3+
fn main() { println!("printing: {}", named_stuff::explore()); }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub fn explore() -> &'static str { "librarystring" }

0 commit comments

Comments
 (0)