Merge commit 'e4fe941b11a55c5005630696e9b6d81c65f7bd04' into subtree-update_cg_gcc_2023-10-25
This commit is contained in:
@@ -4,7 +4,7 @@ use crate::utils::{cargo_install, git_clone, run_command, run_command_with_outpu
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
fn prepare_libcore(sysroot_path: &Path) -> Result<(), String> {
|
||||
fn prepare_libcore(sysroot_path: &Path, libgccjit12_patches: bool, cross_compile: bool) -> Result<(), String> {
|
||||
let rustc_path = match get_rustc_path() {
|
||||
Some(path) => path,
|
||||
None => return Err("`rustc` path not found".to_string()),
|
||||
@@ -87,6 +87,22 @@ fn prepare_libcore(sysroot_path: &Path) -> Result<(), String> {
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
if cross_compile {
|
||||
walk_dir("cross_patches", |_| Ok(()), |file_path: &Path| {
|
||||
patches.push(file_path.to_path_buf());
|
||||
Ok(())
|
||||
})?;
|
||||
}
|
||||
if libgccjit12_patches {
|
||||
walk_dir(
|
||||
"patches/libgccjit12",
|
||||
|_| Ok(()),
|
||||
|file_path: &Path| {
|
||||
patches.push(file_path.to_path_buf());
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
}
|
||||
patches.sort();
|
||||
for file_path in patches {
|
||||
println!("[GIT] apply `{}`", file_path.display());
|
||||
@@ -156,16 +172,22 @@ where
|
||||
}
|
||||
|
||||
struct PrepareArg {
|
||||
cross_compile: bool,
|
||||
only_libcore: bool,
|
||||
libgccjit12_patches: bool,
|
||||
}
|
||||
|
||||
impl PrepareArg {
|
||||
fn new() -> Result<Option<Self>, String> {
|
||||
let mut only_libcore = false;
|
||||
let mut cross_compile = false;
|
||||
let mut libgccjit12_patches = false;
|
||||
|
||||
for arg in std::env::args().skip(2) {
|
||||
match arg.as_str() {
|
||||
"--only-libcore" => only_libcore = true,
|
||||
"--cross" => cross_compile = true,
|
||||
"--libgccjit12-patches" => libgccjit12_patches = true,
|
||||
"--help" => {
|
||||
Self::usage();
|
||||
return Ok(None);
|
||||
@@ -173,7 +195,11 @@ impl PrepareArg {
|
||||
a => return Err(format!("Unknown argument `{a}`")),
|
||||
}
|
||||
}
|
||||
Ok(Some(Self { only_libcore }))
|
||||
Ok(Some(Self {
|
||||
cross_compile,
|
||||
only_libcore,
|
||||
libgccjit12_patches,
|
||||
}))
|
||||
}
|
||||
|
||||
fn usage() {
|
||||
@@ -181,8 +207,10 @@ impl PrepareArg {
|
||||
r#"
|
||||
`prepare` command help:
|
||||
|
||||
--only-libcore : Only setup libcore and don't clone other repositories
|
||||
--help : Show this help
|
||||
--only-libcore : Only setup libcore and don't clone other repositories
|
||||
--cross : Apply the patches needed to do cross-compilation
|
||||
--libgccjit12-patches : Apply patches needed for libgccjit12
|
||||
--help : Show this help
|
||||
"#
|
||||
)
|
||||
}
|
||||
@@ -194,7 +222,7 @@ pub fn run() -> Result<(), String> {
|
||||
None => return Ok(()),
|
||||
};
|
||||
let sysroot_path = Path::new("build_sysroot");
|
||||
prepare_libcore(sysroot_path)?;
|
||||
prepare_libcore(sysroot_path, args.libgccjit12_patches, args.cross_compile)?;
|
||||
|
||||
if !args.only_libcore {
|
||||
cargo_install("hyperfine")?;
|
||||
|
||||
Reference in New Issue
Block a user