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 os 9import subprocess 10import logging 11import glob 12import shutil 13import errno 14import sys 15import tempfile 16from devtool import exec_build_env_command, setup_tinfoil, parse_recipe, DevtoolError 17from devtool import build_image 18 19logger = logging.getLogger('devtool') 20 21 22def build_sdk(args, config, basepath, workspace): 23 """Entry point for the devtool build-sdk command""" 24 25 sdk_targets = config.get('SDK', 'sdk_targets', '').split() 26 if sdk_targets: 27 image = sdk_targets[0] 28 else: 29 raise DevtoolError('Unable to determine image to build SDK for') 30 31 extra_append = ['SDK_DERIVATIVE = "1"'] 32 try: 33 result, outputdir = build_image.build_image_task(config, 34 basepath, 35 workspace, 36 image, 37 task='populate_sdk_ext', 38 extra_append=extra_append) 39 except build_image.TargetNotImageError: 40 raise DevtoolError('Unable to determine image to build SDK for') 41 42 if result == 0: 43 logger.info('Successfully built SDK. You can find output files in %s' 44 % outputdir) 45 return result 46 47 48def register_commands(subparsers, context): 49 """Register devtool subcommands""" 50 if context.fixed_setup: 51 parser_build_sdk = subparsers.add_parser('build-sdk', 52 help='Build a derivative SDK of this one', 53 description='Builds an extensible SDK based upon this one and the items in your workspace', 54 group='advanced') 55 parser_build_sdk.set_defaults(func=build_sdk) 56