aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-09-22 17:21:28 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-22 18:12:55 +0100
commitff14d9e5b935b99b2efde479515e54c02ba58f6e (patch)
tree360474a802b863f674c9e168a4468d740a7d87fc /scripts
parent320585b7ff6340df0b0dbc63f95ed3ca8fc3a993 (diff)
downloadopenembedded-core-contrib-ff14d9e5b935b99b2efde479515e54c02ba58f6e.tar.gz
recipetool: create: fix creating empty shell functions
The shell considers empty functions to be a syntax error, so for template shell functions that contain only comments (or no lines at all) then add a : to act as a no-op which avoids the syntax error. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/recipetool/create.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index c4754dbcdd..99d9cc850e 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -46,10 +46,26 @@ class RecipeHandler():
results.extend(glob.glob(os.path.join(path, spec)))
return results
- def genfunction(self, outlines, funcname, content):
- outlines.append('%s () {' % funcname)
+ def genfunction(self, outlines, funcname, content, python=False, forcespace=False):
+ if python:
+ prefix = 'python '
+ else:
+ prefix = ''
+ outlines.append('%s%s () {' % (prefix, funcname))
+ if python or forcespace:
+ indent = ' '
+ else:
+ indent = '\t'
+ addnoop = not python
for line in content:
- outlines.append('\t%s' % line)
+ outlines.append('%s%s' % (indent, line))
+ if addnoop:
+ strippedline = line.lstrip()
+ if strippedline and not strippedline.startswith('#'):
+ addnoop = False
+ if addnoop:
+ # Without this there'll be a syntax error
+ outlines.append('%s:' % indent)
outlines.append('}')
outlines.append('')