blob: 3f760f2fbefb8e664e3e2684ba01b57c235a7213 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# Handle U-Boot config for a machine
2#
3# The format to specify it, in the machine, is:
4#
5# UBOOT_CONFIG ??= <default>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06006# UBOOT_CONFIG[foo] = "config,images,binary"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007#
8# or
9#
10# UBOOT_MACHINE = "config"
11#
12# Copyright 2013, 2014 (C) O.S. Systems Software LTDA.
13
Patrick Williamsc0f7c042017-02-23 20:41:17 -060014UBOOT_BINARY ?= "u-boot.${UBOOT_SUFFIX}"
15
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016python () {
17 ubootmachine = d.getVar("UBOOT_MACHINE", True)
18 ubootconfigflags = d.getVarFlags('UBOOT_CONFIG')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060019 ubootbinary = d.getVar('UBOOT_BINARY', True)
20 ubootbinaries = d.getVar('UBOOT_BINARIES', True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021 # The "doc" varflag is special, we don't want to see it here
22 ubootconfigflags.pop('doc', None)
23
24 if not ubootmachine and not ubootconfigflags:
25 PN = d.getVar("PN", True)
26 FILE = os.path.basename(d.getVar("FILE", True))
27 bb.debug(1, "To build %s, see %s for instructions on \
28 setting up your machine config" % (PN, FILE))
29 raise bb.parse.SkipPackage("Either UBOOT_MACHINE or UBOOT_CONFIG must be set in the %s machine configuration." % d.getVar("MACHINE", True))
30
31 if ubootmachine and ubootconfigflags:
32 raise bb.parse.SkipPackage("You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.")
33
Patrick Williamsc0f7c042017-02-23 20:41:17 -060034 if ubootconfigflags and ubootbinaries:
35 raise bb.parse.SkipPackage("You cannot use UBOOT_BINARIES as it is internal to uboot_config.bbclass.")
36
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037 if not ubootconfigflags:
38 return
39
40 ubootconfig = (d.getVar('UBOOT_CONFIG', True) or "").split()
41 if len(ubootconfig) > 0:
42 for config in ubootconfig:
43 for f, v in ubootconfigflags.items():
44 if config == f:
45 items = v.split(',')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060046 if items[0] and len(items) > 3:
47 raise bb.parse.SkipPackage('Only config,images,binary can be specified!')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 d.appendVar('UBOOT_MACHINE', ' ' + items[0])
49 # IMAGE_FSTYPES appending
50 if len(items) > 1 and items[1]:
51 bb.debug(1, "Appending '%s' to IMAGE_FSTYPES." % items[1])
52 d.appendVar('IMAGE_FSTYPES', ' ' + items[1])
Patrick Williamsc0f7c042017-02-23 20:41:17 -060053 if len(items) > 2 and items[2]:
54 bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % items[2])
55 d.appendVar('UBOOT_BINARIES', ' ' + items[2])
56 else:
57 bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % ubootbinary)
58 d.appendVar('UBOOT_BINARIES', ' ' + ubootbinary)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059 break
60 elif len(ubootconfig) == 0:
61 raise bb.parse.SkipPackage('You must set a default in UBOOT_CONFIG.')
62}