mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
add rustc_minicore helper function
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
use crate::command::Command;
|
||||
use crate::env::env_var;
|
||||
use crate::path_helpers::cwd;
|
||||
use crate::path_helpers::{cwd, source_root};
|
||||
use crate::util::set_host_compiler_dylib_path;
|
||||
use crate::{is_aix, is_darwin, is_windows, is_windows_msvc, target, uname};
|
||||
|
||||
@@ -22,6 +22,37 @@ pub fn bare_rustc() -> Rustc {
|
||||
Rustc::bare()
|
||||
}
|
||||
|
||||
/// Construct a `rustc` invocation for building `minicore`.
|
||||
///
|
||||
/// This function:
|
||||
///
|
||||
/// - adds `tests/auxiliary/minicore.rs` as an input
|
||||
/// - sets the crate name to `"minicore"`
|
||||
/// - sets the crate type to `rlib`
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```ignore (illustrative)
|
||||
/// rustc_minicore().target("wasm32-wasip1").target_cpu("mvp").output("libminicore.rlib").run();
|
||||
///
|
||||
/// rustc()
|
||||
/// .input("foo.rs")
|
||||
/// .target("wasm32-wasip1")
|
||||
/// .target_cpu("mvp")
|
||||
/// .extern_("minicore", path("libminicore.rlib"))
|
||||
/// // ...
|
||||
/// .run()
|
||||
/// ```
|
||||
#[track_caller]
|
||||
pub fn rustc_minicore() -> Rustc {
|
||||
let mut builder = rustc();
|
||||
|
||||
let minicore_path = source_root().join("tests/auxiliary/minicore.rs");
|
||||
builder.input(minicore_path).crate_name("minicore").crate_type("rlib");
|
||||
|
||||
builder
|
||||
}
|
||||
|
||||
/// A `rustc` invocation builder.
|
||||
#[derive(Debug)]
|
||||
#[must_use]
|
||||
|
||||
@@ -72,13 +72,12 @@ pub mod rfs {
|
||||
llvm_readobj,
|
||||
};
|
||||
pub use crate::external_deps::python::python_command;
|
||||
pub use crate::external_deps::rustc::{self, Rustc, bare_rustc, rustc, rustc_path};
|
||||
pub use crate::external_deps::rustc::{self, Rustc, bare_rustc, rustc, rustc_minicore, rustc_path};
|
||||
pub use crate::external_deps::rustdoc::{Rustdoc, bare_rustdoc, rustdoc};
|
||||
// Path-related helpers.
|
||||
pub use crate::path_helpers::{
|
||||
build_root, cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix,
|
||||
has_suffix, minicore_path, not_contains, path, shallow_find_directories, shallow_find_files,
|
||||
source_root,
|
||||
has_suffix, not_contains, path, shallow_find_directories, shallow_find_files, source_root,
|
||||
};
|
||||
// Convenience helpers for running binaries and other commands.
|
||||
pub use crate::run::{cmd, run, run_fail, run_with_args};
|
||||
|
||||
@@ -40,12 +40,6 @@ pub fn build_root() -> PathBuf {
|
||||
env_var("BUILD_ROOT").into()
|
||||
}
|
||||
|
||||
/// Path to minicore.
|
||||
#[must_use]
|
||||
pub fn minicore_path() -> PathBuf {
|
||||
source_root().join("tests/auxiliary/minicore.rs")
|
||||
}
|
||||
|
||||
/// Browse the directory `path` non-recursively and return all files which respect the parameters
|
||||
/// outlined by `closure`.
|
||||
#[track_caller]
|
||||
|
||||
@@ -15,17 +15,10 @@
|
||||
// crashes... so I'm going to disable this test for windows for now.
|
||||
//@ ignore-windows-gnu
|
||||
|
||||
use run_make_support::{llvm_objdump, minicore_path, path, rustc};
|
||||
use run_make_support::{llvm_objdump, path, rustc, rustc_minicore};
|
||||
|
||||
fn main() {
|
||||
rustc()
|
||||
.input(minicore_path())
|
||||
.crate_name("minicore")
|
||||
.crate_type("rlib")
|
||||
.target("avr-none")
|
||||
.target_cpu("avr")
|
||||
.output("libminicore.rlib")
|
||||
.run();
|
||||
rustc_minicore().target("avr-none").target_cpu("avr").output("libminicore.rlib").run();
|
||||
|
||||
rustc()
|
||||
.input("avr-rjmp-offsets.rs")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//@ needs-llvm-components: arm
|
||||
//@ needs-rust-lld
|
||||
use run_make_support::{
|
||||
llvm_filecheck, llvm_objdump, minicore_path, path, rfs, run, rustc, source_root,
|
||||
llvm_filecheck, llvm_objdump, path, rfs, run, rustc, rustc_minicore, source_root,
|
||||
};
|
||||
|
||||
// Test a thumb target calling arm functions. Doing so requires switching from thumb mode to arm
|
||||
@@ -27,13 +27,7 @@ fn main() {
|
||||
}
|
||||
|
||||
fn helper(prefix: &str, target: &str) {
|
||||
rustc()
|
||||
.input(minicore_path())
|
||||
.crate_name("minicore")
|
||||
.crate_type("rlib")
|
||||
.target(target)
|
||||
.output("libminicore.rlib")
|
||||
.run();
|
||||
rustc_minicore().target(target).output("libminicore.rlib").run();
|
||||
|
||||
rustc()
|
||||
.input("main.rs")
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
//@ needs-rust-lld
|
||||
use std::path::Path;
|
||||
|
||||
use run_make_support::{minicore_path, path, rfs, rustc, wasmparser};
|
||||
use run_make_support::{path, rfs, rustc, rustc_minicore, wasmparser};
|
||||
|
||||
fn main() {
|
||||
rustc()
|
||||
.input(minicore_path())
|
||||
.crate_name("minicore")
|
||||
.crate_type("rlib")
|
||||
.target("wasm32-wasip1")
|
||||
.target_cpu("mvp")
|
||||
.output("libminicore.rlib")
|
||||
.run();
|
||||
rustc_minicore().target("wasm32-wasip1").target_cpu("mvp").output("libminicore.rlib").run();
|
||||
|
||||
rustc()
|
||||
.input("foo.rs")
|
||||
|
||||
Reference in New Issue
Block a user