Skip to content

Commit

Permalink
Auto merge of #66681 - Mark-Simulacrum:toolstate-into-bootstrap, r=pi…
Browse files Browse the repository at this point in the history
…etroalbini

Move toolstate checking into bootstrap

This intends no functional changes, merely translates the spread of shell/python into Rust.

One problematic area that I'd like to avoid but wasn't quite able to figure out how is the master branch script which is still in bash/python -- I cared less about that since it is orthogonal to the actual checking that we're doing, though as-is we're duplicating some code across Rust and that script.

r? @kennytm or maybe @pietroalbini
  • Loading branch information
bors committed Dec 10, 2019
2 parents 8960acf + 97d9364 commit 7dbfb0a
Show file tree
Hide file tree
Showing 10 changed files with 445 additions and 266 deletions.
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ impl<'a> Builder<'a> {
check::Rustdoc
),
Kind::Test => describe!(
crate::toolstate::ToolStateCheck,
test::Tidy,
test::Ui,
test::CompileFail,
Expand Down
27 changes: 0 additions & 27 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ mod job {
pub use crate::config::Config;
use crate::flags::Subcommand;
use crate::cache::{Interned, INTERNER};
use crate::toolstate::ToolState;

const LLVM_TOOLS: &[&str] = &[
"llvm-nm", // used to inspect binaries; it shows symbol names, their sizes and visibility
Expand Down Expand Up @@ -1074,32 +1073,6 @@ impl Build {
}
}

/// Updates the actual toolstate of a tool.
///
/// The toolstates are saved to the file specified by the key
/// `rust.save-toolstates` in `config.toml`. If unspecified, nothing will be
/// done. The file is updated immediately after this function completes.
pub fn save_toolstate(&self, tool: &str, state: ToolState) {
if let Some(ref path) = self.config.save_toolstates {
if let Some(parent) = path.parent() {
// Ensure the parent directory always exists
t!(std::fs::create_dir_all(parent));
}
let mut file = t!(fs::OpenOptions::new()
.create(true)
.read(true)
.write(true)
.open(path));

let mut current_toolstates: HashMap<Box<str>, ToolState> =
serde_json::from_reader(&mut file).unwrap_or_default();
current_toolstates.insert(tool.into(), state);
t!(file.seek(SeekFrom::Start(0)));
t!(file.set_len(0));
t!(serde_json::to_writer(file, &current_toolstates));
}
}

fn in_tree_crates(&self, root: &str) -> Vec<&Crate> {
let mut ret = Vec::new();
let mut list = vec![INTERNER.intern_str(root)];
Expand Down
Loading

0 comments on commit 7dbfb0a

Please sign in to comment.