196ff1984SBrad Bishop# OpenEmbedded Development tool - menuconfig command plugin 296ff1984SBrad Bishop# 396ff1984SBrad Bishop# Copyright (C) 2018 Xilinx 496ff1984SBrad Bishop# Written by: Chandana Kalluri <ckalluri@xilinx.com> 596ff1984SBrad Bishop# 692b42cb3SPatrick Williams# SPDX-License-Identifier: MIT 792b42cb3SPatrick Williams# 896ff1984SBrad Bishop# This program is free software; you can redistribute it and/or modify 996ff1984SBrad Bishop# it under the terms of the GNU General Public License version 2 as 1096ff1984SBrad Bishop# published by the Free Software Foundation. 1196ff1984SBrad Bishop# 1296ff1984SBrad Bishop# This program is distributed in the hope that it will be useful, 1396ff1984SBrad Bishop# but WITHOUT ANY WARRANTY; without even the implied warranty of 1496ff1984SBrad Bishop# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1596ff1984SBrad Bishop# GNU General Public License for more details. 1696ff1984SBrad Bishop# 1796ff1984SBrad Bishop# You should have received a copy of the GNU General Public License along 1896ff1984SBrad Bishop# with this program; if not, write to the Free Software Foundation, Inc., 1996ff1984SBrad Bishop# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 2096ff1984SBrad Bishop 2196ff1984SBrad Bishop"""Devtool menuconfig plugin""" 2296ff1984SBrad Bishop 2396ff1984SBrad Bishopimport os 2496ff1984SBrad Bishopimport bb 2596ff1984SBrad Bishopimport logging 2696ff1984SBrad Bishopimport argparse 2796ff1984SBrad Bishopimport re 2896ff1984SBrad Bishopimport glob 2996ff1984SBrad Bishopfrom devtool import setup_tinfoil, parse_recipe, DevtoolError, standard, exec_build_env_command 3096ff1984SBrad Bishopfrom devtool import check_workspace_recipe 3196ff1984SBrad Bishoplogger = logging.getLogger('devtool') 3296ff1984SBrad Bishop 3396ff1984SBrad Bishopdef menuconfig(args, config, basepath, workspace): 3496ff1984SBrad Bishop """Entry point for the devtool 'menuconfig' subcommand""" 3596ff1984SBrad Bishop 3696ff1984SBrad Bishop rd = "" 3796ff1984SBrad Bishop kconfigpath = "" 3896ff1984SBrad Bishop pn_src = "" 3996ff1984SBrad Bishop localfilesdir = "" 4096ff1984SBrad Bishop workspace_dir = "" 4196ff1984SBrad Bishop tinfoil = setup_tinfoil(basepath=basepath) 4296ff1984SBrad Bishop try: 4396ff1984SBrad Bishop rd = parse_recipe(config, tinfoil, args.component, appends=True, filter_workspace=False) 4496ff1984SBrad Bishop if not rd: 4596ff1984SBrad Bishop return 1 4696ff1984SBrad Bishop 4796ff1984SBrad Bishop check_workspace_recipe(workspace, args.component) 48*864cc43bSPatrick Williams pn = rd.getVar('PN') 4996ff1984SBrad Bishop 5096ff1984SBrad Bishop if not rd.getVarFlag('do_menuconfig','task'): 5196ff1984SBrad Bishop raise DevtoolError("This recipe does not support menuconfig option") 5296ff1984SBrad Bishop 5396ff1984SBrad Bishop workspace_dir = os.path.join(config.workspace_path,'sources') 5496ff1984SBrad Bishop kconfigpath = rd.getVar('B') 5596ff1984SBrad Bishop pn_src = os.path.join(workspace_dir,pn) 5696ff1984SBrad Bishop 5796ff1984SBrad Bishop # add check to see if oe_local_files exists or not 5896ff1984SBrad Bishop localfilesdir = os.path.join(pn_src,'oe-local-files') 5996ff1984SBrad Bishop if not os.path.exists(localfilesdir): 6096ff1984SBrad Bishop bb.utils.mkdirhier(localfilesdir) 6196ff1984SBrad Bishop # Add gitignore to ensure source tree is clean 6296ff1984SBrad Bishop gitignorefile = os.path.join(localfilesdir,'.gitignore') 6396ff1984SBrad Bishop with open(gitignorefile, 'w') as f: 6496ff1984SBrad Bishop f.write('# Ignore local files, by default. Remove this file if you want to commit the directory to Git\n') 6596ff1984SBrad Bishop f.write('*\n') 6696ff1984SBrad Bishop 6796ff1984SBrad Bishop finally: 6896ff1984SBrad Bishop tinfoil.shutdown() 6996ff1984SBrad Bishop 7096ff1984SBrad Bishop logger.info('Launching menuconfig') 7196ff1984SBrad Bishop exec_build_env_command(config.init_path, basepath, 'bitbake -c menuconfig %s' % pn, watch=True) 7296ff1984SBrad Bishop fragment = os.path.join(localfilesdir, 'devtool-fragment.cfg') 7396ff1984SBrad Bishop res = standard._create_kconfig_diff(pn_src,rd,fragment) 7496ff1984SBrad Bishop 7596ff1984SBrad Bishop return 0 7696ff1984SBrad Bishop 7796ff1984SBrad Bishopdef register_commands(subparsers, context): 7896ff1984SBrad Bishop """register devtool subcommands from this plugin""" 7996ff1984SBrad Bishop 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') 8096ff1984SBrad Bishop parser_menuconfig.add_argument('component', help='compenent to alter config') 8196ff1984SBrad Bishop parser_menuconfig.set_defaults(func=menuconfig,fixed_setup=context.fixed_setup) 82