diff mbox series

[XEN,v8,10/47] build: rework cloc recipe

Message ID 20211125134006.1076646-11-anthony.perard@citrix.com (mailing list archive)
State Superseded
Headers show
Series xen: Build system improvements, now with out-of-tree build! | expand

Commit Message

Anthony PERARD Nov. 25, 2021, 1:39 p.m. UTC
We are going to make other modifications to the cloc recipe, so this
patch prepare make those modification easier.

We replace the Makefile meta programming by just a shell script which
should be easier to read and is actually faster to execute.

Instead of looking for files in "$(BASEDIR)", we use "." which is give
the same result overall. We also avoid the need for a temporary file
as cloc can read the list of files from stdin.

No change intended to the output of `cloc`.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    v8:
    - rework cloc patch, move it ahead of problematic changes
      this is only a convertion to shell script with a single other change.

 xen/Makefile | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

Comments

Jan Beulich Dec. 6, 2021, 5:03 p.m. UTC | #1
On 25.11.2021 14:39, Anthony PERARD wrote:
> We are going to make other modifications to the cloc recipe, so this
> patch prepare make those modification easier.
> 
> We replace the Makefile meta programming by just a shell script which
> should be easier to read and is actually faster to execute.
> 
> Instead of looking for files in "$(BASEDIR)", we use "." which is give
> the same result overall. We also avoid the need for a temporary file
> as cloc can read the list of files from stdin.
> 
> No change intended to the output of `cloc`.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
diff mbox series

Patch

diff --git a/xen/Makefile b/xen/Makefile
index 7bb3595d649f..6afae6ced37c 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -477,14 +477,12 @@  _MAP:
 
 .PHONY: cloc
 cloc:
-	$(eval tmpfile := $(shell mktemp))
-	$(foreach f, $(shell find $(BASEDIR) -name *.o.d), \
-		$(eval path := $(dir $(f))) \
-		$(eval names := $(shell grep -o "[a-zA-Z0-9_/-]*\.[cS]" $(f))) \
-		$(foreach sf, $(names), \
-			$(shell if test -f $(path)/$(sf) ; then echo $(path)/$(sf) >> $(tmpfile); fi;)))
-	cloc --list-file=$(tmpfile)
-	rm $(tmpfile)
+	find . -name '*.o.d' | while read f; do \
+	    for sf in $$(grep -o "[a-zA-Z0-9_/-]*\.[cS]" $$f); do \
+		sf="$$(dirname $$f)/$$sf"; \
+		test -f "$$sf" && echo "$$sf"; \
+	    done; \
+	done | cloc --list-file=-
 
 endif #config-build