Skip to content

Commit 397a479

Browse files
committed
kbuild: simplify rustfmt target
There is no need to prune the rust/alloc directory because it was removed by commit 9d0441b ("rust: alloc: remove our fork of the `alloc` crate"). There is no need to prune the rust/test directory because no '*.rs' files are generated within it. To avoid forking the 'grep -Fv generated' process, filter out generated files using the option, ! -name '*generated*'. Now that the '-path ... -prune' option is no longer used, there is no need to use the absolute path. Searching in $(srctree), which can be a relative path, is sufficient. The comment mentions the use case where $(srctree) is '..', that is, $(objtree) is a sub-directory of $(srctree). In this scenario, all '*.rs' files under $(objtree) are generated files and filters out by the '*generated*' pattern. Add $(RCS_FIND_IGNORE) as a shortcut. Although I do not believe '*.rs' files would exist under the .git directory, there is no need for the 'find' command to traverse it. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nicolas Schier <[email protected]> Acked-by: Miguel Ojeda <[email protected]>
1 parent a49401b commit 397a479

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

Makefile

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,18 +1754,9 @@ rusttest: prepare
17541754
# Formatting targets
17551755
PHONY += rustfmt rustfmtcheck
17561756

1757-
# We skip `rust/alloc` since we want to minimize the diff w.r.t. upstream.
1758-
#
1759-
# We match using absolute paths since `find` does not resolve them
1760-
# when matching, which is a problem when e.g. `srctree` is `..`.
1761-
# We `grep` afterwards in order to remove the directory entry itself.
17621757
rustfmt:
1763-
$(Q)find $(abs_srctree) -type f -name '*.rs' \
1764-
-o -path $(abs_srctree)/rust/alloc -prune \
1765-
-o -path $(abs_objtree)/rust/test -prune \
1766-
| grep -Fv $(abs_srctree)/rust/alloc \
1767-
| grep -Fv $(abs_objtree)/rust/test \
1768-
| grep -Fv generated \
1758+
$(Q)find $(srctree) $(RCS_FIND_IGNORE) \
1759+
-type f -a -name '*.rs' -a ! -name '*generated*' -print \
17691760
| xargs $(RUSTFMT) $(rustfmt_flags)
17701761

17711762
rustfmtcheck: rustfmt_flags = --check

0 commit comments

Comments
 (0)