Skip to content

Commit

Permalink
save dev state
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Feb 27, 2024
1 parent b6e4299 commit 05b8bd6
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 16 deletions.
19 changes: 19 additions & 0 deletions src/bootstrap/src/core/build_steps/lint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use crate::core::builder::Builder;
use std::path::PathBuf;

pub fn lint(build: &Builder<'_>, paths: &[PathBuf]) {
if build.config.dry_run() {
return;
}

let compiler = build.compiler(0, build.config.build);

for path in paths {
let mut clippy = build.cargo_clippy_cmd(compiler);
clippy.current_dir(path);

clippy.env("RUSTC_BOOTSTRAP", "1");
clippy.args(["--all-targets", "--all-features", "--", "--D", "warnings"]);
build.run(&mut clippy);
}
}
1 change: 1 addition & 0 deletions src/bootstrap/src/core/build_steps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub(crate) mod dist;
pub(crate) mod doc;
pub(crate) mod format;
pub(crate) mod install;
pub(crate) mod lint;
pub(crate) mod llvm;
pub(crate) mod run;
pub(crate) mod setup;
Expand Down
41 changes: 41 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,47 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to
crate::exit!(1);
}
crate::core::build_steps::format::format(builder, !builder.config.cmd.bless(), &[]);

// TODO: don't run this by default (check if clippy is enabled in the build configuration)
builder.info("lint check");
crate::core::build_steps::lint::lint(
builder,
&[
// builder.src.join("src/bootstrap"),
builder.src.join("src/tools/build_helper"),
builder.src.join("src/tools/build-manifest"),
builder.src.join("src/tools/bump-stage0"),
builder.src.join("src/tools/cargotest"),
builder.src.join("src/tools/collect-license-metadata"),
builder.src.join("src/tools/compiletest"),
builder.src.join("src/tools/coverage-dump"),
builder.src.join("src/tools/error_index_generator"),
builder.src.join("src/tools/expand-yaml-anchors"),
builder.src.join("src/tools/generate-copyright"),
builder.src.join("src/tools/generate-windows-sys"),
builder.src.join("src/tools/html-checker"),
builder.src.join("src/tools/jsondocck"),
builder.src.join("src/tools/jsondoclint"),
builder.src.join("src/tools/linkchecker"),
builder.src.join("src/tools/lint-docs"),
builder.src.join("src/tools/lld-wrapper"),
builder.src.join("src/tools/miropt-test-tools"),
builder.src.join("src/tools/opt-dist"),
builder.src.join("src/tools/remote-test-client"),
builder.src.join("src/tools/remote-test-server"),
builder.src.join("src/tools/replace-version-placeholder"),
builder.src.join("src/tools/rust-demangler"),
builder.src.join("src/tools/rust-installer"),
builder.src.join("src/tools/rustbook"),
builder.src.join("src/tools/rustdoc-gui-test"),
builder.src.join("src/tools/rustdoc-themes"),
builder.src.join("src/tools/suggest-tests"),
builder.src.join("src/tools/tier-check"),
builder.src.join("src/tools/unicode-table-generator"),
builder.src.join("src/tools/unstable-book-gen"),
builder.src.join("src/tools/x"),
],
);
}

builder.info("tidy check");
Expand Down
2 changes: 1 addition & 1 deletion src/tools/build_helper/src/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl CiEnv {
// The explicit `TERM=xterm` environment is needed for
// `--color always` to actually work. This env var was lost when
// compiling through the Makefile. Very strange.
cmd.env("TERM", "xterm").args(&["--color", "always"]);
cmd.env("TERM", "xterm").args(["--color", "always"]);
}
}
}
Expand Down
26 changes: 11 additions & 15 deletions src/tools/build_helper/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn output_result(cmd: &mut Command) -> Result<String, String> {
String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))?
));
}
Ok(String::from_utf8(output.stdout).map_err(|err| format!("{err:?}"))?)
String::from_utf8(output.stdout).map_err(|err| format!("{err:?}"))
}

/// Finds the remote for rust-lang/rust.
Expand Down Expand Up @@ -64,18 +64,14 @@ pub fn rev_exists(rev: &str, git_dir: Option<&Path>) -> Result<bool, String> {
match output.status.code() {
Some(0) => Ok(true),
Some(128) => Ok(false),
None => {
return Err(format!(
"git didn't exit properly: {}",
String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))?
));
}
Some(code) => {
return Err(format!(
"git command exited with status code: {code}: {}",
String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))?
));
}
None => Err(format!(
"git didn't exit properly: {}",
String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))?
)),
Some(code) => Err(format!(
"git command exited with status code: {code}: {}",
String::from_utf8(output.stderr).map_err(|err| format!("{err:?}"))?
)),
}
}

Expand All @@ -96,7 +92,7 @@ pub fn updated_master_branch(
}
}

Err(format!("Cannot find any suitable upstream master branch"))
Err("Cannot find any suitable upstream master branch".to_string())
}

pub fn get_git_merge_base(
Expand All @@ -117,7 +113,7 @@ pub fn get_git_merge_base(
pub fn get_git_modified_files(
config: &GitConfig<'_>,
git_dir: Option<&Path>,
extensions: &Vec<&str>,
extensions: &[&str],
) -> Result<Option<Vec<String>>, String> {
let merge_base = get_git_merge_base(config, git_dir)?;

Expand Down
1 change: 1 addition & 0 deletions src/tools/build_helper/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub fn fail(s: &str) -> ! {
detail_exit(1, cfg!(test));
}

#[allow(clippy::result_unit_err)]
pub fn try_run(cmd: &mut Command, print_cmd_on_fail: bool) -> Result<(), ()> {
let status = match cmd.status() {
Ok(status) => status,
Expand Down

0 comments on commit 05b8bd6

Please sign in to comment.