Skip to content

Commit

Permalink
rustbuild: Migrate tidy checks to Rust
Browse files Browse the repository at this point in the history
This commit rewrites all of the tidy checks we have, namely:

* featureck
* errorck
* tidy
* binaries

into Rust under a new `tidy` tool inside of the `src/tools` directory. This at
the same time deletes all the corresponding Python tidy checks so we can be sure
to only have one source of truth for all the tidy checks.

cc rust-lang#31590
  • Loading branch information
alexcrichton committed Apr 12, 2016
1 parent bed32d8 commit 9dd3c54
Show file tree
Hide file tree
Showing 24 changed files with 547 additions and 742 deletions.
54 changes: 9 additions & 45 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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))
$< $(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)) src/tools/tidy/src/main.rs \
--out-dir $(@D) --crate-name tidy

######################################################################
# Sets of tests
Expand Down
7 changes: 7 additions & 0 deletions src/bootstrap/build/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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),
Expand Down
9 changes: 8 additions & 1 deletion src/bootstrap/build/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }),
Expand Down Expand Up @@ -316,8 +318,13 @@ 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 } |
Source::ToolCargoTest { stage } => {
vec![self.libstd(self.compiler(stage))]
}
Source::ToolErrorIndex { stage } |
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/mk/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9dd3c54

Please sign in to comment.