If patch_recipe_file() is called with output redirection on the same
file twice in succession, then we don't want to wipe out the changes the
first call made so we need to be reading in the redirected file if it
exists instead of the original one.
This is important to enable devtool finish to work with multiple source
trees within the same recipe.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
since this cannot handle all situations.
"""
- with open(fn, 'r') as f:
+ read_fn = fn
+ if redirect_output:
+ redirect_fn = os.path.join(redirect_output, os.path.basename(fn))
+ if os.path.exists(redirect_fn):
+ read_fn = redirect_fn
+ with open(read_fn, 'r') as f:
fromlines = f.readlines()
_, tolines = patch_recipe_lines(fromlines, values)
if redirect_output:
- with open(os.path.join(redirect_output, os.path.basename(fn)), 'w') as f:
+ with open(redirect_fn, 'w') as f:
f.writelines(tolines)
return None
elif patch: