1# Development tool - build-sdk command plugin 2# 3# Copyright (C) 2015-2016 Intel Corporation 4# 5# SPDX-License-Identifier: GPL-2.0-only 6# 7 8import logging 9from devtool import DevtoolError 10from devtool import build_image 11 12logger = logging.getLogger('devtool') 13 14 15def build_sdk(args, config, basepath, workspace): 16 """Entry point for the devtool build-sdk command""" 17 18 sdk_targets = config.get('SDK', 'sdk_targets', '').split() 19 if sdk_targets: 20 image = sdk_targets[0] 21 else: 22 raise DevtoolError('Unable to determine image to build SDK for') 23 24 extra_append = ['SDK_DERIVATIVE = "1"'] 25 try: 26 result, outputdir = build_image.build_image_task(config, 27 basepath, 28 workspace, 29 image, 30 task='populate_sdk_ext', 31 extra_append=extra_append) 32 except build_image.TargetNotImageError: 33 raise DevtoolError('Unable to determine image to build SDK for') 34 35 if result == 0: 36 logger.info('Successfully built SDK. You can find output files in %s' 37 % outputdir) 38 return result 39 40 41def register_commands(subparsers, context): 42 """Register devtool subcommands""" 43 if context.fixed_setup: 44 parser_build_sdk = subparsers.add_parser('build-sdk', 45 help='Build a derivative SDK of this one', 46 description='Builds an extensible SDK based upon this one and the items in your workspace', 47 group='advanced') 48 parser_build_sdk.set_defaults(func=build_sdk) 49