Skip to content

rustbuild: Migrate tidy checks to Rust #32590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 9 additions & 45 deletions mk/tests.mk
Original file line number Diff line number Diff line change
@@ -240,52 +240,16 @@ cleantestlibs:
# Tidy
######################################################################

ifdef CFG_NOTIDY
.PHONY: tidy
tidy:
else

# Run the tidy script in multiple parts to avoid huge 'echo' commands
.PHONY: tidy
tidy: tidy-basic tidy-binaries tidy-errors tidy-features

endif

.PHONY: tidy-basic
tidy-basic:
@$(call E, check: formatting)
$(Q) $(CFG_PYTHON) $(S)src/etc/tidy.py $(S)src/

.PHONY: tidy-binaries
tidy-binaries:
@$(call E, check: binaries)
$(Q)find $(S)src -type f \
\( -perm -u+x -or -perm -g+x -or -perm -o+x \) \
-not -name '*.rs' -and -not -name '*.py' \
-and -not -name '*.sh' -and -not -name '*.pp' \
| grep '^$(S)src/jemalloc' -v \
| grep '^$(S)src/libuv' -v \
| grep '^$(S)src/llvm' -v \
| grep '^$(S)src/rt/hoedown' -v \
| grep '^$(S)src/gyp' -v \
| grep '^$(S)src/etc' -v \
| grep '^$(S)src/doc' -v \
| grep '^$(S)src/compiler-rt' -v \
| grep '^$(S)src/libbacktrace' -v \
| grep '^$(S)src/rust-installer' -v \
| grep '^$(S)src/liblibc' -v \
| xargs $(CFG_PYTHON) $(S)src/etc/check-binaries.py

.PHONY: tidy-errors
tidy-errors:
@$(call E, check: extended errors)
$(Q) $(CFG_PYTHON) $(S)src/etc/errorck.py $(S)src/

.PHONY: tidy-features
tidy-features:
@$(call E, check: feature sanity)
$(Q) $(CFG_PYTHON) $(S)src/etc/featureck.py $(S)src/

tidy: $(HBIN0_H_$(CFG_BUILD))/tidy$(X_$(CFG_BUILD))
$(TARGET_RPATH_VAR0_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $< $(S)src

$(HBIN0_H_$(CFG_BUILD))/tidy$(X_$(CFG_BUILD)): \
$(TSREQ0_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
$(TLIB0_T_$(CFG_BUILD)_H_$(CFG_BUILD))/stamp.std \
$(call rwildcard,$(S)src/tools/tidy/src,*.rs)
$(STAGE0_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(S)src/tools/tidy/src/main.rs \
--out-dir $(@D) --crate-name tidy

######################################################################
# Sets of tests
7 changes: 7 additions & 0 deletions src/bootstrap/build/check.rs
Original file line number Diff line number Diff line change
@@ -33,3 +33,10 @@ pub fn cargotest(build: &Build, stage: u32, host: &str) {
.env("PATH", newpath)
.arg(&build.cargo));
}

pub fn tidy(build: &Build, stage: u32, host: &str) {
println!("tidy check stage{} ({})", stage, host);
let compiler = Compiler::new(stage, host);
build.run(build.tool_cmd(&compiler, "tidy")
.arg(build.src.join("src")));
}
6 changes: 6 additions & 0 deletions src/bootstrap/build/mod.rs
Original file line number Diff line number Diff line change
@@ -197,6 +197,9 @@ impl Build {
ToolCargoTest { stage } => {
compile::tool(self, stage, target.target, "cargotest");
}
ToolTidy { stage } => {
compile::tool(self, stage, target.target, "tidy");
}
DocBook { stage } => {
doc::rustbook(self, stage, target.target, "book", &doc_out);
}
@@ -230,6 +233,9 @@ impl Build {
CheckCargoTest { stage } => {
check::cargotest(self, stage, target.target);
}
CheckTidy { stage } => {
check::tidy(self, stage, target.target);
}

DistDocs { stage } => dist::docs(self, stage, target.target),
DistMingw { _dummy } => dist::mingw(self, target.target),
8 changes: 7 additions & 1 deletion src/bootstrap/build/step.rs
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ macro_rules! targets {
(tool_rustbook, ToolRustbook { stage: u32 }),
(tool_error_index, ToolErrorIndex { stage: u32 }),
(tool_cargotest, ToolCargoTest { stage: u32 }),
(tool_tidy, ToolTidy { stage: u32 }),

// Steps for long-running native builds. Ideally these wouldn't
// actually exist and would be part of build scripts, but for now
@@ -79,6 +80,7 @@ macro_rules! targets {
(check, Check { stage: u32, compiler: Compiler<'a> }),
(check_linkcheck, CheckLinkcheck { stage: u32 }),
(check_cargotest, CheckCargoTest { stage: u32 }),
(check_tidy, CheckTidy { stage: u32 }),

// Distribution targets, creating tarballs
(dist, Dist { stage: u32 }),
@@ -316,8 +318,12 @@ impl<'a> Step<'a> {
Source::CheckCargoTest { stage } => {
vec![self.tool_cargotest(stage)]
}
Source::CheckTidy { stage } => {
vec![self.tool_tidy(stage)]
}

Source::ToolLinkchecker { stage } => {
Source::ToolLinkchecker { stage } |
Source::ToolTidy { stage } => {
vec![self.libstd(self.compiler(stage))]
}
Source::ToolErrorIndex { stage } |
2 changes: 2 additions & 0 deletions src/bootstrap/mk/Makefile.in
Original file line number Diff line number Diff line change
@@ -42,5 +42,7 @@ check-cargotest:
$(Q)$(BOOTSTRAP) --step check-cargotest
dist:
$(Q)$(BOOTSTRAP) --step dist
tidy:
$(Q)$(BOOTSTRAP) --step check-tidy --stage 0

.PHONY: dist
20 changes: 0 additions & 20 deletions src/etc/check-binaries.py

This file was deleted.

136 changes: 0 additions & 136 deletions src/etc/errorck.py

This file was deleted.

Loading