Skip to content

Commit

Permalink
Merge pull request #374 from workerwork/master
Browse files Browse the repository at this point in the history
fix: 删除 libc-test 不需要的文件
  • Loading branch information
elliott10 authored Sep 16, 2022
2 parents f9adf71 + 5528f51 commit ea7324f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
4 changes: 4 additions & 0 deletions xtask/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

最新的更新将出现在最上方。

## 20220916 (workerwork)

- 在把 libc-test 放入 rootfs 编译后,删除源码和编译中间文件,只保留可执行文件和动态库;

## 20220910 (YdrMaster)

- `bin` 时只要有 `linux` feature 就自动递归 `image`
Expand Down
39 changes: 38 additions & 1 deletion xtask/src/linux/test.rs
Original file line number Diff line number Diff line change
@@ -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。
Expand Down Expand Up @@ -32,6 +37,38 @@ impl super::LinuxRootfs {
)
.unwrap();
}

// 删除 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() != elf_path)
.for_each(|path| dir::rm(path.path()).unwrap());

fs::read_dir(&dir.join(&elf_path))
.unwrap()
.filter_map(Result::ok)
.filter(|path| !test_set.contains(&path.file_name()))
.for_each(|path| dir::rm(path.path()).unwrap());

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"))
.filter(|path| !path.file_name().into_string().unwrap().ends_with(".so"))
.for_each(|path| dir::rm(path.path()).unwrap());
}
}

/// 将其他测试放入 rootfs。
Expand Down

0 comments on commit ea7324f

Please sign in to comment.