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 | # |
| 5 | # This program is free software; you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License version 2 as |
| 7 | # published by the Free Software Foundation. |
| 8 | # |
| 9 | # This program is distributed in the hope that it will be useful, |
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | # GNU General Public License for more details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU General Public License along |
| 15 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | |
| 18 | import os |
| 19 | import subprocess |
| 20 | import logging |
| 21 | import glob |
| 22 | import shutil |
| 23 | import errno |
| 24 | import sys |
| 25 | import tempfile |
| 26 | from devtool import exec_build_env_command, setup_tinfoil, parse_recipe, DevtoolError |
| 27 | from devtool import build_image |
| 28 | |
| 29 | logger = logging.getLogger('devtool') |
| 30 | |
| 31 | |
| 32 | def build_sdk(args, config, basepath, workspace): |
| 33 | """Entry point for the devtool build-sdk command""" |
| 34 | |
| 35 | sdk_targets = config.get('SDK', 'sdk_targets', '').split() |
| 36 | if sdk_targets: |
| 37 | image = sdk_targets[0] |
| 38 | else: |
| 39 | raise DevtoolError('Unable to determine image to build SDK for') |
| 40 | |
| 41 | extra_append = ['SDK_DERIVATIVE = "1"'] |
| 42 | try: |
| 43 | result, outputdir = build_image.build_image_task(config, |
| 44 | basepath, |
| 45 | workspace, |
| 46 | image, |
| 47 | task='populate_sdk_ext', |
| 48 | extra_append=extra_append) |
| 49 | except build_image.TargetNotImageError: |
| 50 | raise DevtoolError('Unable to determine image to build SDK for') |
| 51 | |
| 52 | if result == 0: |
| 53 | logger.info('Successfully built SDK. You can find output files in %s' |
| 54 | % outputdir) |
| 55 | return result |
| 56 | |
| 57 | |
| 58 | def register_commands(subparsers, context): |
| 59 | """Register devtool subcommands""" |
| 60 | if context.fixed_setup: |
| 61 | parser_build_sdk = subparsers.add_parser('build-sdk', |
| 62 | help='Build a derivative SDK of this one', |
| 63 | description='Builds an extensible SDK based upon this one and the items in your workspace', |
| 64 | group='advanced') |
| 65 | parser_build_sdk.set_defaults(func=build_sdk) |