mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-18 18:04:13 +00:00
Auto merge of #113965 - chenyukang:yukang-fix-113963-panic, r=ozkanonur
Fix test panics for submodule of book is not updated Fixes #113963
This commit is contained in:
commit
d9d80e211e
@ -16,7 +16,7 @@ use crate::cache::{Interned, INTERNER};
|
|||||||
use crate::compile;
|
use crate::compile;
|
||||||
use crate::config::{Config, TargetSelection};
|
use crate::config::{Config, TargetSelection};
|
||||||
use crate::tool::{self, prepare_tool_cargo, SourceType, Tool};
|
use crate::tool::{self, prepare_tool_cargo, SourceType, Tool};
|
||||||
use crate::util::{symlink_dir, t, up_to_date};
|
use crate::util::{dir_is_empty, symlink_dir, t, up_to_date};
|
||||||
use crate::Mode;
|
use crate::Mode;
|
||||||
|
|
||||||
macro_rules! submodule_helper {
|
macro_rules! submodule_helper {
|
||||||
@ -197,11 +197,21 @@ impl Step for TheBook {
|
|||||||
let compiler = self.compiler;
|
let compiler = self.compiler;
|
||||||
let target = self.target;
|
let target = self.target;
|
||||||
|
|
||||||
|
let absolute_path = builder.src.join(&relative_path);
|
||||||
|
let redirect_path = absolute_path.join("redirects");
|
||||||
|
if !absolute_path.exists()
|
||||||
|
|| !redirect_path.exists()
|
||||||
|
|| dir_is_empty(&absolute_path)
|
||||||
|
|| dir_is_empty(&redirect_path)
|
||||||
|
{
|
||||||
|
eprintln!("Please checkout submodule: {}", relative_path.display());
|
||||||
|
crate::exit!(1);
|
||||||
|
}
|
||||||
// build book
|
// build book
|
||||||
builder.ensure(RustbookSrc {
|
builder.ensure(RustbookSrc {
|
||||||
target,
|
target,
|
||||||
name: INTERNER.intern_str("book"),
|
name: INTERNER.intern_str("book"),
|
||||||
src: INTERNER.intern_path(builder.src.join(&relative_path)),
|
src: INTERNER.intern_path(absolute_path.clone()),
|
||||||
parent: Some(self),
|
parent: Some(self),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -210,7 +220,7 @@ impl Step for TheBook {
|
|||||||
builder.ensure(RustbookSrc {
|
builder.ensure(RustbookSrc {
|
||||||
target,
|
target,
|
||||||
name: INTERNER.intern_string(format!("book/{}", edition)),
|
name: INTERNER.intern_string(format!("book/{}", edition)),
|
||||||
src: INTERNER.intern_path(builder.src.join(&relative_path).join(edition)),
|
src: INTERNER.intern_path(absolute_path.join(edition)),
|
||||||
// There should only be one book that is marked as the parent for each target, so
|
// There should only be one book that is marked as the parent for each target, so
|
||||||
// treat the other editions as not having a parent.
|
// treat the other editions as not having a parent.
|
||||||
parent: Option::<Self>::None,
|
parent: Option::<Self>::None,
|
||||||
@ -225,7 +235,7 @@ impl Step for TheBook {
|
|||||||
|
|
||||||
// build the redirect pages
|
// build the redirect pages
|
||||||
let _guard = builder.msg_doc(compiler, "book redirect pages", target);
|
let _guard = builder.msg_doc(compiler, "book redirect pages", target);
|
||||||
for file in t!(fs::read_dir(builder.src.join(&relative_path).join("redirects"))) {
|
for file in t!(fs::read_dir(redirect_path)) {
|
||||||
let file = t!(file);
|
let file = t!(file);
|
||||||
let path = file.path();
|
let path = file.path();
|
||||||
let path = path.to_str().unwrap();
|
let path = path.to_str().unwrap();
|
||||||
|
@ -36,7 +36,7 @@ use once_cell::sync::OnceCell;
|
|||||||
use crate::builder::Kind;
|
use crate::builder::Kind;
|
||||||
use crate::config::{LlvmLibunwind, TargetSelection};
|
use crate::config::{LlvmLibunwind, TargetSelection};
|
||||||
use crate::util::{
|
use crate::util::{
|
||||||
exe, libdir, mtime, output, run, run_suppressed, symlink_dir, try_run_suppressed,
|
dir_is_empty, exe, libdir, mtime, output, run, run_suppressed, symlink_dir, try_run_suppressed,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod bolt;
|
mod bolt;
|
||||||
@ -535,10 +535,6 @@ impl Build {
|
|||||||
///
|
///
|
||||||
/// `relative_path` should be relative to the root of the git repository, not an absolute path.
|
/// `relative_path` should be relative to the root of the git repository, not an absolute path.
|
||||||
pub(crate) fn update_submodule(&self, relative_path: &Path) {
|
pub(crate) fn update_submodule(&self, relative_path: &Path) {
|
||||||
fn dir_is_empty(dir: &Path) -> bool {
|
|
||||||
t!(std::fs::read_dir(dir)).next().is_none()
|
|
||||||
}
|
|
||||||
|
|
||||||
if !self.config.submodules(&self.rust_info()) {
|
if !self.config.submodules(&self.rust_info()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -493,3 +493,7 @@ pub fn lld_flag_no_threads(is_windows: bool) -> &'static str {
|
|||||||
});
|
});
|
||||||
if is_windows { windows } else { other }
|
if is_windows { windows } else { other }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn dir_is_empty(dir: &Path) -> bool {
|
||||||
|
t!(std::fs::read_dir(dir)).next().is_none()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user