summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oe/recipeutils.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index ef827550eb..b9f6ada4d6 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -158,7 +158,7 @@ def split_var_value(value, assignment=True):
158 return outlist 158 return outlist
159 159
160 160
161def patch_recipe_lines(fromlines, values): 161def patch_recipe_lines(fromlines, values, trailing_newline=True):
162 """Update or insert variable values into lines from a recipe. 162 """Update or insert variable values into lines from a recipe.
163 Note that some manual inspection/intervention may be required 163 Note that some manual inspection/intervention may be required
164 since this cannot handle all situations. 164 since this cannot handle all situations.
@@ -166,6 +166,11 @@ def patch_recipe_lines(fromlines, values):
166 166
167 import bb.utils 167 import bb.utils
168 168
169 if trailing_newline:
170 newline = '\n'
171 else:
172 newline = ''
173
169 recipe_progression_res = [] 174 recipe_progression_res = []
170 recipe_progression_restrs = [] 175 recipe_progression_restrs = []
171 for item in recipe_progression: 176 for item in recipe_progression:
@@ -196,7 +201,7 @@ def patch_recipe_lines(fromlines, values):
196 def outputvalue(name, lines, rewindcomments=False): 201 def outputvalue(name, lines, rewindcomments=False):
197 if values[name] is None: 202 if values[name] is None:
198 return 203 return
199 rawtext = '%s = "%s"\n' % (name, values[name]) 204 rawtext = '%s = "%s"%s' % (name, values[name], newline)
200 addlines = [] 205 addlines = []
201 if name in nowrap_vars: 206 if name in nowrap_vars:
202 addlines.append(rawtext) 207 addlines.append(rawtext)
@@ -204,19 +209,19 @@ def patch_recipe_lines(fromlines, values):
204 splitvalue = split_var_value(values[name], assignment=False) 209 splitvalue = split_var_value(values[name], assignment=False)
205 if len(splitvalue) > 1: 210 if len(splitvalue) > 1:
206 linesplit = ' \\\n' + (' ' * (len(name) + 4)) 211 linesplit = ' \\\n' + (' ' * (len(name) + 4))
207 addlines.append('%s = "%s%s"\n' % (name, linesplit.join(splitvalue), linesplit)) 212 addlines.append('%s = "%s%s"%s' % (name, linesplit.join(splitvalue), linesplit, newline))
208 else: 213 else:
209 addlines.append(rawtext) 214 addlines.append(rawtext)
210 else: 215 else:
211 wrapped = textwrap.wrap(rawtext) 216 wrapped = textwrap.wrap(rawtext)
212 for wrapline in wrapped[:-1]: 217 for wrapline in wrapped[:-1]:
213 addlines.append('%s \\\n' % wrapline) 218 addlines.append('%s \\%s' % (wrapline, newline))
214 addlines.append('%s\n' % wrapped[-1]) 219 addlines.append('%s%s' % (wrapped[-1], newline))
215 if rewindcomments: 220 if rewindcomments:
216 # Ensure we insert the lines before any leading comments 221 # Ensure we insert the lines before any leading comments
217 # (that we'd want to ensure remain leading the next value) 222 # (that we'd want to ensure remain leading the next value)
218 for i, ln in reversed(list(enumerate(lines))): 223 for i, ln in reversed(list(enumerate(lines))):
219 if ln[0] != '#': 224 if not ln.startswith('#'):
220 lines[i+1:i+1] = addlines 225 lines[i+1:i+1] = addlines
221 break 226 break
222 else: 227 else: