Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 1 | # OpenEmbedded Development tool - menuconfig command plugin |
| 2 | # |
| 3 | # Copyright (C) 2018 Xilinx |
| 4 | # Written by: Chandana Kalluri <ckalluri@xilinx.com> |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License version 2 as |
| 8 | # published by the Free Software Foundation. |
| 9 | # |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License along |
| 16 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | |
| 19 | """Devtool menuconfig plugin""" |
| 20 | |
| 21 | import os |
| 22 | import bb |
| 23 | import logging |
| 24 | import argparse |
| 25 | import re |
| 26 | import glob |
| 27 | from devtool import setup_tinfoil, parse_recipe, DevtoolError, standard, exec_build_env_command |
| 28 | from devtool import check_workspace_recipe |
| 29 | logger = logging.getLogger('devtool') |
| 30 | |
| 31 | def menuconfig(args, config, basepath, workspace): |
| 32 | """Entry point for the devtool 'menuconfig' subcommand""" |
| 33 | |
| 34 | rd = "" |
| 35 | kconfigpath = "" |
| 36 | pn_src = "" |
| 37 | localfilesdir = "" |
| 38 | workspace_dir = "" |
| 39 | tinfoil = setup_tinfoil(basepath=basepath) |
| 40 | try: |
| 41 | rd = parse_recipe(config, tinfoil, args.component, appends=True, filter_workspace=False) |
| 42 | if not rd: |
| 43 | return 1 |
| 44 | |
| 45 | check_workspace_recipe(workspace, args.component) |
| 46 | pn = rd.getVar('PN', True) |
| 47 | |
| 48 | if not rd.getVarFlag('do_menuconfig','task'): |
| 49 | raise DevtoolError("This recipe does not support menuconfig option") |
| 50 | |
| 51 | workspace_dir = os.path.join(config.workspace_path,'sources') |
| 52 | kconfigpath = rd.getVar('B') |
| 53 | pn_src = os.path.join(workspace_dir,pn) |
| 54 | |
| 55 | # add check to see if oe_local_files exists or not |
| 56 | localfilesdir = os.path.join(pn_src,'oe-local-files') |
| 57 | if not os.path.exists(localfilesdir): |
| 58 | bb.utils.mkdirhier(localfilesdir) |
| 59 | # Add gitignore to ensure source tree is clean |
| 60 | gitignorefile = os.path.join(localfilesdir,'.gitignore') |
| 61 | with open(gitignorefile, 'w') as f: |
| 62 | f.write('# Ignore local files, by default. Remove this file if you want to commit the directory to Git\n') |
| 63 | f.write('*\n') |
| 64 | |
| 65 | finally: |
| 66 | tinfoil.shutdown() |
| 67 | |
| 68 | logger.info('Launching menuconfig') |
| 69 | exec_build_env_command(config.init_path, basepath, 'bitbake -c menuconfig %s' % pn, watch=True) |
| 70 | fragment = os.path.join(localfilesdir, 'devtool-fragment.cfg') |
| 71 | res = standard._create_kconfig_diff(pn_src,rd,fragment) |
| 72 | |
| 73 | return 0 |
| 74 | |
| 75 | def register_commands(subparsers, context): |
| 76 | """register devtool subcommands from this plugin""" |
| 77 | parser_menuconfig = subparsers.add_parser('menuconfig',help='Alter build-time configuration for a recipe', description='Launches the make menuconfig command (for recipes where do_menuconfig is available), allowing users to make changes to the build-time configuration. Creates a config fragment corresponding to changes made.', group='advanced') |
| 78 | parser_menuconfig.add_argument('component', help='compenent to alter config') |
| 79 | parser_menuconfig.set_defaults(func=menuconfig,fixed_setup=context.fixed_setup) |