Skip to content

Commit 301d722

Browse files
Add run-make-support::rust_lib_name
1 parent de1d0e0 commit 301d722

File tree

2 files changed

+10
-4
lines changed
  • src/tools/run-make-support/src
  • tests/run-make/crate-data-smoke

2 files changed

+10
-4
lines changed

src/tools/run-make-support/src/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,13 @@ pub fn dynamic_lib_name(name: &str) -> String {
135135
/// Construct a path to a rust library (rlib) under `$TMPDIR` given the library name. This will return a
136136
/// path with `$TMPDIR` joined with the library name.
137137
pub fn rust_lib(name: &str) -> PathBuf {
138-
tmp_dir().join(format!("lib{name}.rlib"))
138+
tmp_dir().join(rust_lib_name(name))
139+
}
140+
141+
/// Generate the name a rust library (rlib) would have. If you want the complete path, use
142+
/// [`rust_lib`] instead.
143+
pub fn rust_lib_name(name: &str) -> String {
144+
format!("lib{name}.rlib")
139145
}
140146

141147
/// Construct the binary name based on platform.

tests/run-make/crate-data-smoke/rmake.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::process::Output;
22

3-
use run_make_support::{bin_name, rust_lib, rustc};
3+
use run_make_support::{bin_name, rust_lib_name, rustc};
44

55
fn compare_stdout<S: AsRef<str>>(output: Output, expected: S) {
66
assert_eq!(
@@ -34,10 +34,10 @@ fn main() {
3434
);
3535
compare_stdout(
3636
rustc().print("file-names").input("lib.rs").run(),
37-
rust_lib("mylib").file_name().unwrap().to_string_lossy(),
37+
rust_lib_name("mylib"),
3838
);
3939
compare_stdout(
4040
rustc().print("file-names").input("rlib.rs").run(),
41-
rust_lib("mylib").file_name().unwrap().to_string_lossy(),
41+
rust_lib_name("mylib"),
4242
);
4343
}

0 commit comments

Comments
 (0)