Remove unnecessary functions and the last mention of TMPDIR from run-make-support

This commit is contained in:
Jakub Beránek 2024-06-07 14:10:27 +02:00
parent c9cb3280f3
commit 5844b679f3
No known key found for this signature in database
GPG Key ID: 909CD0D26483516B
10 changed files with 18 additions and 36 deletions

View File

@ -65,12 +65,6 @@ pub fn is_darwin() -> bool {
target().contains("darwin") target().contains("darwin")
} }
/// Construct a path to a static library under `$TMPDIR` given the library name. This will return a
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
pub fn static_lib(name: &str) -> PathBuf {
PathBuf::from(static_lib_name(name))
}
pub fn python_command() -> Command { pub fn python_command() -> Command {
let python_path = env_var("PYTHON"); let python_path = env_var("PYTHON");
Command::new(python_path) Command::new(python_path)
@ -111,12 +105,6 @@ pub fn static_lib_name(name: &str) -> String {
if is_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") } if is_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") }
} }
/// Construct a path to a dynamic library under `$TMPDIR` given the library name. This will return a
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
pub fn dynamic_lib(name: &str) -> PathBuf {
PathBuf::from(dynamic_lib_name(name))
}
/// Construct the dynamic library name based on the platform. /// Construct the dynamic library name based on the platform.
pub fn dynamic_lib_name(name: &str) -> String { pub fn dynamic_lib_name(name: &str) -> String {
// See tools.mk (irrelevant lines omitted): // See tools.mk (irrelevant lines omitted):
@ -154,14 +142,7 @@ pub fn dynamic_lib_extension() -> &'static str {
} }
} }
/// Construct a path to a rust library (rlib) under `$TMPDIR` given the library name. This will return a /// Construct a rust library (rlib) name.
/// path with `$TMPDIR` joined with the library name.
pub fn rust_lib(name: &str) -> PathBuf {
PathBuf::from(rust_lib_name(name))
}
/// Generate the name a rust library (rlib) would have. If you want the complete path, use
/// [`rust_lib`] instead.
pub fn rust_lib_name(name: &str) -> String { pub fn rust_lib_name(name: &str) -> String {
format!("lib{name}.rlib") format!("lib{name}.rlib")
} }

View File

