All of lore.kernel.org
 help / color / mirror / Atom feed
From: ChenQi <Qi.Chen@windriver.com>
To: Sergio Prado <sergiosiena@gmail.com>,
	"yocto@yoctoproject.org" <yocto@yoctoproject.org>
Subject: Re: Bitbake bash completion
Date: Wed, 12 Nov 2014 15:14:15 +0800	[thread overview]
Message-ID: <546308C7.2010906@windriver.com> (raw)
In-Reply-To: <CAKm6Z3U_M8J_8tL3awdEo4aFHmY5gQt5hMh5mxggAcLqXatKnw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 871 bytes --]

Hi Prado,

It's really a good idea. I've tried it out.

Attached is a patch to improve speed, accuracy and user experience.

Regards,
Chen Qi

On 11/12/2014 08:27 AM, Sergio Prado wrote:
> Hello all,
>
> I have just written a bitbake bash completion script so it could make
> my life easier when trying to discover a recipe name and bake it.
>
> https://github.com/sergioprado/bitbake-bash-completion
>
> It should complete all commands (bitbake 1.22.0), recipes and tasks.
>
> When running for the first time, it will execute "bitbake -e" to get
> the BBPATH variable and save it in a hidden file. It will use this
> file on subsequent executions.
>
> Feel free to try it and let me know if you find any bug or have
> suggestions on how to improve it.
>
> Thanks,
>
> Sergio Prado
> www.sergioprado.org
> https://twitter.com/sergioprado


[-- Attachment #2: 0001-Improve-speed-accuracy-and-user-experience.patch --]
[-- Type: text/x-patch, Size: 2604 bytes --]

From 40497abfe58313ed9171abc122bffe559ca85509 Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Wed, 12 Nov 2014 02:06:49 -0500
Subject: [PATCH] Improve speed, accuracy and user experience

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 bitbake |   42 ++++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/bitbake b/bitbake
index e904d97..63f2d52 100644
--- a/bitbake
+++ b/bitbake
@@ -9,7 +9,7 @@
 _bitbake()
 {
     local cur prev opts_short opts_long tasks bbdir bbfile recipes
-    local ui bblayers_conf bblayers_md5 bblayers_bbpath
+    local ui bblayers_conf bblayers_md5 bblayers_bbfile bblayers_recipes
 
     COMPREPLY=()
 
@@ -79,30 +79,40 @@ _bitbake()
 
     bblayers_conf="conf/bblayers.conf"
     bblayers_md5=".bblayers.conf.md5"
-    bblayers_bbpath=".bblayers.bbpath"
+    bblayers_bbfile=".bblayers.bbfile"
+    bblayers_recipes=".bblayers.recipes"
+
+    _parse_recipes () {
+	echo `bitbake -e | grep "^BBFILES=" | cut -d "=" -f 2 | sed -e 's/"//g'` > $bblayers_bbfile
+	 for bbfile_entry in `cat $bblayers_bbfile`; do
+	     if [ "${bbfile_entry%.bbappend}" = "${bbfile_entry}" ]; then
+		 echo $bbfile_entry
+	     fi
+	 done | while read recipe_path; do
+	     recipe="${recipe_path##*/}"
+	     recipe="${recipe%%_*.bb}"
+	     recipe="${recipe%%.bb}"
+	     if [ "$recipe" != "*" ]; then
+		 echo $recipe
+	     fi
+	 done > $bblayers_recipes
+    }
 
     if [ ! -e $bblayers_conf ]; then
         return 0;
     fi
 
+    if [ "$prev" = "bitbake" -a "$cur" = "" ]; then
+	_parse_recipes
+    fi
+
     md5sum --quiet --status -c $bblayers_md5 2>/dev/null
-    if [ $? != 0 -o ! -e $bblayers_bbpath ]; then
-         printf "\nReading BBPATH..."
+    if [ $? != 0 -o ! -e $bblayers_recipes ]; then
          md5sum $bblayers_conf > $bblayers_md5
-         echo `bitbake -e | grep "^BBPATH=" | cut -d "=" -f 2 | sed -e 's/^"//'  -e 's/"$//'` > $bblayers_bbpath
-         echo "done! Press TAB to continue..."
+	 _parse_recipes
     fi
 
-    for bbdir in `cat $bblayers_bbpath | sed s/:/\ /g`; do
-        for bbfile in `echo $bbdir/*/*/${cur}*.bb`; do
-            if [ -e $bbfile ]; then
-                bbfile=`basename $bbfile`
-                bbfile=${bbfile%%_*.bb}
-                bbfile=${bbfile%%.bb}
-                recipes="$recipes $bbfile"
-            fi
-        done
-    done
+    recipes=`cat $bblayers_recipes`
 
     COMPREPLY=( $(compgen -W "${recipes}" -- ${cur}) )
     return 0
-- 
1.7.9.5


  reply	other threads:[~2014-11-12  7:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12  0:27 Bitbake bash completion Sergio Prado
2014-11-12  7:14 ` ChenQi [this message]
2014-11-12 13:08   ` Sergio Prado

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=546308C7.2010906@windriver.com \
    --to=qi.chen@windriver.com \
    --cc=sergiosiena@gmail.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.