All of lore.kernel.org
 help / color / mirror / Atom feed
* Bitbake bash completion
@ 2014-11-12  0:27 Sergio Prado
  2014-11-12  7:14 ` ChenQi
  0 siblings, 1 reply; 3+ messages in thread
From: Sergio Prado @ 2014-11-12  0:27 UTC (permalink / raw)
  To: yocto@yoctoproject.org

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bitbake bash completion
  2014-11-12  0:27 Bitbake bash completion Sergio Prado
@ 2014-11-12  7:14 ` ChenQi
  2014-11-12 13:08   ` Sergio Prado
  0 siblings, 1 reply; 3+ messages in thread
From: ChenQi @ 2014-11-12  7:14 UTC (permalink / raw)
  To: Sergio Prado, yocto@yoctoproject.org

[-- 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: Bitbake bash completion
  2014-11-12  7:14 ` ChenQi
@ 2014-11-12 13:08   ` Sergio Prado
  0 siblings, 0 replies; 3+ messages in thread
From: Sergio Prado @ 2014-11-12 13:08 UTC (permalink / raw)
  To: ChenQi; +Cc: yocto@yoctoproject.org

Hello Chen,

Good idea on keeping the cache of available bitbake recipes.

Patch applied, thanks.

Sergio Prado
www.sergioprado.org
https://twitter.com/sergioprado


2014-11-12 5:14 GMT-02:00 ChenQi <Qi.Chen@windriver.com>:
> 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
>
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-12 13:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-12  0:27 Bitbake bash completion Sergio Prado
2014-11-12  7:14 ` ChenQi
2014-11-12 13:08   ` Sergio Prado

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.