@ -1,14 +1,14 @@
//! Check that non-trivial `repr(C)` enum in Rust has valid C layout. //! Check that non-trivial `repr(C)` enum in Rust has valid C layout.
//@ ignore-cross-compile //@ ignore-cross-compile
use run_make_support::{cc, extra_c_flags, extra_cxx_flags, run, rustc, static_lib}; use run_make_support::{cc, extra_c_flags, extra_cxx_flags, run, rustc, static_lib_name};
pub fn main() { pub fn main() {
use std::path::Path; use std::path::Path;
rustc().input("nonclike.rs").crate_type("staticlib").run(); rustc().input("nonclike.rs").crate_type("staticlib").run();
cc().input("test.c") cc().input("test.c")
.input(static_lib("nonclike")) .input(static_lib_name("nonclike"))
.out_exe("test") .out_exe("test")
.args(&extra_c_flags()) .args(&extra_c_flags())
.args(&extra_cxx_flags()) .args(&extra_cxx_flags())

View File

@ -3,13 +3,13 @@
//@ ignore-cross-compile //@ ignore-cross-compile
use run_make_support::{cc, extra_c_flags, run, rustc, static_lib}; use run_make_support::{cc, extra_c_flags, run, rustc, static_lib_name};
use std::fs; use std::fs;
fn main() { fn main() {
rustc().input("foo.rs").run(); rustc().input("foo.rs").run();
cc().input("bar.c").input(static_lib("foo")).out_exe("bar").args(&extra_c_flags()).run(); cc().input("bar.c").input(static_lib_name("foo")).out_exe("bar").args(&extra_c_flags()).run();
run("bar"); run("bar");
fs::remove_file(static_lib("foo")); fs::remove_file(static_lib_name("foo"));
run("bar"); run("bar");
} }

View File

@ -5,12 +5,12 @@
//@ ignore-cross-compile //@ ignore-cross-compile
use run_make_support::{cc, extra_c_flags, run, rustc, static_lib}; use run_make_support::{cc, extra_c_flags, run, rustc, static_lib_name};
fn main() { fn main() {
rustc().input("checkrust.rs").run(); rustc().input("checkrust.rs").run();
cc().input("test.c") cc().input("test.c")
.input(static_lib("checkrust")) .input(static_lib_name("checkrust"))
.out_exe("test") .out_exe("test")
.args(&extra_c_flags()) .args(&extra_c_flags())
.run(); .run();

View File

@ -12,7 +12,7 @@
use std::fs::remove_file; use std::fs::remove_file;
use run_make_support::{cc, cwd, dynamic_lib, is_msvc, run, rustc}; use run_make_support::{cc, cwd, dynamic_lib_name, is_msvc, run, rustc};
fn main() { fn main() {
rustc().input("bar.rs").run(); rustc().input("bar.rs").run();
@ -25,7 +25,7 @@ fn main() {
} }
run("foo"); run("foo");
remove_file(dynamic_lib("foo")).unwrap(); remove_file(dynamic_lib_name("foo")).unwrap();
rustc().input("foo.rs").arg("-Clto").run(); rustc().input("foo.rs").arg("-Clto").run();
run("foo"); run("foo");

View File

@ -9,10 +9,10 @@
//@ ignore-cross-compile //@ ignore-cross-compile
use run_make_support::{cc, extra_c_flags, run, rustc, static_lib}; use run_make_support::{cc, extra_c_flags, run, rustc, static_lib_name};
fn main() { fn main() {
let libbar_path = static_lib("bar"); let libbar_path = static_lib_name("bar");
rustc().input("foo.rs").crate_type("rlib").run(); rustc().input("foo.rs").crate_type("rlib").run();
rustc() rustc()
.input("bar.rs") .input("bar.rs")

View File

@ -1,6 +1,6 @@
//@ ignore-cross-compile //@ ignore-cross-compile
use run_make_support::{htmldocck, rustc, rustdoc, rust_lib_name}; use run_make_support::{htmldocck, rust_lib_name, rustc, rustdoc};
fn main() { fn main() {
let out_dir = "rustdoc"; let out_dir = "rustdoc";

View File

@ -3,12 +3,12 @@
//@ ignore-cross-compile //@ ignore-cross-compile
use run_make_support::{dynamic_lib, rustc}; use run_make_support::{dynamic_lib_name, rustc};
use std::fs::File; use std::fs::File;
fn main() { fn main() {
rustc().input("foo.rs").arg("-Cprefer-dynamic").run(); rustc().input("foo.rs").arg("-Cprefer-dynamic").run();
File::create(dynamic_lib("foo-something-special")).unwrap(); File::create(dynamic_lib_name("foo-something-special")).unwrap();
File::create(dynamic_lib("foo-something-special2")).unwrap(); File::create(dynamic_lib_name("foo-something-special2")).unwrap();
rustc().input("bar.rs").run(); rustc().input("bar.rs").run();
} }

View File

@ -8,7 +8,7 @@
fn main() { fn main() {
rustc().input("foo.rs").target("wasm32-wasip1").run(); rustc().input("foo.rs").target("wasm32-wasip1").run();
let file = PathBuf::from("foo.wasm"); let file = Path::new("foo.wasm");
run(&file, "return_two_i32", "1\n2\n"); run(&file, "return_two_i32", "1\n2\n");
run(&file, "return_two_i64", "3\n4\n"); run(&file, "return_two_i64", "3\n4\n");

View File

@ -2,6 +2,7 @@
use run_make_support::{rustc, wasmparser}; use run_make_support::{rustc, wasmparser};
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::path::Path;
fn main() { fn main() {
test_file("foo.rs", &[("a", &["foo"]), ("b", &["foo"])]); test_file("foo.rs", &[("a", &["foo"]), ("b", &["foo"])]);