Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | # Recipe creation tool - edit plugin |
| 2 | # |
| 3 | # This sub-command edits the recipe and appends for the specified target |
| 4 | # |
| 5 | # Example: recipetool edit busybox |
| 6 | # |
| 7 | # Copyright (C) 2018 Mentor Graphics Corporation |
| 8 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 9 | # SPDX-License-Identifier: GPL-2.0-only |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 10 | # |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 11 | |
| 12 | import argparse |
| 13 | import errno |
| 14 | import logging |
| 15 | import os |
| 16 | import re |
| 17 | import subprocess |
| 18 | import sys |
| 19 | import scriptutils |
| 20 | |
| 21 | |
| 22 | logger = logging.getLogger('recipetool') |
| 23 | tinfoil = None |
| 24 | |
| 25 | |
| 26 | def tinfoil_init(instance): |
| 27 | global tinfoil |
| 28 | tinfoil = instance |
| 29 | |
| 30 | |
| 31 | def edit(args): |
| 32 | import oe.recipeutils |
| 33 | |
| 34 | recipe_path = tinfoil.get_recipe_file(args.target) |
| 35 | appends = tinfoil.get_file_appends(recipe_path) |
| 36 | |
Andrew Geissler | d25ed32 | 2020-06-27 00:28:28 -0500 | [diff] [blame] | 37 | return scriptutils.run_editor([recipe_path] + list(appends), logger) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 38 | |
| 39 | |
| 40 | def register_commands(subparsers): |
| 41 | parser = subparsers.add_parser('edit', |
| 42 | help='Edit the recipe and appends for the specified target. This obeys $VISUAL if set, otherwise $EDITOR, otherwise vi.') |
| 43 | parser.add_argument('target', help='Target recipe/provide to edit') |
| 44 | parser.set_defaults(func=edit, parserecipes=True) |