mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
devtool: add configure-help subcommand
When you need to set EXTRA_OECONF for a recipe, you need to know what options the configure script actually supports; the configure script however is only accessible from within a devshell and (at least in the case of autotooled software fetched from an SCM repository) may not actually exist until do_configure has run. Thus, provide a "devtool configure-help" subcommand that runs the configure script for a recipe with --help and shows you the output through a pager (e.g. less), prefaced by a header describing the current options being specified. There is basic support for autotools, cmake and bare configure scripts. The cmake support is a little hacky since cmake doesn't really have a concise help option that lists user-defined knobs (without actually running through the configure process), however that being a design feature of cmake there's not much I can think of to do about that at the moment. (From OE-Core rev: 0e5d84d9705091b338000ef02720cfa090f76888) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
84720c8ce9
commit
89a7ed5b67
|
@ -129,7 +129,7 @@ def get_recipe_file(cooker, pn):
|
|||
logger.error("Unable to find any recipe file matching %s" % pn)
|
||||
return recipefile
|
||||
|
||||
def parse_recipe(config, tinfoil, pn, appends):
|
||||
def parse_recipe(config, tinfoil, pn, appends, filter_workspace=True):
|
||||
"""Parse recipe of a package"""
|
||||
import oe.recipeutils
|
||||
recipefile = get_recipe_file(tinfoil.cooker, pn)
|
||||
|
@ -138,6 +138,7 @@ def parse_recipe(config, tinfoil, pn, appends):
|
|||
return None
|
||||
if appends:
|
||||
append_files = tinfoil.cooker.collection.get_file_appends(recipefile)
|
||||
if filter_workspace:
|
||||
# Filter out appends from the workspace
|
||||
append_files = [path for path in append_files if
|
||||
not path.startswith(config.workspace_path)]
|
||||
|
|
|
@ -61,6 +61,165 @@ def edit_recipe(args, config, basepath, workspace):
|
|||
return 0
|
||||
|
||||
|
||||
def configure_help(args, config, basepath, workspace):
|
||||
"""Entry point for the devtool 'configure-help' subcommand"""
|
||||
import oe.utils
|
||||
|
||||
check_workspace_recipe(workspace, args.recipename)
|
||||
tinfoil = setup_tinfoil(config_only=False, basepath=basepath)
|
||||
try:
|
||||
rd = parse_recipe(config, tinfoil, args.recipename, appends=True, filter_workspace=False)
|
||||
if not rd:
|
||||
return 1
|
||||
b = rd.getVar('B', True)
|
||||
s = rd.getVar('S', True)
|
||||
configurescript = os.path.join(s, 'configure')
|
||||
confdisabled = 'noexec' in rd.getVarFlags('do_configure') or 'do_configure' not in (rd.getVar('__BBTASKS', False) or [])
|
||||
configureopts = oe.utils.squashspaces(rd.getVar('CONFIGUREOPTS', True) or '')
|
||||
extra_oeconf = oe.utils.squashspaces(rd.getVar('EXTRA_OECONF', True) or '')
|
||||
extra_oecmake = oe.utils.squashspaces(rd.getVar('EXTRA_OECMAKE', True) or '')
|
||||
do_configure = rd.getVar('do_configure', True) or ''
|
||||
do_configure_noexpand = rd.getVar('do_configure', False) or ''
|
||||
packageconfig = rd.getVarFlags('PACKAGECONFIG') or []
|
||||
autotools = bb.data.inherits_class('autotools', rd) and ('oe_runconf' in do_configure or 'autotools_do_configure' in do_configure)
|
||||
cmake = bb.data.inherits_class('cmake', rd) and ('cmake_do_configure' in do_configure)
|
||||
cmake_do_configure = rd.getVar('cmake_do_configure', True)
|
||||
pn = rd.getVar('PN', True)
|
||||
finally:
|
||||
tinfoil.shutdown()
|
||||
|
||||
if 'doc' in packageconfig:
|
||||
del packageconfig['doc']
|
||||
|
||||
if autotools and not os.path.exists(configurescript):
|
||||
logger.info('Running do_configure to generate configure script')
|
||||
try:
|
||||
stdout, _ = exec_build_env_command(config.init_path, basepath,
|
||||
'bitbake -c configure %s' % msg, args.recipename,
|
||||
stderr=subprocess.STDOUT)
|
||||
except bb.process.ExecutionError:
|
||||
pass
|
||||
|
||||
if confdisabled or do_configure.strip() in ('', ':'):
|
||||
raise DevtoolError("do_configure task has been disabled for this recipe")
|
||||
elif args.no_pager and not os.path.exists(configurescript):
|
||||
raise DevtoolError("No configure script found and no other information to display")
|
||||
else:
|
||||
configopttext = ''
|
||||
if autotools and configureopts:
|
||||
configopttext = '''
|
||||
Arguments currently passed to the configure script:
|
||||
|
||||
%s
|
||||
|
||||
Some of those are fixed.''' % (configureopts + ' ' + extra_oeconf)
|
||||
if extra_oeconf:
|
||||
configopttext += ''' The ones that are specified through EXTRA_OECONF (which you can change or add to easily):
|
||||
|
||||
%s''' % extra_oeconf
|
||||
|
||||
elif cmake:
|
||||
in_cmake = False
|
||||
cmake_cmd = ''
|
||||
for line in cmake_do_configure.splitlines():
|
||||
if in_cmake:
|
||||
cmake_cmd = cmake_cmd + ' ' + line.strip().rstrip('\\')
|
||||
if not line.endswith('\\'):
|
||||
break
|
||||
if line.lstrip().startswith('cmake '):
|
||||
cmake_cmd = line.strip().rstrip('\\')
|
||||
if line.endswith('\\'):
|
||||
in_cmake = True
|
||||
else:
|
||||
break
|
||||
if cmake_cmd:
|
||||
configopttext = '''
|
||||
The current cmake command line:
|
||||
|
||||
%s
|
||||
|
||||
Arguments specified through EXTRA_OECMAKE (which you can change or add to easily)
|
||||
|
||||
%s''' % (oe.utils.squashspaces(cmake_cmd), extra_oecmake)
|
||||
else:
|
||||
configopttext = '''
|
||||
The current implementation of cmake_do_configure:
|
||||
|
||||
cmake_do_configure() {
|
||||
%s
|
||||
}
|
||||
|
||||
Arguments specified through EXTRA_OECMAKE (which you can change or add to easily)
|
||||
|
||||
%s''' % (cmake_do_configure.rstrip(), extra_oecmake)
|
||||
|
||||
elif do_configure:
|
||||
configopttext = '''
|
||||
The current implementation of do_configure:
|
||||
|
||||
do_configure() {
|
||||
%s
|
||||
}''' % do_configure.rstrip()
|
||||
if '${EXTRA_OECONF}' in do_configure_noexpand:
|
||||
configopttext += '''
|
||||
|
||||
Arguments specified through EXTRA_OECONF (which you can change or add to easily):
|
||||
|
||||
%s''' % extra_oeconf
|
||||
|
||||
if packageconfig:
|
||||
configopttext += '''
|
||||
|
||||
Some of these options may be controlled through PACKAGECONFIG; for more details please see the recipe.'''
|
||||
|
||||
if args.arg:
|
||||
helpargs = ' '.join(args.arg)
|
||||
elif cmake:
|
||||
helpargs = '-LH'
|
||||
else:
|
||||
helpargs = '--help'
|
||||
|
||||
msg = '''configure information for %s
|
||||
------------------------------------------
|
||||
%s''' % (pn, configopttext)
|
||||
|
||||
if cmake:
|
||||
msg += '''
|
||||
|
||||
The cmake %s output for %s follows. After "-- Cache values" you should see a list of variables you can add to EXTRA_OECMAKE (prefixed with -D and suffixed with = followed by the desired value, without any spaces).
|
||||
------------------------------------------''' % (helpargs, pn)
|
||||
elif os.path.exists(configurescript):
|
||||
msg += '''
|
||||
|
||||
The ./configure %s output for %s follows.
|
||||
------------------------------------------''' % (helpargs, pn)
|
||||
|
||||
olddir = os.getcwd()
|
||||
tmppath = tempfile.mkdtemp()
|
||||
with tempfile.NamedTemporaryFile('w', delete=False) as tf:
|
||||
if not args.no_header:
|
||||
tf.write(msg + '\n')
|
||||
tf.close()
|
||||
try:
|
||||
try:
|
||||
cmd = 'cat %s' % tf.name
|
||||
if cmake:
|
||||
cmd += '; cmake %s %s 2>&1' % (helpargs, s)
|
||||
os.chdir(b)
|
||||
elif os.path.exists(configurescript):
|
||||
cmd += '; %s %s' % (configurescript, helpargs)
|
||||
if sys.stdout.isatty() and not args.no_pager:
|
||||
pager = os.environ.get('PAGER', 'less')
|
||||
cmd = '(%s) | %s' % (cmd, pager)
|
||||
subprocess.check_call(cmd, shell=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
return e.returncode
|
||||
finally:
|
||||
os.chdir(olddir)
|
||||
shutil.rmtree(tmppath)
|
||||
os.remove(tf.name)
|
||||
|
||||
|
||||
def register_commands(subparsers, context):
|
||||
"""Register devtool subcommands from this plugin"""
|
||||
parser_edit_recipe = subparsers.add_parser('edit-recipe', help='Edit a recipe file in your workspace',
|
||||
|
@ -68,3 +227,14 @@ def register_commands(subparsers, context):
|
|||
parser_edit_recipe.add_argument('recipename', help='Recipe to edit')
|
||||
parser_edit_recipe.add_argument('--any-recipe', '-a', action="store_true", help='Edit any recipe, not just where the recipe file itself is in the workspace')
|
||||
parser_edit_recipe.set_defaults(func=edit_recipe)
|
||||
|
||||
# NOTE: Needed to override the usage string here since the default
|
||||
# gets the order wrong - recipename must come before --arg
|
||||
parser_configure_help = subparsers.add_parser('configure-help', help='Get help on configure script options',
|
||||
usage='devtool configure-help [options] recipename [--arg ...]',
|
||||
description='Displays the help for the configure script for the specified recipe (i.e. runs ./configure --help) prefaced by a header describing the current options being specified. Output is piped through less (or whatever PAGER is set to, if set) for easy browsing.')
|
||||
parser_configure_help.add_argument('recipename', help='Recipe to show configure help for')
|
||||
parser_configure_help.add_argument('-p', '--no-pager', help='Disable paged output', action="store_true")
|
||||
parser_configure_help.add_argument('-n', '--no-header', help='Disable explanatory header text', action="store_true")
|
||||
parser_configure_help.add_argument('--arg', help='Pass remaining arguments to the configure script instead of --help (useful if the script has additional help options)', nargs=argparse.REMAINDER)
|
||||
parser_configure_help.set_defaults(func=configure_help)
|
||||
|
|
Loading…
Reference in New Issue
Block a user