Update run-make
tests to use cargo
wrapper cmd
This commit is contained in:
parent
53897921bd
commit
f548216728
@ -15,46 +15,36 @@
|
|||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use run_make_support::object::read::Object;
|
use run_make_support::object::read::Object;
|
||||||
use run_make_support::object::read::archive::ArchiveFile;
|
use run_make_support::object::read::archive::ArchiveFile;
|
||||||
use run_make_support::object::{ObjectSection, ObjectSymbol, RelocationTarget};
|
use run_make_support::object::{ObjectSection, ObjectSymbol, RelocationTarget};
|
||||||
use run_make_support::rfs::{read, read_dir};
|
use run_make_support::rfs::{read, read_dir};
|
||||||
use run_make_support::{cmd, env_var, object};
|
use run_make_support::{cargo, object, path, target};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let target_dir = PathBuf::from("target");
|
let target_dir = path("target");
|
||||||
let target = env_var("TARGET");
|
|
||||||
|
|
||||||
println!("Testing compiler_builtins for {}", target);
|
println!("Testing compiler_builtins for {}", target());
|
||||||
|
|
||||||
let manifest_path = PathBuf::from("Cargo.toml");
|
cargo()
|
||||||
|
.args(&[
|
||||||
|
"build",
|
||||||
|
"--manifest-path",
|
||||||
|
"Cargo.toml",
|
||||||
|
"-Zbuild-std=core",
|
||||||
|
"--target",
|
||||||
|
&target(),
|
||||||
|
])
|
||||||
|
.env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes")
|
||||||
|
.env("CARGO_TARGET_DIR", &target_dir)
|
||||||
|
.env("RUSTC_BOOTSTRAP", "1")
|
||||||
|
// Visual Studio 2022 requires that the LIB env var be set so it can
|
||||||
|
// find the Windows SDK.
|
||||||
|
.env("LIB", std::env::var("LIB").unwrap_or_default())
|
||||||
|
.run();
|
||||||
|
|
||||||
let path = env_var("PATH");
|
let rlibs_path = target_dir.join(target()).join("debug").join("deps");
|
||||||
let rustc = env_var("RUSTC");
|
|
||||||
let cargo = env_var("CARGO");
|
|
||||||
let mut cmd = cmd(cargo);
|
|
||||||
cmd.args(&[
|
|
||||||
"build",
|
|
||||||
"--manifest-path",
|
|
||||||
manifest_path.to_str().unwrap(),
|
|
||||||
"-Zbuild-std=core",
|
|
||||||
"--target",
|
|
||||||
&target,
|
|
||||||
])
|
|
||||||
.env("PATH", path)
|
|
||||||
.env("RUSTC", rustc)
|
|
||||||
.env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes")
|
|
||||||
.env("CARGO_TARGET_DIR", &target_dir)
|
|
||||||
.env("RUSTC_BOOTSTRAP", "1")
|
|
||||||
// Visual Studio 2022 requires that the LIB env var be set so it can
|
|
||||||
// find the Windows SDK.
|
|
||||||
.env("LIB", std::env::var("LIB").unwrap_or_default());
|
|
||||||
|
|
||||||
cmd.run();
|
|
||||||
|
|
||||||
let rlibs_path = target_dir.join(target).join("debug").join("deps");
|
|
||||||
let compiler_builtins_rlib = read_dir(rlibs_path)
|
let compiler_builtins_rlib = read_dir(rlibs_path)
|
||||||
.find_map(|e| {
|
.find_map(|e| {
|
||||||
let path = e.unwrap().path();
|
let path = e.unwrap().path();
|
||||||
|
@ -14,10 +14,7 @@
|
|||||||
|
|
||||||
//@ only-thumb
|
//@ only-thumb
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use run_make_support::{cargo, cmd, env, env_var, target};
|
||||||
|
|
||||||
use run_make_support::rfs::create_dir;
|
|
||||||
use run_make_support::{cmd, env_var, target};
|
|
||||||
|
|
||||||
const CRATE: &str = "cortex-m";
|
const CRATE: &str = "cortex-m";
|
||||||
const CRATE_URL: &str = "https://github.com/rust-embedded/cortex-m";
|
const CRATE_URL: &str = "https://github.com/rust-embedded/cortex-m";
|
||||||
@ -28,32 +25,21 @@ fn main() {
|
|||||||
// See below link for git usage:
|
// See below link for git usage:
|
||||||
// https://stackoverflow.com/questions/3489173#14091182
|
// https://stackoverflow.com/questions/3489173#14091182
|
||||||
cmd("git").args(["clone", CRATE_URL, CRATE]).run();
|
cmd("git").args(["clone", CRATE_URL, CRATE]).run();
|
||||||
std::env::set_current_dir(CRATE).unwrap();
|
env::set_current_dir(CRATE);
|
||||||
cmd("git").args(["reset", "--hard", CRATE_SHA1]).run();
|
cmd("git").args(["reset", "--hard", CRATE_SHA1]).run();
|
||||||
|
|
||||||
let target_dir = PathBuf::from("target");
|
cargo()
|
||||||
let manifest_path = PathBuf::from("Cargo.toml");
|
.args(&[
|
||||||
|
"build",
|
||||||
let path = env_var("PATH");
|
"--manifest-path",
|
||||||
let rustc = env_var("RUSTC");
|
"Cargo.toml",
|
||||||
let cargo = env_var("CARGO");
|
"-Zbuild-std=core",
|
||||||
// FIXME: extract cargo invocations to a proper command
|
"--target",
|
||||||
// https://github.com/rust-lang/rust/issues/128734
|
&target(),
|
||||||
let mut cmd = cmd(cargo);
|
])
|
||||||
cmd.args(&[
|
.env("CARGO_TARGET_DIR", "target")
|
||||||
"build",
|
// Don't make lints fatal, but they need to at least warn
|
||||||
"--manifest-path",
|
// or they break Cargo's target info parsing.
|
||||||
manifest_path.to_str().unwrap(),
|
.env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes --cap-lints=warn")
|
||||||
"-Zbuild-std=core",
|
.run();
|
||||||
"--target",
|
|
||||||
&target(),
|
|
||||||
])
|
|
||||||
.env("PATH", path)
|
|
||||||
.env("RUSTC", rustc)
|
|
||||||
.env("CARGO_TARGET_DIR", &target_dir)
|
|
||||||
// Don't make lints fatal, but they need to at least warn
|
|
||||||
// or they break Cargo's target info parsing.
|
|
||||||
.env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes --cap-lints=warn");
|
|
||||||
|
|
||||||
cmd.run();
|
|
||||||
}
|
}
|
||||||
|
@ -14,49 +14,34 @@
|
|||||||
//!
|
//!
|
||||||
//! FIXME: https://github.com/rust-lang/rust/issues/128733 this test uses external
|
//! FIXME: https://github.com/rust-lang/rust/issues/128733 this test uses external
|
||||||
//! dependencies, and needs an active internet connection
|
//! dependencies, and needs an active internet connection
|
||||||
//!
|
|
||||||
//! FIXME: https://github.com/rust-lang/rust/issues/128734 extract bootstrap cargo
|
|
||||||
//! to a proper command
|
|
||||||
|
|
||||||
//@ only-thumb
|
//@ only-thumb
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use run_make_support::{cmd, env_var, path_helpers, target};
|
use run_make_support::{cargo, cmd, env_var, path, target};
|
||||||
|
|
||||||
const CRATE: &str = "example";
|
const CRATE: &str = "example";
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
std::env::set_current_dir(CRATE).unwrap();
|
std::env::set_current_dir(CRATE).unwrap();
|
||||||
|
|
||||||
let bootstrap_cargo = env_var("BOOTSTRAP_CARGO");
|
let target_dir = path("target");
|
||||||
let path = env_var("PATH");
|
let manifest_path = path("Cargo.toml");
|
||||||
let rustc = env_var("RUSTC");
|
|
||||||
|
|
||||||
let target_dir = path_helpers::path("target");
|
// Debug
|
||||||
let manifest_path = path_helpers::path("Cargo.toml");
|
cargo()
|
||||||
|
.args(&["run", "--target", &target()])
|
||||||
|
.env("RUSTFLAGS", "-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x")
|
||||||
|
.env("CARGO_TARGET_DIR", &target_dir)
|
||||||
|
.run()
|
||||||
|
.assert_stdout_contains("x = 42");
|
||||||
|
|
||||||
let debug = {
|
// Release
|
||||||
let mut cmd = cmd(&bootstrap_cargo);
|
cargo()
|
||||||
cmd.args(&["run", "--target", &target()])
|
.args(&["run", "--release", "--target", &target()])
|
||||||
.env("RUSTFLAGS", "-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x")
|
.env("RUSTFLAGS", "-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x")
|
||||||
.env("CARGO_TARGET_DIR", &target_dir)
|
.env("CARGO_TARGET_DIR", &target_dir)
|
||||||
.env("PATH", &path)
|
.run()
|
||||||
.env("RUSTC", &rustc);
|
.assert_stdout_contains("x = 42");
|
||||||
cmd.run()
|
|
||||||
};
|
|
||||||
|
|
||||||
debug.assert_stdout_contains("x = 42");
|
|
||||||
|
|
||||||
let release = {
|
|
||||||
let mut cmd = cmd(&bootstrap_cargo);
|
|
||||||
cmd.args(&["run", "--release", "--target", &target()])
|
|
||||||
.env("RUSTFLAGS", "-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x")
|
|
||||||
.env("CARGO_TARGET_DIR", &target_dir)
|
|
||||||
.env("PATH", &path)
|
|
||||||
.env("RUSTC", &rustc);
|
|
||||||
cmd.run()
|
|
||||||
};
|
|
||||||
|
|
||||||
release.assert_stdout_contains("x = 42");
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user