[Bash-completion-devel] Improve make target completion

Igor Murzov e-mail at date.by
Wed Sep 5 13:32:24 UTC 2012


On Sat, 1 Sep 2012 09:14:41 +0100
Tristan Wibberley <tristan.wibberley at gmail.com> wrote:

> Hello bash completion team.
> 
> Forwarding my changes to the team now that I discovered there is a
> mailling list for this.
> 
> Please consider applying the attached git commits for bash-completion for make.
> 
> attachments:
>   commit-aef2ee - converts make completion to use more metadata for
> better results
>   commit-6d1b6d9 - simplifies regex, adds more exclusions
>   commit-d05dbbc - scalability and speed + incremental completions.
> 
> The commits against
> http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git
> improve bash completion for make by replacing the processing command
> for the output of make -np
> 
> This lists all explicit targets, no intermediates, and no source files.
> 
> For an automake project like gcc there is almost no difference in
> output completions. For gcc's generated makefile a couple of
> completions are not proposed in this version which are proposed by the
> existing version and these are not buildable targets in that project's
> make system.
> 
> Performance even for small makefiles like gcc's is improved.
> 
> For makefiles with .INTERMEDIATE targets properly marked up then
> generated deps rules, targets of those deps and intermediate files do
> not get listed thus the patch avoids suggesting most of the targets a
> user doesn't want.
> 
> For the linux kernel makefiles, completion time is reduced to one
> quarter of the time to process the makefiles, nearly halving the
> latency while returning most useful targets (taking the list from 88
> to four digits) and keeping the number of suggestions small (taking
> the first round of suggestions up to the first slash from 88 to 100 or
> so because it supports incremental completion where targets are in
> subdirectories.).
> 
> For a makefile such as the example at
> http://codeshot.blogspot.co.uk/2012/08/this-is-program-that-lists-targets-in.html
> the improvement is dramatic. When I create 4 empty files named
> test/a.cc test/b.cc test/c.cc test/d.cc in a subfolder "test" below
> that Makefile this version of make target completion generates 14
> useful user targets and no source files vs 2 useful targets and 5
> source files for the existing bash completion awk expression.

Hi, Tristan.

I like your patches. Completion for make was always somewhat
incomplete and with your patches it definitely works!

Some small remarks about the patches:

* Your way to parse the output of `make -npq` does not work
  for me unless LC_ALL=C is set. So please use `LC_ALL=C make -npq`
  to get correct results on other locales.

* We don't use tabs for formatting. And commit-d05dbbc has
  one tab in it. And there is also one whitespace issue in
  this patch:

  $ git apply commit-aef2eee commit-6d1b6d9 commit-d05dbbc
  commit-d05dbbc:279: trailing whitespace.
          COMPREPLY=( $( compgen -W "$( 
  warning: 1 line adds whitespace errors.

Also, it's may be better to squash these 3 patches into one
single patch, because it seems better for me to review the
changes as a whole. Anyway, the patches are great!


-- Igor



More information about the Bash-completion-devel mailing list