xtask: remove hardcoded paths, better clean cmd
This commit is contained in:
parent
ac0432100d
commit
afdc86ef3a
@ -1,4 +1,5 @@
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
@ -154,17 +155,47 @@ pub fn clean_userspace(env: &BuildEnv) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn clean_all(env: &BuildEnv, clean_toolchain: bool) -> Result<(), Error> {
|
||||
pub fn clean_all(env: &BuildEnv, clean_toolchain: bool, repos: bool) -> Result<(), Error> {
|
||||
log::info!("Cleaning");
|
||||
|
||||
CargoBuilder::Host(env.verbose).run(&env.workspace_root, "clean")?;
|
||||
clean_userspace(env)?;
|
||||
fs::remove_dir_all(&env.llvm_sysroot)?;
|
||||
// Clean libm
|
||||
for target in Arch::all() {
|
||||
Command::new("make")
|
||||
.current_dir(
|
||||
env.workspace_root
|
||||
.join(format!("toolchain-c/libs/openlibm-{}", target.name())),
|
||||
)
|
||||
.arg("clean")
|
||||
.status()
|
||||
.ok();
|
||||
}
|
||||
|
||||
if clean_toolchain {
|
||||
if repos {
|
||||
fs::remove_dir_all(env.workspace_root.join("toolchain")).ok();
|
||||
fs::remove_dir_all(env.workspace_root.join("toolchain-c/llvm-project")).ok();
|
||||
fs::remove_dir_all(env.workspace_root.join("toolchain-c/libs")).ok();
|
||||
fs::remove_dir_all(env.workspace_root.join("toolchain-c/prefix")).ok();
|
||||
} else if clean_toolchain {
|
||||
// clean repos also cleans toolchain, so no need for this
|
||||
Command::new("./x")
|
||||
.current_dir(env.workspace_root.join("toolchain"))
|
||||
.arg("clean")
|
||||
.status()?;
|
||||
|
||||
// Clean host toolchain
|
||||
fs::remove_dir_all(env.workspace_root.join("toolchain-c/llvm-project/build")).ok();
|
||||
fs::remove_dir_all(env.workspace_root.join("toolchain-c/prefix")).ok();
|
||||
|
||||
for target in Arch::all() {
|
||||
fs::remove_dir_all(
|
||||
env.workspace_root
|
||||
.join(format!("toolchain-c/llvm-project/build-{}", target.name())),
|
||||
)
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -130,10 +130,12 @@ fn build_rootfs<S: AsRef<Path>, D: AsRef<Path>>(
|
||||
rootfs_dir.join("dynload-program"),
|
||||
)?;
|
||||
|
||||
util::copy_file(format!(
|
||||
"/home/alnyan/build/ygg/toolchain/build/host/stage1-std/{}-unknown-yggdrasil/release/libstd.so",
|
||||
env.arch.name()
|
||||
), rootfs_dir.join("lib/libstd.so"))?;
|
||||
let libstd_so = env.workspace_root.join(format!(
|
||||
"toolchain/build/host/stage1-std/{}-unknown-yggdrasil/release/libstd.so",
|
||||
env.arch.name()
|
||||
));
|
||||
|
||||
util::copy_file(libstd_so, rootfs_dir.join("lib/libstd.so"))?;
|
||||
|
||||
log::info!("Installing extras");
|
||||
for (src, dst) in install_extra {
|
||||
@ -206,11 +208,6 @@ pub fn build_initrd(
|
||||
|
||||
build_userspace(env, &mut install_extra, check)?;
|
||||
|
||||
install_extra.push((
|
||||
"toolchain-c/programs/lua-5.4.7/src/lua".into(),
|
||||
"lua".into(),
|
||||
));
|
||||
|
||||
build_rootfs(
|
||||
env,
|
||||
install_extra,
|
||||
|
@ -200,6 +200,10 @@ impl Profile {
|
||||
}
|
||||
|
||||
impl Arch {
|
||||
pub fn all() -> impl Iterator<Item = Self> {
|
||||
[Self::aarch64, Self::x86_64, Self::i686].into_iter()
|
||||
}
|
||||
|
||||
pub fn user_triple(&self) -> &str {
|
||||
match self {
|
||||
Self::aarch64 => "aarch64-unknown-yggdrasil",
|
||||
|
@ -63,6 +63,8 @@ enum SubArgs {
|
||||
Clean {
|
||||
#[clap(short, long, help = "Clean toolchain as well")]
|
||||
toolchain: bool,
|
||||
#[clap(short, long, help = "Clean cloned repositories")]
|
||||
repos: bool,
|
||||
},
|
||||
|
||||
// #[clap(about = "Print `git status` for the components", alias = "gst")]
|
||||
@ -131,7 +133,7 @@ fn run(args: Args) -> Result<(), Error> {
|
||||
SubArgs::Check => build::check_all(env, CheckAction::Check),
|
||||
SubArgs::Clippy => build::check_all(env, CheckAction::Clippy),
|
||||
SubArgs::Test => build::test_all(env),
|
||||
SubArgs::Clean { toolchain } => build::clean_all(&env, toolchain),
|
||||
SubArgs::Clean { toolchain, repos } => build::clean_all(&env, toolchain, repos),
|
||||
// SubArgs::GitStatus => util::git_status_all(&env),
|
||||
SubArgs::Qemu {
|
||||
qemu,
|
||||
|
Loading…
x
Reference in New Issue
Block a user