diff mbox series

[bpf-next,2/4] tools/resolve_btfids: Check objects before removing

Message ID 20210204211825.588160-3-jolsa@kernel.org (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series kbuild/resolve_btfids: Invoke resolve_btfids clean in root Makefile | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 5 maintainers not CCed: jean-philippe@linaro.org toke@redhat.com andrii@kernel.org rafael.j.wysocki@intel.com kpsingh@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 25 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Jiri Olsa Feb. 4, 2021, 9:18 p.m. UTC
We want this clean to be called from tree's root clean
and that one is silent if there's nothing to clean.

Adding check for all object to clean and display CLEAN
messages only if there are objects to remove.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/bpf/resolve_btfids/Makefile | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

Comments

Song Liu Feb. 4, 2021, 11:41 p.m. UTC | #1
> On Feb 4, 2021, at 1:18 PM, Jiri Olsa <jolsa@kernel.org> wrote:
> 
> We want this clean to be called from tree's root clean
> and that one is silent if there's nothing to clean.
> 
> Adding check for all object to clean and display CLEAN
> messages only if there are objects to remove.
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
> tools/bpf/resolve_btfids/Makefile | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
> index b780b3a9fb07..3007cfabf5e6 100644
> --- a/tools/bpf/resolve_btfids/Makefile
> +++ b/tools/bpf/resolve_btfids/Makefile
> @@ -64,13 +64,20 @@ $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
> 	$(call msg,LINK,$@)
> 	$(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
> 
> +clean_objects := $(wildcard $(OUTPUT)/*.o                \
> +                            $(OUTPUT)/.*.o.cmd           \
> +                            $(OUTPUT)/.*.o.d             \
> +                            $(OUTPUT)/libbpf             \
> +                            $(OUTPUT)/libsubcmd          \
> +                            $(OUTPUT)/resolve_btfids)
> +
> +clean:
> +
> +ifneq ($(clean_objects),)
> clean: fixdep-clean
> 	$(call msg,CLEAN,$(BINARY))
> -	$(Q)$(RM) -f $(BINARY); \
> -	$(RM) -rf $(if $(OUTPUT),$(OUTPUT),.)/feature; \
> -	$(RM) -rf $(OUTPUT)libbpf; \
> -	$(RM) -rf $(OUTPUT)libsubcmd; \
> -	find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
> +	$(Q)$(RM) -rf $(clean_objects)
> +endif
> 
> tags:
> 	$(call msg,GEN,,tags)
> -- 
> 2.26.2
>
Andrii Nakryiko Feb. 5, 2021, 12:42 a.m. UTC | #2
On Thu, Feb 4, 2021 at 1:20 PM Jiri Olsa <jolsa@kernel.org> wrote:
>
> We want this clean to be called from tree's root clean
> and that one is silent if there's nothing to clean.
>
> Adding check for all object to clean and display CLEAN
> messages only if there are objects to remove.
>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/bpf/resolve_btfids/Makefile | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
> index b780b3a9fb07..3007cfabf5e6 100644
> --- a/tools/bpf/resolve_btfids/Makefile
> +++ b/tools/bpf/resolve_btfids/Makefile
> @@ -64,13 +64,20 @@ $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
>         $(call msg,LINK,$@)
>         $(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
>
> +clean_objects := $(wildcard $(OUTPUT)/*.o                \
> +                            $(OUTPUT)/.*.o.cmd           \
> +                            $(OUTPUT)/.*.o.d             \
> +                            $(OUTPUT)/libbpf             \
> +                            $(OUTPUT)/libsubcmd          \
> +                            $(OUTPUT)/resolve_btfids)
> +
> +clean:
> +
> +ifneq ($(clean_objects),)
>  clean: fixdep-clean

this looks a bit weird, declaring clean twice. Wouldn't moving ifneq
inside the clean work just fine?

>         $(call msg,CLEAN,$(BINARY))
> -       $(Q)$(RM) -f $(BINARY); \
> -       $(RM) -rf $(if $(OUTPUT),$(OUTPUT),.)/feature; \
> -       $(RM) -rf $(OUTPUT)libbpf; \
> -       $(RM) -rf $(OUTPUT)libsubcmd; \
> -       find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
> +       $(Q)$(RM) -rf $(clean_objects)
> +endif
>
>  tags:
>         $(call msg,GEN,,tags)
> --
> 2.26.2
>
Jiri Olsa Feb. 5, 2021, 10:40 a.m. UTC | #3
On Thu, Feb 04, 2021 at 04:42:41PM -0800, Andrii Nakryiko wrote:
> On Thu, Feb 4, 2021 at 1:20 PM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > We want this clean to be called from tree's root clean
> > and that one is silent if there's nothing to clean.
> >
> > Adding check for all object to clean and display CLEAN
> > messages only if there are objects to remove.
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/bpf/resolve_btfids/Makefile | 17 ++++++++++++-----
> >  1 file changed, 12 insertions(+), 5 deletions(-)
> >
> > diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
> > index b780b3a9fb07..3007cfabf5e6 100644
> > --- a/tools/bpf/resolve_btfids/Makefile
> > +++ b/tools/bpf/resolve_btfids/Makefile
> > @@ -64,13 +64,20 @@ $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
> >         $(call msg,LINK,$@)
> >         $(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
> >
> > +clean_objects := $(wildcard $(OUTPUT)/*.o                \
> > +                            $(OUTPUT)/.*.o.cmd           \
> > +                            $(OUTPUT)/.*.o.d             \
> > +                            $(OUTPUT)/libbpf             \
> > +                            $(OUTPUT)/libsubcmd          \
> > +                            $(OUTPUT)/resolve_btfids)
> > +
> > +clean:
> > +
> > +ifneq ($(clean_objects),)
> >  clean: fixdep-clean
> 
> this looks a bit weird, declaring clean twice. Wouldn't moving ifneq
> inside the clean work just fine?

it has the fixdep-clean dependency we don't want to run
if clean_objects is not defined.. I could move the empty
clean to the the else path

jirka


---
diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
index 1d46a247ec95..be09ec4f03ff 100644
--- a/tools/bpf/resolve_btfids/Makefile
+++ b/tools/bpf/resolve_btfids/Makefile
@@ -64,13 +64,20 @@ $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
 	$(call msg,LINK,$@)
 	$(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
 
+clean_objects := $(wildcard $(OUTPUT)/*.o                \
+                            $(OUTPUT)/.*.o.cmd           \
+                            $(OUTPUT)/.*.o.d             \
+                            $(OUTPUT)/libbpf             \
+                            $(OUTPUT)/libsubcmd          \
+                            $(OUTPUT)/resolve_btfids)
+
+ifneq ($(clean_objects),)
 clean: fixdep-clean
 	$(call msg,CLEAN,$(BINARY))
-	$(Q)$(RM) -f $(BINARY); \
-	$(RM) -rf $(if $(OUTPUT),$(OUTPUT),.)/feature; \
-	$(RM) -rf $(OUTPUT)/libbpf; \
-	$(RM) -rf $(OUTPUT)/libsubcmd; \
-	find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
+	$(Q)$(RM) -rf $(clean_objects)
+else
+clean:
+endif
 
 tags:
 	$(call msg,GEN,,tags)
diff mbox series

Patch

diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
index b780b3a9fb07..3007cfabf5e6 100644
--- a/tools/bpf/resolve_btfids/Makefile
+++ b/tools/bpf/resolve_btfids/Makefile
@@ -64,13 +64,20 @@  $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
 	$(call msg,LINK,$@)
 	$(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
 
+clean_objects := $(wildcard $(OUTPUT)/*.o                \
+                            $(OUTPUT)/.*.o.cmd           \
+                            $(OUTPUT)/.*.o.d             \
+                            $(OUTPUT)/libbpf             \
+                            $(OUTPUT)/libsubcmd          \
+                            $(OUTPUT)/resolve_btfids)
+
+clean:
+
+ifneq ($(clean_objects),)
 clean: fixdep-clean
 	$(call msg,CLEAN,$(BINARY))
-	$(Q)$(RM) -f $(BINARY); \
-	$(RM) -rf $(if $(OUTPUT),$(OUTPUT),.)/feature; \
-	$(RM) -rf $(OUTPUT)libbpf; \
-	$(RM) -rf $(OUTPUT)libsubcmd; \
-	find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
+	$(Q)$(RM) -rf $(clean_objects)
+endif
 
 tags:
 	$(call msg,GEN,,tags)