diff mbox series

[1/1] Makefile: ignore configs/ prefix on configuration events

Message ID 20250630023826.1163-1-git@jdknight.me
State New
Headers show
Series [1/1] Makefile: ignore configs/ prefix on configuration events | expand

Commit Message

James Knight June 30, 2025, 2:38 a.m. UTC
Allows accepting board configuration events that are prefixed with a
`configs/` path. This provides a convenience for users where it can be
slightly easier/quicker to utilize shell completion to prepare a build.
For example:

    make configs/qemu_sparc64_sun4u_defconfig

Would be equivalent to:

    make qemu_sparc64_sun4u_defconfig

Signed-off-by: James Knight <git@jdknight.me>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Edgar Bonet June 30, 2025, 7:48 a.m. UTC | #1
Hello all!

On 2025-06-30, James Knight wrote:
> Allows accepting board configuration events that are prefixed with a
> `configs/` path. This provides a convenience for users where it can be
> slightly easier/quicker to utilize shell completion to prepare a build.
> For example:
> 
>     make configs/qemu_sparc64_sun4u_defconfig
> 
> Would be equivalent to:
> 
>     make qemu_sparc64_sun4u_defconfig

I don't know how this is supposed to work but, in my experience, shell
completion on buildroot's make targets is painfully slow, and does not
work with defonfig targets.

With this patch applied:

    make qem<TAB> → make qemu
    make qemu_sp<TAB>arc64<TAB>  # no completion

    make conf<TAB> → make config␣  # where “␣” is a trailing space
    make configs/qe<TAB>mu_sp<TAB>arc64<TAB>  # no completion

It would be very cool to have usable shell completion though.

Context: Ubuntu 24.04, buildroot git master

Regards,

Edgar Bonet.
Arnout Vandecappelle July 1, 2025, 7:02 a.m. UTC | #2
Hi James,

On 30/06/2025 04:38, James Knight wrote:
> Allows accepting board configuration events that are prefixed with a
> `configs/` path. This provides a convenience for users where it can be
> slightly easier/quicker to utilize shell completion to prepare a build.
> For example:
> 
>      make configs/qemu_sparc64_sun4u_defconfig
> 
> Would be equivalent to:
> 
>      make qemu_sparc64_sun4u_defconfig

  I agree with the principle (though I want to think a little more about the 
implications in corner cases). However...

> 
> Signed-off-by: James Knight <git@jdknight.me>
> ---
>   Makefile | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index c581067320..46b246245b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1026,7 +1026,7 @@ defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
>   		$(firstword \
>   			$(foreach d, \
>   				$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)), \
> -				$(wildcard $(d)/configs/$@) \
> +				$(wildcard $(d)/configs/$(@:configs/%=%)) \

  We don't use this kind of substitution, instead use patsubst.

  And maybe it's simpler to use

	$(wildcard $(d)/configs/$@ $(d)/$@)

It would mean that any defconfig at the top of a br2-external would also work, 
but perhaps there's nothing wrong with that...

  Regards,
  Arnout

>   			) \
>   		), \
>   		$(error "Can't find $@") \
Arnout Vandecappelle July 1, 2025, 7:04 a.m. UTC | #3
On 30/06/2025 09:48, Edgar Bonet via buildroot wrote:
> Hello all!
> 
> On 2025-06-30, James Knight wrote:
>> Allows accepting board configuration events that are prefixed with a
>> `configs/` path. This provides a convenience for users where it can be
>> slightly easier/quicker to utilize shell completion to prepare a build.
>> For example:
>>
>>      make configs/qemu_sparc64_sun4u_defconfig
>>
>> Would be equivalent to:
>>
>>      make qemu_sparc64_sun4u_defconfig
> 
> I don't know how this is supposed to work but, in my experience, shell
> completion on buildroot's make targets is painfully slow, and does not
> work with defonfig targets.
> 
> With this patch applied:
> 
>      make qem<TAB> → make qemu
>      make qemu_sp<TAB>arc64<TAB>  # no completion
> 
>      make conf<TAB> → make config␣  # where “␣” is a trailing space
>      make configs/qe<TAB>mu_sp<TAB>arc64<TAB>  # no completion
> 
> It would be very cool to have usable shell completion though.

  In bash, you can use Ctrl-backslash to only use filename completion, not 
context-sensitive completion. But that only works if it's an actual filename, 
like in the example that James gives.

  The context-sensitive completion with TAB already works without James' patch.

  So basically, this patch is exactly a workaround for the problem you indicate 
(if you know what ctrl-backslash does).

  Regards,
  Arnout

> 
> Context: Ubuntu 24.04, buildroot git master
> 
> Regards,
> 
> Edgar Bonet.
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Edgar Bonet July 1, 2025, 7:51 a.m. UTC | #4
Hello!

Today, Arnout Vandecappelle wrote:
> In bash, you can use Ctrl-backslash to only use filename completion,
> not context-sensitive completion. But that only works if it's an
> actual filename, like in the example that James gives.

Today I learned something. Thanks! Now, on my system the key bindings
are different:

    Ctrl-\  →  send SIGQUIT (ignored by bash)
    Alt-/   →  filename completion

Regards,

Edgar.
James Knight July 7, 2025, 1:30 a.m. UTC | #5
Arnout,

On Tue, Jul 1, 2025 at 3:02 AM Arnout Vandecappelle <arnout@rnout.be> wrote:
> We don't use this kind of substitution, instead use patsubst.

If using pathsubst is preferred (e.g. "$(wildcard $(d)/configs/$(call
pathsubst,configs/,,$@))"), or using the other suggested variant:

>         $(wildcard $(d)/configs/$@ $(d)/$@)

Let me know and I can set up a patch for it (if desired).

> ... I want to think a little more about the implications in corner cases...

And no worries if such a modification is not desired.
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index c581067320..46b246245b 100644
--- a/Makefile
+++ b/Makefile
@@ -1026,7 +1026,7 @@  defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
 		$(firstword \
 			$(foreach d, \
 				$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)), \
-				$(wildcard $(d)/configs/$@) \
+				$(wildcard $(d)/configs/$(@:configs/%=%)) \
 			) \
 		), \
 		$(error "Can't find $@") \