All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] improve formatting of OE run.do_configure etc scripts
@ 2016-01-28  0:43 Andre McCurdy
  2016-01-28  0:43 ` [PATCH 1/3] build.py: minor shell_trap_code() formatting tweaks Andre McCurdy
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andre McCurdy @ 2016-01-28  0:43 UTC (permalink / raw)
  To: bitbake-devel

Andre McCurdy (3):
  build.py: minor shell_trap_code() formatting tweaks
  data.py: avoid double newlines at the end of functions in emit_var()
  data.py: sort variables being output by emit_func()

 lib/bb/build.py | 5 ++---
 lib/bb/data.py  | 9 ++++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)

-- 
1.9.1



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

* [PATCH 1/3] build.py: minor shell_trap_code() formatting tweaks
  2016-01-28  0:43 [PATCH 0/3] improve formatting of OE run.do_configure etc scripts Andre McCurdy
@ 2016-01-28  0:43 ` Andre McCurdy
  2016-01-28  0:43 ` [PATCH 2/3] data.py: avoid double newlines at the end of functions in emit_var() Andre McCurdy
  2016-01-28  0:43 ` [PATCH 3/3] data.py: sort variables being output by emit_func() Andre McCurdy
  2 siblings, 0 replies; 5+ messages in thread
From: Andre McCurdy @ 2016-01-28  0:43 UTC (permalink / raw)
  To: bitbake-devel

Fix quoting of $BASH_COMMAND and avoid wrapping at 80 columns (the
script which follows is likely to contain some very long lines, so
line wrapping in bb_exit_handler() looks somewhat out of place).

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
---
 lib/bb/build.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/bb/build.py b/lib/bb/build.py
index 8852209..4a48a61 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -277,9 +277,8 @@ bb_exit_handler() {
     case $ret in
     0)  ;;
     *)  case $BASH_VERSION in
-        "")   echo "WARNING: exit code $ret from a shell command.";;
-        *)    echo "WARNING: ${BASH_SOURCE[0]}:${BASH_LINENO[0]} exit $ret from
-  \"$BASH_COMMAND\"";;
+        "") echo "WARNING: exit code $ret from a shell command.";;
+        *)  echo "WARNING: ${BASH_SOURCE[0]}:${BASH_LINENO[0]} exit $ret from '$BASH_COMMAND'";;
         esac
         exit $ret
     esac
-- 
1.9.1



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

