menuconfig.py 3.3 KB

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