Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1 | # Development tool - build-sdk command plugin |
| 2 | # |
| 3 | # Copyright (C) 2015-2016 Intel Corporation |
| 4 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 5 | # SPDX-License-Identifier: GPL-2.0-only |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6 | # |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 7 | |
| 8 | import os |
| 9 | import subprocess |
| 10 | import logging |
| 11 | import glob |
| 12 | import shutil |
| 13 | import errno |
| 14 | import sys |
| 15 | import tempfile |
| 16 | from devtool import exec_build_env_command, setup_tinfoil, parse_recipe, DevtoolError |
| 17 | from devtool import build_image |
| 18 | |
| 19 | logger = logging.getLogger('devtool') |
| 20 | |
| 21 | |
| 22 | def 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 | |
| 48 | def 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) |