From c2973bb03638c4537d51efe82810b1c45602560f Mon Sep 17 00:00:00 2001 From: workerwork Date: Thu, 15 Sep 2022 22:50:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=20libc-test=20?= =?UTF-8?q?=E4=B8=8D=E9=9C=80=E8=A6=81=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xtask/src/linux/test.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/xtask/src/linux/test.rs b/xtask/src/linux/test.rs index 81fb33cb8..8208d4a58 100644 --- a/xtask/src/linux/test.rs +++ b/xtask/src/linux/test.rs @@ -32,6 +32,30 @@ impl super::LinuxRootfs { ) .unwrap(); } + + // 删除 libc-test 不必要的文件 + fs::read_dir(&dir) + .unwrap() + .filter_map(Result::ok) + .filter(|path| path.file_name() != "src") + .for_each(|path| dir::rm(path.path()).unwrap()); + + fs::read_dir(&dir.join("src")) + .unwrap() + .filter_map(Result::ok) + .filter(|path| path.file_name() != "math") + .filter(|path| path.file_name() != "functional") + .filter(|path| path.file_name() != "regression") + .for_each(|path| dir::rm(path.path()).unwrap()); + + for item in ["math", "functional", "regression"] { + fs::read_dir(&dir.join("src").join(item)) + .unwrap() + .filter_map(Result::ok) + .filter(|path| !path.file_name().into_string().unwrap().ends_with(".exe")) + .filter(|path| !path.file_name().into_string().unwrap().ends_with(".so")) + .for_each(|path| dir::rm(path.path()).unwrap()); + } } /// 将其他测试放入 rootfs。 From 5528f51e00ae81390f5d8c463e54a6b037b15b69 Mon Sep 17 00:00:00 2001 From: workerwork Date: Fri, 16 Sep 2022 16:43:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=20libc-test=20?= =?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xtask/CHANGELOG.md | 4 ++++ xtask/src/linux/test.rs | 29 +++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/xtask/CHANGELOG.md b/xtask/CHANGELOG.md index 0486996bf..24e1766c3 100644 --- a/xtask/CHANGELOG.md +++ b/xtask/CHANGELOG.md @@ -2,6 +2,10 @@ 最新的更新将出现在最上方。 +## 20220916 (workerwork) + +- 在把 libc-test 放入 rootfs 编译后,删除源码和编译中间文件,只保留可执行文件和动态库; + ## 20220910 (YdrMaster) - `bin` 时只要有 `linux` feature 就自动递归 `image`; diff --git a/xtask/src/linux/test.rs b/xtask/src/linux/test.rs index 8208d4a58..68cc6c257 100644 --- a/xtask/src/linux/test.rs +++ b/xtask/src/linux/test.rs @@ -1,7 +1,12 @@ use super::join_path_env; use crate::{commands::wget, Arch}; use command_ext::{dir, CommandExt, Ext, Make, Tar}; -use std::{ffi::OsStr, fs, path::PathBuf}; +use std::{ + collections::HashSet, + ffi::{OsStr, OsString}, + fs, + path::PathBuf, +}; impl super::LinuxRootfs { /// 将 libc-test 放入 rootfs。 @@ -34,22 +39,30 @@ impl super::LinuxRootfs { } // 删除 libc-test 不必要的文件 + let elf_path = OsString::from("src"); + let test_set = HashSet::from([ + OsString::from("api"), + OsString::from("common"), + OsString::from("math"), + OsString::from("musl"), + OsString::from("functional"), + OsString::from("regression"), + ]); + fs::read_dir(&dir) .unwrap() .filter_map(Result::ok) - .filter(|path| path.file_name() != "src") + .filter(|path| path.file_name() != elf_path) .for_each(|path| dir::rm(path.path()).unwrap()); - fs::read_dir(&dir.join("src")) + fs::read_dir(&dir.join(&elf_path)) .unwrap() .filter_map(Result::ok) - .filter(|path| path.file_name() != "math") - .filter(|path| path.file_name() != "functional") - .filter(|path| path.file_name() != "regression") + .filter(|path| !test_set.contains(&path.file_name())) .for_each(|path| dir::rm(path.path()).unwrap()); - for item in ["math", "functional", "regression"] { - fs::read_dir(&dir.join("src").join(item)) + for item in test_set { + fs::read_dir(&dir.join(&elf_path).join(item)) .unwrap() .filter_map(Result::ok) .filter(|path| !path.file_name().into_string().unwrap().ends_with(".exe"))