* [PATCH 2/3] data.py: avoid double newlines at the end of functions in emit_var()
  2016-01-28  0:43 [PATCH 0/3] improve formatting of OE run.do_configure etc scripts Andre McCurdy
  2016-01-28  0:43 ` [PATCH 1/3] build.py: minor shell_trap_code() formatting tweaks Andre McCurdy
@ 2016-01-28  0:43 ` Andre McCurdy
  2016-01-28  0:43 ` [PATCH 3/3] data.py: sort variables being output by emit_func() Andre McCurdy
  2 siblings, 0 replies; 5+ messages in thread
From: Andre McCurdy @ 2016-01-28  0:43 UTC (permalink / raw)
  To: bitbake-devel

A newline is always appended to the function body when it's written
out, so strip any trailing newlines which may be there already.

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
---
 lib/bb/data.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/bb/data.py b/lib/bb/data.py
index fac57da..70ba56b 100644
--- a/lib/bb/data.py
+++ b/lib/bb/data.py
@@ -227,6 +227,7 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
 
     if func:
         # NOTE: should probably check for unbalanced {} within the var
+        val = val.rstrip('\n')
         o.write("%s() {\n%s\n}\n" % (varExpanded, val))
         return 1
 
-- 
1.9.1



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

* [PATCH 3/3] data.py: sort variables being output by emit_func()
  2016-01-28  0:43 [PATCH 0/3] improve formatting of OE run.do_configure etc scripts Andre McCurdy
  2016-01-28  0:43 ` [PATCH 1/3] build.py: minor shell_trap_code() formatting tweaks Andre McCurdy
  2016-01-28  0:43 ` [PATCH 2/3] data.py: avoid double newlines at the end of functions in emit_var() Andre McCurdy
@ 2016-01-28  0:43 ` Andre McCurdy
  2016-01-29  0:01   ` Richard Purdie
  2 siblings, 1 reply; 5+ messages in thread
From: Andre McCurdy @ 2016-01-28  0:43 UTC (permalink / raw)
  To: bitbake-devel

Sorting variables and separating those being exported from those being
unset greatly improves the readability of OE run.do_configure, etc,
shell scripts.

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
---
 lib/bb/data.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/bb/data.py b/lib/bb/data.py
index 70ba56b..07f4bba 100644
--- a/lib/bb/data.py
+++ b/lib/bb/data.py
@@ -270,7 +270,13 @@ def exported_vars(d):
 def emit_func(func, o=sys.__stdout__, d = init()):
     """Emits all items in the data store in a format such that it can be sourced by a shell."""
 
-    keys = (key for key in d.keys() if not key.startswith("__") and not d.getVarFlag(key, "func"))
+    o.write('\n')
+    keys = sorted(key for key in d.keys() if not key.startswith("__") and not d.getVarFlag(key, "func") and not d.getVarFlag(key, 'unexport'))
+    for key in keys:
+        emit_var(key, o, d, False)
+
+    o.write('\n')
+    keys = sorted(key for key in d.keys() if not key.startswith("__") and not d.getVarFlag(key, "func") and d.getVarFlag(key, 'unexport'))
     for key in keys:
         emit_var(key, o, d, False)
 
-- 
1.9.1



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

* Re: [PATCH 3/3] data.py: sort variables being output by emit_func()
  2016-01-28  0:43 ` [PATCH 3/3] data.py: sort variables being output by emit_func() Andre McCurdy
@ 2016-01-29  0:01   ` Richard Purdie
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Purdie @ 2016-01-29  0:01 UTC (permalink / raw)
  To: Andre McCurdy, bitbake-devel

On Wed, 2016-01-27 at 16:43 -0800, Andre McCurdy wrote:
> Sorting variables and separating those being exported from those
> being
> unset greatly improves the readability of OE run.do_configure, etc,
> shell scripts.
> 
> Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
> ---
>  lib/bb/data.py | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/bb/data.py b/lib/bb/data.py
> index 70ba56b..07f4bba 100644
> --- a/lib/bb/data.py
> +++ b/lib/bb/data.py
> @@ -270,7 +270,13 @@ def exported_vars(d):
>  def emit_func(func, o=sys.__stdout__, d = init()):
>      """Emits all items in the data store in a format such that it
> can be sourced by a shell."""
>  
> -    keys = (key for key in d.keys() if not key.startswith("__") and
> not d.getVarFlag(key, "func"))
> +    o.write('\n')
> +    keys = sorted(key for key in d.keys() if not
> key.startswith("__") and not d.getVarFlag(key, "func") and not
> d.getVarFlag(key, 'unexport'))
> +    for key in keys:
> +        emit_var(key, o, d, False)
> +
> +    o.write('\n')
> +    keys = sorted(key for key in d.keys() if not
> key.startswith("__") and not d.getVarFlag(key, "func") and
> d.getVarFlag(key, 'unexport'))
>      for key in keys:
>          emit_var(key, o, d, False)

FWIW d.keys() is very slow and best avoided if we can.

Since this code only generally runs at execution time rather than
parsing, its probably not a big deal but thought I'd mention it.

Cheers,

Richard


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

end of thread, other threads:[~2016-01-29  0:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-28  0:43 [PATCH 0/3] improve formatting of OE run.do_configure etc scripts Andre McCurdy
2016-01-28  0:43 ` [PATCH 1/3] build.py: minor shell_trap_code() formatting tweaks Andre McCurdy
2016-01-28  0:43 ` [PATCH 2/3] data.py: avoid double newlines at the end of functions in emit_var() Andre McCurdy
2016-01-28  0:43 ` [PATCH 3/3] data.py: sort variables being output by emit_func() Andre McCurdy
2016-01-29  0:01   ` Richard Purdie

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.