Skip to content

Commit

Permalink
add crate-name to Rust target args
Browse files Browse the repository at this point in the history
This is required for downstream Rust dependencies to properly import
libraries using `extern crate`.
  • Loading branch information
Adam C. Foltzer committed Jul 12, 2017
1 parent 138a8b2 commit 1e4cddc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,7 @@ def generate_rust_target(self, target, outfile):
else:
raise InvalidArguments('Unknown target type for rustc.')
args.append(cratetype)
args += ['--crate-name', target.name]
args += rustc.get_buildtype_args(self.get_option_for_target('buildtype', target))
depfile = os.path.join(target.subdir, target.name + '.d')
args += ['--emit', 'dep-info={}'.format(depfile), '--emit', 'link']
Expand Down
2 changes: 2 additions & 0 deletions test cases/rust/6 named staticlib/installed_files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
usr/bin/prog?exe
usr/lib/libnamed_stuff.rlib
5 changes: 5 additions & 0 deletions test cases/rust/6 named staticlib/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project('rust static library', 'rust')

l = static_library('named_stuff', 'stuff.rs', install : true)
e = executable('prog', 'prog.rs', link_with : l, install : true)
test('linktest', e)
3 changes: 3 additions & 0 deletions test cases/rust/6 named staticlib/prog.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extern crate named_stuff;

fn main() { println!("printing: {}", named_stuff::explore()); }
1 change: 1 addition & 0 deletions test cases/rust/6 named staticlib/stuff.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub fn explore() -> &'static str { "librarystring" }

0 comments on commit 1e4cddc

Please sign in to comment.