devtool build
cover devtool build
From: Leonardo Sandoval <[email protected]>
First patch moves all the build related code from standard.py to build.py, and second patch includes the --disable-parallel-make parameter, which as the name indicates, removes parallelism on the make tool.
The following changes since commit 22afc047dd1b8f83e56c4a9862710776c509e3c5:
oe-selftest: test devtool build-image plugin (2015-08-31 11:37:14 +0100)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib lsandov1/devtool-disable-parallelism
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=lsandov1/devtool-disable-parallelism
Leonardo Sandoval (2):
devtool: Create a single file for the build devtool feature
devtool: Allow disabling make parallelism on build command
scripts/lib/devtool/build.py | 75 +++++++++++++++++++++++++++++++++++++++++ scripts/lib/devtool/standard.py | 22 ------------ 2 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 scripts/lib/devtool/build.py
Signature · 1 line
1.8.4.5
PATCH 1/2 devtool: Create a single file for the build devtool feature
From: Leonardo Sandoval <[email protected]>
The intention is to have a single file for each devtool feature so devtool can grow in a modular way. In this direction, this patch creates build.py, moving all related build features from standard.py to build.py.
--- scripts/lib/devtool/build.py | 50 +++++++++++++++++++++++++++++++++++++++++ scripts/lib/devtool/standard.py | 22 ------------------ 2 files changed, 50 insertions(+), 22 deletions(-) create mode 100644 scripts/lib/devtool/build.py
scripts/lib/devtool/build.py new file +50 -0
@@ -0,0 +1,50 @@ +# Development tool - build command plugin +# +# Copyright (C) 2014-2015 Intel Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +"""Devtool build plugin""" + +import logging +import argparse +from devtool import exec_build_env_command + +logger = logging.getLogger('devtool') + +def plugin_init(pluginlist): + """Plugin initialization""" + pass + +def build(args, config, basepath, workspace): + """Entry point for the devtool 'build' subcommand""" + import bb + if not args.recipename in workspace: + raise DevtoolError("no recipe named %s in your workspace" % + args.recipename) + build_task = config.get('Build', 'build_task', 'populate_sysroot') + try: + exec_build_env_command(config.init_path, basepath, 'bitbake -c %s %s' % (build_task, args.recipename), watch=True) + except bb.process.ExecutionError as e: + # We've already seen the output since watch=True, so just ensure we return something to the user + return e.exitcode + + return 0 + +def register_commands(subparsers, context): + """Register devtool subcommands from this plugin""" + parser_build = subparsers.add_parser('build', help='Build a recipe', + description='Builds the specified recipe using bitbake', + formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser_build.add_argument('recipename', help='Recipe to build') + parser_build.set_defaults(func=build)
scripts/lib/devtool/standard.py +0 -22
@@ -822,22 +822,6 @@ def reset(args, config, basepath, workspace): return 0 -def build(args, config, basepath, workspace): - """Entry point for the devtool 'build' subcommand""" - import bb - if not args.recipename in workspace: - raise DevtoolError("no recipe named %s in your workspace" % - args.recipename) - build_task = config.get('Build', 'build_task', 'populate_sysroot') - try: - exec_build_env_command(config.init_path, basepath, 'bitbake -c %s %s' % (build_task, args.recipename), watch=True) - except bb.process.ExecutionError as e: - # We've already seen the output since watch=True, so just ensure we return something to the user - return e.exitcode - - return 0 - - def register_commands(subparsers, context): """Register devtool subcommands from this plugin""" parser_add = subparsers.add_parser('add', help='Add a new recipe',
@@ -886,12 +870,6 @@ def register_commands(subparsers, context): formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser_status.set_defaults(func=status) - parser_build = subparsers.add_parser('build', help='Build a recipe', - description='Builds the specified recipe using bitbake', - formatter_class=argparse.ArgumentDefaultsHelpFormatter) - parser_build.add_argument('recipename', help='Recipe to build') - parser_build.set_defaults(func=build) - parser_reset = subparsers.add_parser('reset', help='Remove a recipe from your workspace', description='Removes the specified recipe from your workspace (resetting its state)', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
Signature · 1 line
1.8.4.5
PATCH 2/2 devtool: Allow disabling make parallelism on build command
In reply to [email protected]From: Leonardo Sandoval <[email protected]>
Through --disable-parallel-make, the user can turn off parallelism on the make tool. This can be useful when debuging race conditions issues. A POSTFILE is created under 'build/conf' for further usage. So far, the file just clears the PARALLEL_MAKE variable. The postfile can be used with bitbake, including it with the '-R' parameter.
[YOCTO #7589]
--- scripts/lib/devtool/build.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
scripts/lib/devtool/build.py +28 -3
@@ -16,9 +16,12 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """Devtool build plugin""" +import os +import bb import logging import argparse -from devtool import exec_build_env_command +import tempfile +from devtool import exec_build_env_command, DevtoolError logger = logging.getLogger('devtool')
@@ -26,18 +29,39 @@ def plugin_init(pluginlist): """Plugin initialization""" pass +def _create_conf_file(values, conf_file=None): + if not conf_file: + fd, conf_file = tempfile.mkstemp(suffix='.conf') + elif not os.path.exists(os.path.dirname(conf_file)): + logger.info("Creating folder %s" % os.path.dirname(conf_file)) + bb.utils.mkdirhier(os.path.dirname(conf_file)) + with open(conf_file,'w') as f: + for key, value in values.iteritems(): + f.write('%s="%s"\n' % (key,value)) + return conf_file + def build(args, config, basepath, workspace): """Entry point for the devtool 'build' subcommand""" - import bb if not args.recipename in workspace: raise DevtoolError("no recipe named %s in your workspace" % args.recipename) + build_task = config.get('Build', 'build_task', 'populate_sysroot') + + postfile_param = postfile = "" + if args.disable_parallel_make: + logger.info("Disabling 'make' parallelism") + postfile = os.path.join(basepath,'conf','disable_parallelism.conf') + _create_conf_file({'PARALLEL_MAKE':''}, postfile) + postfile_param = "-R %s" % postfile try: - exec_build_env_command(config.init_path, basepath, 'bitbake -c %s %s' % (build_task, args.recipename), watch=True) + exec_build_env_command(config.init_path, basepath, 'bitbake -c %s %s %s' % (build_task, postfile_param, args.recipename), watch=True) except bb.process.ExecutionError as e: # We've already seen the output since watch=True, so just ensure we return something to the user return e.exitcode + finally: + if args.disable_parallel_make: + logger.info("POSTFILE placed on %s" % postfile) return 0
@@ -47,4 +71,5 @@ def register_commands(subparsers, context): description='Builds the specified recipe using bitbake', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser_build.add_argument('recipename', help='Recipe to build') + parser_build.add_argument('--disable-parallel-make', action="store_true", help='Disable make parallelism') parser_build.set_defaults(func=build)
Signature · 1 line
1.8.4.5